Revision 46 as of 2018-04-24 11:51:08

Clear message

Raspberry Pi

With the release of the Raspberry Pi 2 Model B and its ARMv7-based BCM2709 processor, it is now possible to run Ubuntu directly on the Raspberry Pi.

Note that the information on this page currently only applies to the Raspberry Pi 2 and 3, not the original Raspberry Pi.

Snappy Ubuntu Core

Snappy Ubuntu Core is a new rendition of Ubuntu with transactional updates - a minimal server image with the same libraries as today’s Ubuntu, but applications are provided through a simpler mechanism. Images are available for the Raspberry Pi 2 and 3.

Ubuntu 18.04 LTS 'classic'

Most of the information regarding 16.04 below applies to 18.04 as well.


Ubuntu 16.04 LTS 'classic'

These are not Ubuntu Core images, but the 'classic' deb based image. The Raspberry Pi 3 does not (yet) work with official Ubuntu images out of the box, but unofficial images are available.


Note: The Pi 2 image is an updated Ubuntu 16.04.4 LTS classic image. The Pi 3 is an Ubuntu 16.04 LTS classic image.

Login username is "ubuntu", password is "ubuntu". You will be asked to change the password on first login.


Installation is the same as other Raspberry Pi images; a generic installation guide from raspberrypi.org is available here.

For example:

xzcat ubuntu.img.xz | sudo dd bs=4M of=/dev/mmcblk0

Or using ddrescue (must decompress the image first):

unxz ubuntu.img.xz
sudo ddrescue -D -d --force ubuntu.img /dev/mmcblk0

Optional PPAs

While the official image includes compatible firmware, bootloader and kernel, there are a few packages available in an unofficial PPA (ppa:ubuntu-raspi2/ppa) which are useful on the Raspberry Pi, including:

  • libraspberrypi-bin - VideoCore utilities from https://github.com/raspberrypi/userland such as vcgencmd, raspistill, etc.

  • libraspberrypi-bin-nonfree - Binary VideoCore utilities not provided in the open source userland repository, currently vcdbg and edidparser.

  • xserver-xorg-video-fbturbo - An accelerated x.org video driver, though this is limited to hardware accelerated window moving/scrolling on the Raspberry Pi.

  • hello-dkms - Not strictly to do with the Raspberry Pi, but a small example DKMS project to test building kernel DKMS modules.

To install:

sudo add-apt-repository ppa:ubuntu-raspi2/ppa
sudo apt-get update

Further Raspberry Pi packages can be found in the Ubuntu Pi Flavour Maker PPA.


This is a small ubuntu-server image. If you want a full desktop, go ahead and do so:

$ sudo apt-get install xubuntu-desktop  # or
$ sudo apt-get install lubuntu-desktop  # or
$ sudo apt-get install kubuntu-desktop  # etc

Ubuntu (Unity) and Ubuntu-GNOME just display a blank screen, presumably because they require 3D compositing. Kubuntu works but is slow unless you turn off desktop effects under System Settings. Xubuntu and Lubuntu work fine out of the box.

Tasks can be installed and removed with Tasksel.

Accelerated X driver

An accelerated x.org video driver is available (fbturbo), though this is limited to hardware accelerated window moving/scrolling on the Raspberry Pi. Install the optional PPA above, then:

$ sudo apt-get install xserver-xorg-video-fbturbo

