Jonathan Ryan Grice's Blog

If you want a very lightweight OS for the Raspberry Pi 3, Ubuntu Server is the way to go IMO. There is a couple nuances that we will have to tackle before and after upgrading Ubuntu Server that is specific to the Raspberry Pi that I have encountered. This tutorial will help you get past the conflicts and have a Raspberry Pi 3 running the latest version of Ubuntu Server.

There are a few Prerequisites that are needed before we begin.

  1. Raspberry Pi 3
  2. Formatted Micro SD Card
  3. Win32 Disk Imager (https://sourceforge.net/projects/win32diskimager/)
  4. Ubuntu Server preinstalled iso for Raspberry Pi 3 (https://wiki.ubuntu.com/ARM/RaspberryPi)
  5. A network connected desktop or laptop to download and burn the ISO to the SD Card.
  6. Optional: PuTTY to SSH to the Raspberry Pi 3 (http://www.putty.org)

First download and write the Ubuntu Server ISO for the Raspberry Pi 3 to the Micro SD card using Win32 Disk Imager.

Put the Micro SD card into your Raspberry Pi 3 and plug it in. You can also plug in a USB keyboard and mouse if you will be completing this tutorial from the Raspberry Pi. Otherwise you can SSH into Ubuntu from another device using PuTTY. You will need to get the IP address of the Raspberry Pi 3 from your router or type ifconfig into the terminal on the Pi. The IP of the Raspberry Pi 3 will be listed beside inet addr under eth0.

The first time Ubuntu Server will boot, it will ask for the username and password (user: ubuntu | pass: ubuntu) and ask you to change the default password. This password will be used to SSH if you choose to do so on a headless Raspberry Pi 3.

We need to use either apt or apt-get to update and upgrade Ubuntu Server. Type in the following diversion into the terminal before updating or upgrading. It will resolve a conflict for the firmware being served by two packages.

sudo dpkg-divert --divert /lib/firmware/brcm/brcmfmac43430-sdio-2.bin --package linux-firmware-raspi2 --rename --add /lib/firmware/brcm/brcmfmac43430-sdio.bin

Now we can finally update and upgrade Ubuntu Server without any conflicts. Type in the following commands into the terminal and allow them to complete.

sudo apt update
sudo apt upgrade

Before we reboot our Raspberry Pi 3, we need to change the device tree address in our config.txt file, otherwise Ubuntu Server will not be able to boot.
Type in the following:

sudo nano /boot/firmware/config.txt

Edit the lines:

device_tree_address=0x100
device_tree_end=0x8000

They should now be:

device_tree_address=0x02008000
#device_tree_end=0x8000

Press Ctrl + X to exit Nano.
When prompted to save, press Y.
When prompted to confirm the filename press Enter.

Now we can restart our Raspberry Pi 3 and it will boot Ubuntu Server without any problems.

Bonus: Let's fix the error message: sudo: unable to resolve host ubuntu
Type the following into the Terminal:

sudo nano /etc/hosts

Add ubuntu to the first line so it reads:

127.0.0.1 localhost ubuntu

Press Ctrl + X to exit Nano.
When prompted to save, press Y.
When prompted to confirm the filename press Enter.

Extra Bonus: If you want a very lightweight desktop environment on your Raspberry Pi 3, we can install LightDM and I3.
LightDM is a Greeter or Login Prompt. I3 is a Window Manager. Applications that has a GUI and no CLI will need I3 or an equivalent window manager to run (e.g. Chromium Browser).
I also threw in Synapse and Build Essential. Synapse is an App Launcher and Build Essential will enable linux to build any modules in the future that isn't available as prebuilt binaries for the armhf architecture.
This can be installed by typing the following command:

sudo apt install -y lightdm i3 synapse build-essential

After the installation finishes, reboot the Raspberry Pi. LightDM will start giving you a GUI to log into Ubuntu. Don't login just yet. Instead press, CtrlAltF1 to fallback to a tty login screen and login.

Now we need to tell X to start i3 when it starts. Type the following into the terminal:

sudo nano ~/.xinitrc

In this new file, only add the following line:

exec i3

Press Ctrl + X to exit Nano.
When prompted to save, press Y.
When prompted to confirm the filename press Enter.

Now reboot the Raspberry Pi 3.

sudo reboot

When the Pi reboots you will be prompted with the LightDM login screen. Before logging in, press TabEnter and reselect i3. Now login throught LighDM and i3wm will start. You will be prompted to generate a configuration file. Press Enter. Now set your Mod Key, you can select either the Win or Alt key. Press Enter.

Extra Bonus: Sound. Let's get sound working on the Raspberry Pi. This was aggravating to find the correct setting from sifting through all the crap posts on different forums. After trial and error I have managed to track down the one command to enable sound. Let's be out with it then.

Open a terminal window by pressing ModEnter.

Open the Raspberry Pi config file with nano by typing the following into the terminal window:

sudo nano /boot/firmware/config.txt

Add the following line to the end of the file.

dtparam=audio=on

Press Ctrl + X to exit Nano.
When prompted to save, press Y.
When prompted to confirm the filename press Enter.

If you want to add a tray icon in i3 to control the volume, simply install pnmixer. Type the following into the terminal window:

sudo apt install pnmixer

Now reboot and enjoy sound.

Extra Bonus: After the installation finishes, now would be a good time to backup your SD Card using Win32 Disk Imager which can be restored if at anytime you break your installation.

***The instructions for backing up your newly installed Ubuntu Server has been stricken because the option does not restore the backed up snapshot correctly and it encounters too many errors.
Backup your SD Card manually using Win32 Disk Imager on your desktop or laptop until an alternative backup/restore solution can be found.

Alternatively, you could create a Restore Point using TimeShift.

If you opt to use TimeShift, the repository will have to be added and TimeShift will need to be downloaded.

Within i3, Press Mod +  Enter. This will bring up a terminal window. Type in the following to install TimeShift.

sudo apt-add-repository -y ppa:teejee2008/ppa
sudo apt update
sudo apt install -y timeshift

When the installation finishes, you can close the terminal window by pressing, Mod + Shift + Q.

Now press Mod D, type in sudo timeshift-launcher and press Enter.

When Timeshift opens you will be prompted with a dialog. Click Finish to close the dialog. On the main Timeshift gui. Click Create and backup your system for the first time. Note: This will take a while.

When Timeshift finishes, you can press ModShiftQ to close Timeshift.

If you ever run into any problems after changing any configuration file or installing a program, you can use Timeshift to Restore back to the saved Snapshot.

Updated: It's been a while since I've played with the Raspberry Pi 3. In doing so, I forgot my password. I have written a short tutorial on how to reset your current password. You can read about it here on my blog at Pre-installed Ubuntu Server Raspberry Pi 3 Reset Password.