Installing Ubuntu on a Chromebook

I’ve been experimenting with Chromebooks for a few weeks now to try and come up with a low-power low-cost no-maintenance setup. There are a lot of very good blog posts covering the basics already, but I thought it was at least worth documenting how I got Ubuntu installed on my older Chromebook (which is a bit of a frankenstein that goes against the general ethos of not upgrading or otherwise tinkering with the hardware). This is probably best not attempted on anything with less than 32Gb of storage, and 4Gb of RAM is probably a good idea as well.

Enable developer mode

To enable developer mode, press escape and refresh and hold down the power key. When the scary message appears then press Ctrl+d and wait for the (fairly long) process to complete. This will unlock the full bash shell, and give you enough control over the Chromebook to set up a chroot.

Install Crouton

Crouton is the script that is used to install Ubuntu in a chroot. Download it from here and ensure it’s in your downloads folder. Then press Ctrl+Alt+t to open the chrosh terminal, and type shell at the command prompt. This will get you full shell access to the Chromebook.

To install Ubuntu (at time of writing 16.04) then issue the following command:

sudo sh ~/Downloads/crouton -e -t xfce

This will take a while, but when it’s done then issue the following command to start Ubuntu:

sudo startxfce4

To toggle between ChromeOS and Ubuntu use Ctrl+Alt+Shift+Back and Ctrl+Alt+Shift+Forward. Performance is actually not bad, and productivity is only an apt install firefox away.

Other useful commands

The following commands could be useful (all issued within the ChromeOS shell):

See a list of possible distributions to install:

sh ~/Downloads/crouton -r list

Back up a chroot:

sudo edit-chroot -b name

Restore it:

sudo edit-chroot -r name

Delete a chroot:

sudo delete-chroot name

My Setup

I’ve been maintaining an up to date list of what hardware and software I use since I discovered Uses This a few years ago. It usually lives as a page on this blog, but as I’ve rewritten 95% of it today then I think it deserves to be a blog post.

The hardware I use

Work – Surface Pro 4, with a Targus dock, two generic monitors and a Microsoft keyboard and mouse.

Home – A setup that looks superficially the same as work, but is older, has more cables, and has an excellent solar powered keyboard that is far superior to the Microsoft one I use at work. It also replaces the Surface Pro with a proper laptop, and adds a server with lots of memory that runs my (internal) WordPress sites and contains a backup of all my music. I also have a variety of small laptops and Raspberry Pis that fulfill various server and media functions, and a Synology NAS for backups. I’m trying to phase out a lot of my older computers and only use newer machines with SSDs and lots of memory, but it’s hard to let go sometimes.

Work from home – As home, but with an additional VM that allows me to connect to a remote desktop. Sometimes I’ll plug the Surface in, but that is only required for certain types of work and it’s far from my default setup now.

Travel – Chromebook, Raspberry Pi Zero, iPad (sometimes), Kindle and phone. Sometimes I’ll travel with my laptop, but that is rare. I also carry bootable USB versions of Ubuntu and Tails everywhere I go (even places I don’t take a computer). Increasingly my travel hardware also includes a bike and related tools.

The software I use

At work I’m running Windows 10. It’s ok, but I would like to be able to live without it.

At home (and whilst travelling) It’s a mix of Ubuntu, iOS, LibreElec ChromeOS and Raspbian (although I also have computers running Windows 10 and Mac OS that are rarely switched on now). Some of this is the legacy of spending the first half of 2018 trying to live with each main desktop OS for at least a month, which I must get round to writing up properly soon.

I use Firefox, Chrome and Safari on a daily basis, although Firefox has always been my main browser.

Other software I use that I feel is somewhat noteworthy includes:

WordPress – All my blogs run on WordPress, including several that are only available on my home network (including an extensive knowledge base containing all IT related things I learn). I currently maintain a WordPress multisite installation and several stand alone sites.

Evernote – I use this on every device I own (largely the web version now though), mostly to take notes in meetings and training sessions, and then to revise/reflect later. A lot of my notes are now photographs of whiteboards and other hand drawn scribbles, which Evernote handles very well.

Atom – A text editor that handles Markdown well, and can preview and export to PDF. I also use Pandoc to convert to PDF, HTML and/or .docx if required (I try not to use office software until the point I have to share what I’m working on with someone else).

Trello – I use this for my to do list, and it’s a good way to visualise the planning and execution of any task based work.

Dropbox – Cloud storage and syncing software to ensure I can access everything everywhere. I also use the text editor on the Dropbox mobile app to edit on the move.

IFTTT and Buffer – To automate as much as possible. Between them they handle a lot of the seemingly clever things in my digital life, and explain why I seem to be able to post to social media sites at times when I appear to be elsewhere.