Then add this to /etc/X11/xorg.conf (create if it doesn't already exist):

Section "Device"
    Identifier "Raspberry Pi FBDEV"
    Driver "fbturbo"
    Option "fbdev" "/dev/fb0"
    Option "SwapbuffersWait" "true"


As with Raspbian, VideoCore packages are available. Install the optional PPA above, then:

$ sudo apt-get install libraspberrypi-bin libraspberrypi-dev

However, since these packages are compiled from source during build, the files are installed in their "proper" locations in /usr. Some third-party scripts may expect e.g. /opt/vc/bin/vcgencmd; if so, this hack should do it:

$ sudo ln -s /usr /opt/vc

(Raspbian packages use precompiled repositories during build, which install in /opt/vc.) vcdbg and edidparser are not part of the open source package and must be installed separately:

$ sudo apt-get install libraspberrypi-bin-nonfree

Booting the official Pi 2 image on the Pi 3

The official Ubuntu images use u-boot as the bootloader. The u-boot binary built for the Pi 2 does not work on the Pi 3. This is why there are separate images for the Pi 2 and Pi 3.

However, the Raspberry Pi has its own built in bootloader. This can be used with a few changes to the config.txt file on the system-boot partition:

initramfs initrd.img followkernel

Note the change to the kernel line, the addition of the initramfs line, and the commenting out (#) of the device_tree_address line.

All that remains is to copy bcm2710-rpi-3-b.dtb (plus the overlay folder if needed) from /lib/firmware/4.4.0-1065-raspi2/device-tree to the system-boot partition.

Once booted, you'll need to either uninstall the flash-kernel package, or upgrade the flash-kernel and u-boot packages from ppa:ubuntu-raspi2/ppa-rpi3.

If you've chosen to uninstall the flash-kernel package then you'll need to manually copy across the kernel and initrd files when you install a new kernel or update the initramfs. For example (note, the system-boot partition is mounted at /boot/firmware):

sudo cp /boot/vmlinuz /boot/firmware/
sudo cp /boot/initrd.img /boot/firmware/

USB booting

The Raspberry Pi 3 (and Pi 2 v1.2 with the same BCM2837 SoC as the Pi3) is capable of booting from a USB drive. To do this you'll first need to program USB boot mode.

You must have bootloader files (confusingly referred to as the firmware on the Raspberry Pi) from after April 2017. So grab the latest bootcode.bin, fixup.dat and start.elf files from the GitHub repository and copy them to your system-boot partition.

Edit the cmdline.txt file

sudo nano /boot/firmware/cmdline.txt

and change root=/dev/mmcblk0p2 to root=LABEL=cloudimg-rootfs

If you are using a lot of drives then you may wish to switch to using the UUID of the partition.


The built-in WiFi on the Pi 3B and 3B+ requires some updated/extra files:

mkdir wifi-firmware
cd wifi-firmware
# Pi 3B
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43430-sdio.bin
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43430-sdio.txt
# Pi 3B+
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.bin
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.clm_blob
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.txt 
sudo cp *sdio* /lib/firmware/brcm/
cd ..

Reboot the machine.

Cross-upgrading 14.04 to 16.04

You can upgrade an old unofficial 14.04 installation to the official 16.04 installation, though it takes a number of additional steps.

Note that Ubuntu's setup uses u-boot as an intermediary bootloader, which is different from the previous system of the RPI2 booting the kernel directly. This will be reflected in the upgrade procedure.

Warning /!\ Once you begin this procedure, if you reboot the installation without completing the entire upgrade procedure, you will be left with an unbootable system. Warning /!\

First, remove a number of PPA packages which are obsoleted / incompatible with the 16.04.

apt-get --purge remove rpi2-ubuntu-errata raspberrypi-bootloader-nokernel \
  linux-image-rpi2 flash-kernel

Back up and remove the apt PPA configuration and module blacklists (the latter will be provided directly by the 4.4.0 kernel package).

mkdir -p /root/xenial-upgrade
tar zcvf /root/xenial-upgrade/etc.tar.gz \
  /etc/modprobe.d/rpi2.conf \
  /lib/modules-load.d/rpi2.conf \
  /etc/apt/preferences.d/rpi2-ppa \
  /etc/apt/sources.list.d/fo0bar-rpi2* \
rm -f \
  /etc/modprobe.d/rpi2.conf \
  /lib/modules-load.d/rpi2.conf \
  /etc/apt/preferences.d/rpi2-ppa \
  /etc/apt/sources.list.d/fo0bar-rpi2* \

Back up and remove the contents of /boot/firmware, which will be recreated.

tar zcvf /root/xenial-upgrade/firmware.tar.gz /boot/firmware/*
rm -rf /boot/firmware/*

Update apt sources without the old PPA configuration.

apt-get update

Run do-release-upgrade as normal. When asked to reboot at the end, do not, and select "n" instead.

do-release-upgrade -d
# -d will be unneeded once 16.04.1 is released

Install new firmware, u-boot and 4.4.0 kernel metapackages.

apt-get install u-boot-rpi u-boot-tools linux-raspi2 linux-firmware-raspi2 \
  linux-firmware flash-kernel

Install the RPI2 DT-compatible u-boot image.

apt-get install binutils  # for "strings"
wget -O /tmp/mkknlimg https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.4.y/scripts/mkknlimg
chmod 0755 /tmp/mkknlimg 
/tmp/mkknlimg --dtok /usr/lib/u-boot/rpi_2/u-boot.bin /boot/firmware/uboot.bin

Install basic config.txt and cmdline.txt configurations. If your root device is not on the second SD partition (uncommon) or you have a more advanced configuration, recreate them here.

cat <<"EOM" >/boot/firmware/config.txt

cat <<"EOM" >/boot/firmware/cmdline.txt
net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Update the initrd and re-flash the kernel configuration.

update-initramfs -u



Optionally add ppa:ubuntu-raspi2/ppa as described above.

Ubuntu 14.04 LTS

An Ubuntu 14.04 LTS (Trusty Tahr) image is available for the Raspberry Pi 2, which combines the released 14.04 distribution with a PPA containing kernels and firmware which work on the Raspberry Pi 2.

Warning /!\ This image, along with the one-off kernel it installs, is no longer maintained. Please use the 16.04 Xenial image instead. Warning /!\



Root resize

There are no Raspbian-specific utilities included, specifically no automatic root resizer. However, it's not hard to do manually. Once booted:

$ sudo fdisk /dev/mmcblk0

Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

$ sudo resize2fs /dev/mmcblk0p2


There is no swap partition/file included. If you want swap, it's recommended you do:

$ sudo apt-get install dphys-swapfile

You should have a (resized) SD card at least 4GB, because by default it will want to create a ~2GB swapfile.

Wifi firmware

If you are using a wifi dongle, you will likely need to get the linux-firmware package:

$ sudo apt-get install linux-firmware

SSH server

If you would like to install an SSH server for remote access:

$ sudo apt-get install openssh-server

Serial console

To enable the serial console, change the /boot/cmdline.txt as follows:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootwait

and add a new file /etc/init/ttyAMA0.conf:

start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]

exec /sbin/getty -L 115200 ttyAMA0 vt102


The kernel used by the Raspberry Pi 2 port is an Ubuntu-style kernel package of an "rpi2" flavor, e.g. linux-image-3.18.0-20-rpi2. Currently it is comprised of the following functionality:

Ubuntu's 3.18 development is no longer active, as they moved on to 3.19 to be released with 15.04 vivid. However, mainline 3.18 was designated an LTS kernel release, and is still getting active security/stability updates. Because of this, 3.18 will likely remain the "supported" kernel of this port. (Again, this is an unofficial port and no support guarantee is implied.)


  • The script used to build the images is available here.

If you want to build an image on your x86 Ubuntu host, install qemu-user-static package and edit the script to use "qemu-debootstrap --arch armhf" instead of "debootstrap":

qemu-debootstrap --arch armhf $RELEASE $R http://ports.ubuntu.com/

Ubuntu arm64/AArch64

'arm64' is the Debian port name for the 64-bit ARMv8 architecture, referred to as 'aarch64' in upstream toolchains (GNU triplet aarch64-linux-gnu), and some other distros.

BCM2837 is the chip used in the Raspberry Pi 3 and in later models of the Raspberry Pi 2. It packages a 64-bit quad-core ARM Cortex A53 (ARMv8) CPU with VideoCore IV GPU.

There is a config.txt entry to make the ARM start in 64-mode (otherwise 32-bit mode is used):


(This will fail to boot unless you provide a kernel compiled for 64-bit mode)

64 bit versions of the linux-raspi2 kernels were introduced in Ubuntu 16.10 (Yakkety Yak).

Booting generic ISO images

The generic arm64 linux kernels can also be used with a suitable bootloader. For example, the Bionic mini.iso, ubuntu-17.10-server-arm64.iso and bionic-live-server-arm64.iso can be booted with a u-boot-UEFI-grub2 combination. This can be achieved as follows:

Create a partition with pi firmware/bootloader files

The Raspberry Pi's bootloader, built into the GPU and non-updateable, only has support for reading from FAT filesystems (both FAT16 and FAT32). So the first step is to create a partition on a SD card or USB device and format it as FAT.

Next, download and copy across the GPU firmware and bootloader files (start*.elf, fixup*.dat and bootcode.bin). The very latest files can be found at https://github.com/raspberrypi/firmware, but releases can be downloaded as follows:

wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20180417-1_armhf.deb
dpkg-deb -x raspberrypi-bootloader_1.20180417-1_armhf.deb /tmp/pi-bootloader

Mount the FAT formatted partition and copy the files across

sudo mount /dev/XXX1 /mnt
sudo cp /tmp/pi-bootloader/boot/* /mnt

Compile U-boot

Ubuntu includes an ARM cross compiler than can be used to compile U-boot for the RPi:

sudo apt install git make gcc gcc-aarch64-linux-gnu
git clone --depth 1 git://git.denx.de/u-boot.git
cd u-boot
make rpi_3_defconfig
make CROSS_COMPILE=aarch64-linux-gnu-

Copy it to the partition:

sudo cp u-boot.bin /mnt/kernel8.img
cd ..

Calling it kernel8.img means that 64-bit mode is automatically used.

Copy the device tree blob

An optional stage is to provide a dtb file:

wget http://ports.ubuntu.com/dists/bionic/main/installer-arm64/current/images/device-tree/bcm2837-rpi-3-b.dtb
mkdir /mnt/dtb/broadcom/
sudo cp bcm2837-rpi-3-b.dtb /mnt/dtb/broadcom/
sudo umount /mnt

"Burn" the iso and boot the pi

Use dd to burn the iso to a separate USB flash drive.

Insert the device containing the bootloader files, plus the burnt USB flash drive into the Raspberry Pi and power on!

Note, once you've made your selection via the grub menu, there is a long blank screen interval before the installer shows on the screen.

Alternative: Copy the iso contents to the FAT partition

If the above fails to boot or if you don't have a spare flash drive, then you can combine the contents of the iso with the bootloader files:

sudo mount /dev/XXX1 /mnt
wget http://ports.ubuntu.com/dists/bionic/main/installer-arm64/current/images/netboot/mini.iso
mkdir /tmp/mini-iso
sudo mount -o loop mini.iso /tmp/mini-iso
sudo cp -rT /tmp/mini-iso /mnt

Note, if you are doing this via a graphical file manager then you must ensure you copy the hidden .disk folder.

Finally extract the bootaa64.efi file and copy it across:

mkdir /tmp/efi-img
sudo mount -o loop /tmp/mini-iso/boot/grub/efi.img /tmp/efi-img
sudo cp -rT /tmp/efi-img /mnt
sudo umount /tmp/efi-img
sudo umount /tmp/mini-iso
sudo umount /mnt

Building Raspberry Pi 3 images

To build a Raspberry Pi 3 image, you will need an armhf 18.04 LTS (bionic) build host (or chroot) and a fair amount of working space (at least 10GB).

Branch lp:~fo0bar/livecd-rootfs/raspi2-rpi3, build its .deb and install it.

As root:

apt-get install live-build
mkdir -p build/chroot
cd build
cp -a /usr/share/livecd-rootfs/live-build/auto .
export ARCH=armhf
export SUITE=xenial  # or bionic
# export MIRROR=http://deb-proxy.local/ubuntu-ports  # if you have a local caching proxy
export IMAGEFORMAT=ext4
export SUBARCH=raspi3
export PROJECT=ubuntu-cpc
export EXTRA_PPAS="ubuntu-raspi2/ppa-rpi3"
lb config
lb build