code_exec
Posts: 271
Joined: Sun Sep 30, 2018 12:25 pm

How to setup Ubuntu Server for the Raspberry Pi 3

Sat Feb 16, 2019 12:33 pm

Starting with Ubuntu 18.04.2 and Ubuntu 19.04, Canonical now produce official images for the Raspberry Pi 3, both in armhf and arm64 formats. However, there are some tweaks I recommend doing if you want to enjoy Ubuntu Server on the Pi to its full potential.

1. Change the bootloader

Both the armhf and arm64 images use u-boot as the bootloader, which can be hard to configure if it doesn't fit your display and it also blocks the Pi 3's built in WiFi. Because of this, I still recommend using the Raspberry Pi's built-in bootloader. This will allow you to swap a microSD card across a Pi 2 and a Pi 3 (armhf only), configure the config.txt and cmdline.txt to fit your display, and access the Pi 3's built-in WiFi.

Flash the image to a microSD card, but before you insert it into the Pi, remove the kernel entry from config.txt, and then reconfigure it so that the Pi's bootloader directly boots the kernel and initrd. Here's an entry for this:

Code: Select all

kernel=vmlinuz
initramfs initrd.img followkernel
Insert the microSD card into your Pi and power on!

2. Enabling USB booting

The Ubuntu Server images now come with recent copies of the bootloader files (bootcode.bin, *.elf, *.dat) meaning that USB booting is now possible, but unfortunately not out of the box. The cmdline.txt points the kernel to /dev/mmcblk0p2 as the root partition, meaning the kernel will fail to boot Ubuntu if you attempt to boot from USB. Fortunately, this can be fixed with a simple change to the cmdline.txt.

For the original Pi 3B, you need to program USB booting first if you want to boot from USB. This is not needed on the Pi 3B+ or 3A+ since USB booting is enabled by default on these models.

Flash the image to USB storage but before you insert it into the Pi, replace the root entry with the following:

Code: Select all

root=LABEL=writable
Insert the USB storage into the Pi and boot.

3. Enabling hardware accelerated graphics

You can use the experimental VC4 driver with the linux-raspi2 kernel. Simply add the following entry to config.txt to enable it:

Code: Select all

dtoverlay=vc4-kms-v3d
Be aware that this will cause the image to fail to boot on the Pi 3A+ due to memory requirements.

4. Desktop environment

This is a minimal Ubuntu Server image which does not come with a desktop environment preinstalled. However, one can be installed with one of the following commands:

Code: Select all

sudo apt install xubuntu-desktop # For Xubuntu's desktop
sudo apt install ubuntu-budgie-desktop # For Ubuntu Budgie's desktop
sudo apt install kubuntu-desktop # For Kubuntu's desktop
sudo apt install xfce4 # For vanilla XFCE
sudo apt install lxde # For vanilla LXDE
sudo apt install kde-plasma-desktop # For vanilla KDE Plasma
5. Enabling swap

If you plan on using resource-hungry web browsers and other resource-hungry software, I recommend creating a swapfile. Do so with the following commands:

Code: Select all

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Add the following entry to /etc/fstab:

Code: Select all

/swapfile swap swap defaults 0 0
Reboot and swap should be available, which can be checked with the following command:

Code: Select all

sudo swapon --show
6. Removing cloud-init

cloud-init can slow down boot time, so you should get rid of it unless you actually plan on actually using the image as a server. Run the following commands to remove it:

Code: Select all

sudo rm -rf /etc/cloud/
sudo apt purge cloud-init
7. 64-bit kernel and 32-bit userland

If you want to install a 64-bit kernel and therefore be able to run 64-bit software on the armhf image, simply run the following commands:

Code: Select all

sudo dpkg --add-architecture arm64
sudo apt update
sudo apt remove linux-raspi2
sudo apt install linux-raspi2:arm64
Configure the config.txt to tell the Pi's bootloader to boot in 64-bit mode by adding the following entry to config.txt:

Code: Select all

arm_64-bit=1
Reboot and run the 'arch' command. It should return 'aarch64'. You can now install arm64 software. For example, to install 64-bit Firefox:

Code: Select all

sudo apt install firefox:arm64
You can also setup a chroot for running arm64 applications.

Is Ubuntu Server worth it on the Raspberry Pi? Yes. You get up-to-date software such as Firefox which is several versions behind in Raspbian. You also get a 64-bit Linux distro (if you chose the arm64 image) which is based on Debian like Raspbian, giving Raspbian users a distribution which is the same in many ways (same package manager, etc). I recommend you at least give it a try and post about your experience with it.

Credit to everyone who contributed to the Raspberry Pi page on the Ubuntu Wiki. A lot of the information in this post was based on the information provided by the Ubuntu Wiki.
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.

https://github.com/CodeExecution/Ubuntu-ARM64-RPi

gilius
Posts: 93
Joined: Sun Apr 08, 2018 1:12 pm

Re: How to setup Ubuntu Server for the Raspberry Pi 3

Sun Feb 17, 2019 12:27 pm

I guess you mean this:
http://cdimage.ubuntu.com/releases/18.0 ... 1550368866
Instead of this:
https://www.ubuntu.com/download/iot/raspberry-pi-2-3

You forgot the login details: ubuntu/ubuntu

Unfortunately, I can't get this to boot from USB on my B+ - with or without the "root=LABEL=writable".
sudo apt install lxde # For vanilla LXDE
This seems to require updating Ubuntu first, but still ends up "failing to start session". I will try XFCE next.

Return to “Other”