Virtualbox – Because no-one needs as many physical computers as I had before virtualisation was a thing.

Spotify for discovering new music, and Rhythmbox for playing the music I already own.

My dream setup

Maybe I’m already living the dream, but the one thing I’d really like is to go back to doing everything on one computer (ideally running Ubuntu). That was possible 10 years ago, and I’m sad that it doesn’t seem possible today. I also yearn to live the life of a nomad, with just a bike, a change of clothes, and a tiny laptop to my name.

Testing on Ubuntu

This blog post details the installation process for Ubuntu when I’m using it for testing web applications. The builds are designed to conduct meaningful tests on Oracle cloud applications but should be suitable for testing any similar web application.

Test Build 1 (all tests)

Installation

  • Installed in a VM running in VirtualBox
  • Give the VM 4Gb of Ram, a 10Gb hard drive, and enable 3D acceleration
  • Install from ubuntu-18.04-desktop-amd64.iso
  • Minimal installation
  • Download updates
  • Don’t install 3rd party software

Post installation tasks

  • Launch gnome-terminal
  • Install all updates by typing sudo apt update && sudo apt upgrade -y
  • Reboot if required

Smoke tests

  • VM boots
  • User can log in
  • User can connect to internet
  • User can open Firefox and browse to a website

Test Build 2 (all tests that fail on Test Build 1)

  • Installed in a VM running in VirtualBox
  • Give the VM 4Gb of Ram, a 10Gb hard drive, and enable 3D acceleration
  • Install from ubuntu-18.04-desktop-amd64.iso
  • Normal installation
  • Download updates
  • Install 3rd party software

Post installation tasks

  • Launch Software & Updates
  • Under Ubuntu Software ensure that all 4 repositories are enabled (main, universe, restricted, multiverse)
  • Under Other Software enable Canonical Partners
  • Launch gnome-terminal
  • Install all updates by typing sudo apt update && sudo apt upgrade -y
  • Reboot if required
  • Install some software by typing sudo apt install ubuntu-restricted-extras adobe-flashplugin browser-plugin-freshplayer-pepperflash chromium-browser

Smoke tests

  • VM boots
  • User can log in
  • User can connect to internet
  • User can open Firefox and browse to a website
  • User can open Chromium and browse to a website
  • User can open LibreOffice Calc
  • User can open LibreOffice Writer

Setting up new Ubuntu computers

I’ve had to set up a few Ubuntu desktop machines recently, and I thought it was worth documenting what I install on each one, and how I automate those installations as much as possible. I wrote about this a few years ago but so much has changed with my setup that I thought it was worth revisiting these instructions.

Generally, I’ll always install from USB, and from the latest desktop version. I make my installer in Ubuntu, using Disk Image Writer and boot the computer from that. From 18.04 onwards I sometimes use the minimal installation feature (which I love), but for now assume that I just go with the defaults for everything.

Once it has finished installing, I’ll go through the process of getting everything I want on to the machine.

Install dropbox

I download the latest version from https://www.dropbox.com/install?os=lnx and then type:

sudo dpkg -i dropbox <hit the tab key>

I have a lot of files on Dropbox, so I let this sync while I’m doing the rest.

Add some software from the Ubuntu repositories

sudo apt update
sudo apt install byobu gimp vlc ubuntu-restricted-extras build-essential hexchat openssh-server gnome-tweak-tool tilix testdrive tasksel gnome-session libdvd-pkg chromium-browser youtube-dl
sudo snap install --classic atom
sudo snap install spotify

Add a script to make updating software easier

Create a new file called updateall

#!/bin/bash
echo "updateall v.1.2 for Ubuntu"
#Run this as a normal user. Your admin password will be asked for if required.
sudo apt update
sudo apt upgrade -y
sudo apt full-upgrade -y
sudo apt autoremove -y
sudo purge-old-kernels -y
echo "The script has now finished running."

I move it to /usr/local/bin/ then make it executable with sudo chmod 755 /usr/local/bin/updateall.

Install tails-installer

sudo add-apt-repository ppa:tails-team/tails-installer
sudo apt update
sudo apt install tails-installer   

Install pandoc

This installs the latest version at time of writing, although there may be updates available.

wget https://github.com/jgm/pandoc/releases/download/2.2.1/pandoc-2.2.1-1-amd64.deb
sudo dpkg -i pandoc-2.2.1-1-amd64.deb
sudo apt install texlive texlive-latex-extra

See here for more on how I configure and use Pandoc.

Cosmetic tweaks

  • Change desktop wallpaper
  • Log out, log back in, and select a vanilla Gnome desktop.
  • Go to Settings --> Security and Privacy and turn off all “phone home” functionality.

Experiments with PDF files

I’ve been experimenting a lot with combining PDF files in interesting ways (largely to make a recipe book from all sorts of different sources). I’ve used Preview on my Mac for a lot of this, but have also done a fair bit of work in Ubuntu recently which required a slightly different approach.

The best graphical PDF merging tool for Linux is probably pdfmod. It’s in the Ubuntu repositories, and can do anything Preview can do as far as merging/exporting PDF files from multiple sources.

For command line merging, pdftk does the job well. The syntax would be something like:

pdftk *.pdf cat output combined.pdf

Which would merge all PDF files in the current directory, or:

pdftk file1.pdf file2.pdf cat output combined.pdf

Which would merge two specific files.

If you need to convert Word documents to PDF prior to doing this, there is a command line tool called lowriter which is part of the libreoffice suite. The syntax would be:

lowriter --convert-to pdf *.docx

It works with .doc and .docx files.

Simple CCTV setup using a Raspberry Pi

This weekend I’ve been setting up my latest Raspberry Pi (a version III, in a blue lego case, running Ubuntu) to display a video stream of what’s going on outside my house so I can watch out for deliveries etc.

It’s something I’ve done before on different hardware, but I thought it was worth documenting as it’s a good project for any model of Raspberry Pi, and requires nothing more than the Pi, a USB webcam (or camera module), and 15 minutes of your time. I’m using a piece of software called motion which is available in the Debian/Raspian/Ubuntu repositories.

Install motion:

sudo apt-get install motion

Enable motion to start at boot:

sudo nano /etc/default/motion

Find the line that says start_motion_daemon=no and change it to start_motion_daemon=yes.

Enable the stream to be viewed from other computers on the local network, and also make the output a little bigger:

sudo nano /etc/motion/motion.conf

Change the following values:

daemon on    
width 640     
height 480     
framerate 100     
stream_localhost off    

Reboot, and then browse to port 8081 on the computer you’ve set it up on.

An updated guide to using Pandoc for document conversion

I wrote about Pandoc last year, but I’m using it more and more and I’ve found myself editing the original post a fair few times. This is the updated 2016 version that gathers together useful commands I’ve learned so far.

Last year I found myself needing to do a lot of document conversion, and maintaining documentation that needs to be available in a variety of formats (HTML, Word documents, Markdown and PDF). My tool of choice for this sort of thing is Pandoc, which is available for Windows, Mac OS X and Linux, although most of my usage so far has been on Linux and Mac OS X (it’s a command line package that can output to Dropbox, so it doesn’t matter where it runs really).

There are instructions for installing Pandoc on quite a few platforms. I’ve found that following these is generally enough, although it’s worth installing the latest version of the .deb packages rather than the one in the repositories.

On Debian/Ubuntu I also add the texlive-latex-extra package, but that’s largely because it gives me a specific Beamer theme I like to use.

If you’re using Pandoc on Mac OS X there is one more command you’ll need to issue prior to the first time you want to create a PDF file:

sudo ln -s /Library/TeX/texbin/pdflatex /usr/local/bin/

This will ensure Pandoc knows where to find pdflatex. If this step isn’t followed then you’ll likely get an error message along the lines of pandoc: pdflatex not found. pdflatex is needed for pdf output.

Pandoc works for me because I write everything in markdown, and Pandoc is great at taking markdown and converting it into almost anything else. It’s also good if you need to create a PDF, a Word document and a slide show from the same document. The syntax is fairly simple for most document types:

For example:

pandoc input.md -s -o output.docx
pandoc input.md -s -o output.html
pandoc input.md -s -o output.epub

Conversion to PDF works the same, although I’m not a fan of wide margins, so I tweak it slightly:

pandoc -V geometry:margin=1in input.md -s -o output.pdf

For a Beamer slide show you’ll need something like:

pandoc -t beamer input.md -V theme:metropolis -o output.pdf

Pandoc does a lot more, but the documentation is great, and the commands above should be enough to get you started. If you want to try out the functionality in a web browser then http://pandoc.org/try/ should be able to handle most types of conversions.

Setting up new Ubuntu machines

I’ve had to set up a few Ubuntu desktop machines recently (for my own use), and I thought it was worth documenting what I install on each one, and how I automate those installations as much as possible.

Add a script to make updating software easier

Create a new file called updateall

#!/bin/bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get clean -y
sudo apt-get autoclean -y
sudo apt-get autoremove -y
sudo purge-old-kernels -y

Move it to /usr/local/bin/ then make it executable with sudo chmod -X updateall.

Add some software from the Ubuntu repositories

updateall
sudo apt-get install git gimp byobu vlc ubuntu-restricted-extras build-essential hexchat openssh-server unity-tweak-tool youtube-dl

Install Spotify

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt-get update
sudo apt-get install spotify-client

Install atom

cd Downloads
wget https://github.com/atom/atom/releases/download/v1.7.3/atom-amd64.deb
sudo dpkg -i atom-amd64.deb

The version number may be different – get the latest version from https://github.com/atom/atom/releases/.

Install dropbox

wget https://www.dropbox.com/download?dl=packages/ubuntu/dropbox_2015.10.28_amd64.deb
sudo dpkg -i dropbox_2015.10.28_amd64.deb

The version number will be different, but hit tab after typing dropbox and it should autocomplete. If that doesn’t work, download the latest version from https://www.dropbox.com/install?os=lnx.

Install tails-installer

wget --continue http://dl.amnesia.boum.org/tails/stable/tails-i386-2.3/tails-i386-2.3.iso
sudo add-apt-repository ppa:tails-team/tails-installer
sudo apt update
sudo apt install tails-installer   

Install pandoc

wget https://github.com/jgm/pandoc/releases/download/1.17.0.2/pandoc-1.17.0.2-1-amd64.deb
sudo dpkg -i pandoc-1.17.0.2-1-amd64.deb
sudo apt-get install texlive

See here for more on how I configure and use Pandoc, and also for a fix for a Mac OS X related bug to do with rendering PDFs.

Cosmetic tweaks

Go to System Settings --> Appearance
Change theme from Ambience –> Radiance
Reduce Launcher size to 24
Change desktop wallpaper
Enable workspaces

Open Unity Tweak Tool and configure so that hot corners work, with the top left and right corner doing a window spread (largely because that’s how my Macs are set up, and also how Gnome 3 works).

Go to System Settings --> Security and Privacy and turn off all “phone home” functionality.

Updating Ubuntu

I’ve been using Ubuntu a fair bit over the last few weeks, both at work and at home. I have a number of projects on the go, and I’ve found myself needing to maintain a few different machines (both LTS and current) to run experiments on, and to built live servers and services.

One thing I’m very big on is keeping software up to date, and I thought it was worth sharing the script I use to update my Ubuntu machines (and then to delete anything that is no longer required, like old kernels).

#!/bin/bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get clean -y
sudo apt-get autoclean -y
sudo apt-get autoremove -y

I create this on each machine (in a file called updateall), move it to /usr/local/bin/ and then make it executable with sudo chmod -X update all. I then run it when I want to update software (or even better, add it as a scheduled job so it runs once a day).

If I end up with many more machines I’ll need to find something more elegant, but for now this will suffice.

Building a budget computer

I’ve been meaning to set up a low-powered Linux machine for a while, but developing a new Ubuntu-based service at work made me realise that having something at home to experiment with would be useful. I wanted something with real hardware, but also something that wouldn’t use too much power or cost me too much money.

After a bit of research, I settled on a Gigabyte Brix BXBT-2807, which is a bare bones solution that requires a hard drive, memory, and an OS to complete. Amazon says that this model now costs £94.98, although with my Prime Now discount and another voucher it cost me just over £60. I chose this model because it’s got a USB3 port (as well as 2 USB 2 ports), and it outputs to both HDMI and VGA meaning I can use it with both my existing monitor and my TV. Size-wise it’s a roughly square black box that doesn’t look big enough to be a real computer, and which takes up about the same space as a Mac Mini (being much narrower but slightly taller).

I decided to make this machine as powerful as it could be, just in case I ever needed to use it to do anything more taxing than web development and a little light browsing. I already had a 128gb SSD (which would have added about £40 to the cost), but neither of the sticks of memory I had were suitable (one was too higher voltage, the other was only 2Gb and I wanted more than that). I ended up buying an 8gb stick for around £30, which maxes out this particular case as it only has one memory slot.

Assembly was straightforward, and just required a phillips screwdriver. Once I’d fitted the hard drive and memory I connected the computer to my existing monitor, plugged in a keyboard and mouse and booted it from an Ubuntu installation USB. It booted from the USB fine, and installation didn’t take too long at all. I went with 14.04 LTS because it’s what the machine at work is running, and I do enough software updates on my other machines without having something else that was on the bleeding edge.

All in all this machine is working well (and very well for the price). I needed to add a bluetooth adaptor to get my solar powered keyboard working (but I carry a couple of these with me anyway), and this computer seems incapable of connecting to a 5MHz wireless network, but these are the only two things that are sub-optimal, and are easily fixed with a bluetooth adaptor and an ethernet cable. I’m also very impressed with how fast this machine is, and even how quickly it will perform processor-intensive tasks like ripping DVDs.

So far I’ve set up a minimal Plex server on it, plus a LAMP development environment and the tools for making Ubuntu live USB installers. I’ve also used it for a couple of days for email/web browsing, and didn’t really notice that I was on a much less powerful machine.

I’m very pleased with how quick this was to set up, and it’s good to see that it’s possible to have a fully functional computer for under £150.