Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide

Ubuntu Server logo
Ubuntu Server logo

Ubuntu Server has been my favorite Linux distribution for years. On everything but the Raspberry Pi I run Ubuntu Server but felt stuck with Raspbian on the Pi. Until now! Ubuntu Server 18.04.2 has been released and major improvements have been made to the official Pi branch.

The Raspberry Pi 4 is not officially supported out of the box yet on the current Ubuntu Server Raspberry Pi images but you can get it working by manually updating the firmware. Solid state storage is also working but with the catch of having to use a micro SD card as a bootloader since the Pi 4 does not have official boot support yet. I describe how to do both in this article.

The Raspberry Pi’s peripherals such as WiFi / Bluetooth are now fully supported. Previous Ubuntu Server versions for Raspberry Pi (like many other distros) had broken or completely missing drivers for core components such as WiFi / Bluetooth. In the 18.04.2 update the firmware for the WiFi and other components is now included out of the box making it a fully functional distribution!

This is the first distribution besides Raspbian that feels like you can just image it and everything works. I’ll guide you through the process in this guide. It only takes a few minutes to set up.

Recommended Gear

I highly recommend upgrading to a solid state setup. The performance gains are gigantic. It’s now less than 30 bucks to take your Pi solid state. This is the best performance upgrade you can possibly get for a Pi.

With the new Raspberry Pi 4 it’s even more beneficial to use USB storage since a USB 3.0 bus was finally added in the Pi 4 letting it take full advantage of solid state drives. This is the setup I am currently using:

Raspberry Pi 4 Model B 2 GB

Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide

StarTech 2.5″ SATA to USB 3.0 Adapter -AND- Kingston A400 SSD 120GB SATA 3 2.5” Solid State Drive

Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide
Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide

Or for a compact setup: SanDisk Extreme Pro 128 GB USB Solid State Flash Drive

Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide

For a micro SD card setup: SanDisk Extreme A2 Application Class Micro SD Card

Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide

These storage choices are ones that all scored highly on the end-user submitted Raspberry Pi Storage Benchmarks and will give you outstanding I/O performance on the Raspberry Pi. I also personally own all of them and recommend them knowing they are compatible and perform well on the Pi.

Getting Ubuntu Server

64 bit (aarch64)

If you want to use the 64 bit version you CloudKernels has built an updated image for the Pi 4. Here is a direct link to the 64 bit Ubuntu Server Pi 4 image: https://cloudkernels.net/ubuntu-18.04.3-preinstalled-server-arm64+raspi4+kvm.img.xz

Right now there is a memory limitation of 1 GB in 64 bit mode on the Raspberry Pi 4. This is apparently due to the SD card driver breaking when more than 1 GB of RAM is present. This will all be solved eventually but until then I recommend using the 32 bit version of Ubuntu or waiting until the Raspberry Pi 4 support catches up. If you want to run the 64 bit one now anyway it works fine other than the memory limitation.

The Raspberry Pi 4 brought us all the way up to the 4 GB barrier but to expand past that Raspbian will eventually have to go 64 bit as one of the limitations of a 32 bit operating system is it can only address 4 GB of RAM. To break the 4 GB memory addressing barrier the operating system is going to *have* to go 64 bit (aarch64/arm64).

32 bit (armhf – recommended)

You should choose the armhf 32 bit version for now unless you have a specific need for a 64 bit distribution. The 32 bit version is faster and more stable for the overwhelming majority of use cases. The 64 bit version has come a very long way and is totally usable at this point but there are still some significant downsides.

To get the 32 bit version head to the official Ubuntu Raspberry Pi page at https://wiki.ubuntu.com/ARM/RaspberryPi and scroll to the “Official Images” section. Until the official Raspberry Pi 4 image is released choose the Raspberry Pi 3B+ armhf release and follow the directions in the next sections to update the firmware for a Pi 4 boot.

Writing the Base Image

This part is easy. Extract the image from xz format to img format (7zip is great and free and can extract these). Now write the img to your media (Micro SD card, solid state drive, USB storage, etc). the same way you would for any other distribution!

Updating Firmware for Raspberry Pi 4

If you are using the CloudKernel 64 bit image you can skip to the “Boot Ubuntu Server” section as it already implements the updated firmware. If you are using the 32 bit image or the official Ubuntu Server preinstalled server image from Ubuntu’s web site you will need to update the firmware using these instructions.

Remove Existing Firmware

The firmware in the current release was not built with Raspberry Pi 4 support so we need to update the firmware on the /boot/ partition for the Pi 4 to be able to boot correctly.

Insert/mount the micro SD card in your computer and navigate to the “boot” partition. Delete everything in the existing folder so it is completely empty.

Download Latest Firmware

32 bit Firmware Instructions

If you are trying to run the 64 bit version of Ubuntu skip to the 64 bit instruction section next. For 32 bit versions of Ubuntu download the firmware from the official GitHib repository here: https://github.com/raspberrypi/firmware/archive/master.zip

The latest firmware is everything inside master.zip “boot” folder (including subfolders). We want to extract everything from “boot” (including subfolders) to our micro SD’s “boot” partition that we just emptied in the previous step. Don’t forget to get the “overlays” folder as that contains overlays necessary to boot correctly.

The end result will look something like this on the “boot” drive:

$ ls
  COPYING.linux                bcm2711-rpi-4-b.dtb   kernel.img
  LICENCE.broadcom             bootcode.bin          kernel7.img
 'System Volume Information'   cmdline.txt           kernel7l.img
  bcm2708-rpi-b-plus.dtb       config.txt            overlays
  bcm2708-rpi-b.dtb            fixup.dat             start.elf
  bcm2708-rpi-cm.dtb           fixup4.dat            start4.elf
  bcm2708-rpi-zero-w.dtb       fixup4cd.dat          start4cd.elf
  bcm2708-rpi-zero.dtb         fixup4db.dat          start4db.elf
  bcm2709-rpi-2-b.dtb          fixup4x.dat           start4x.elf
  bcm2710-rpi-3-b-plus.dtb     fixup_cd.dat          start_cd.elf
  bcm2710-rpi-3-b.dtb          fixup_db.dat          start_db.elf
  bcm2710-rpi-cm3.dtb          fixup_x.dat           start_x.elf

64 bit Firmware Instructions

To boot Ubuntu Server in 64 bit mode we need to download the 64 bit version of the firmware. The .dtb files are different between 32 bit and 64 bit operating systems. Raspbian does not come with a 64 bit bootloader and one isn’t provided in the official GitHub repo either.

Building the 64 bit version of the firmware yourself requires a cross compile toolchain and a lot of time but it is an option. Fortunately sakiki has provided a blob of the 64 bit version firmware intended to be used to boot Raspberry Pi 4 64 bit devices in the mean time while support continues to catch up.

Download the firmware blob: https://github.com/sakaki-/gentoo-on-rpi3-64bit/releases/download/v1.4.2/deploy_root_p4.tar.xz

Extract the files from deploy-root/bootfs in the archive to the “boot” partition on the SD card that we cleaned out in the previous step. This will give us our 64 bit bootloader.

Create/Update config.txt and cmdline.txt

Navigate to the micro SD /boot/ partition. Create a blank cmdline.txt file with the following line:

dwc_otg.fiq_fix_enable=2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rootflags=noload net.ifnames=0

Next we are going to create config.txt with the following content:

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]

[all]

64 bit config.txt Configuration

To boot the Pi in 64 bit mode we need to add the following lines to the config.txt:

total_mem=1024
arm_64bit=1
enable_gic=1
armstub=armstub8-gic.bin 

The final configuration for 64 bit will look like this:

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]

total_mem=1024
arm_64bit=1
enable_gic=1
armstub=armstub8-gic.bin

[all]

These enable all the different 64 bit related options you need to perform a 64 bit boot on the Pi.

Note on total_mem=1024: at the moment the Raspberry Pi 4’s SD card won’t work in 64 bit mode without capping the total memory to 1 GB. This is being worked on and will be fixed as soon as official support rolls out.

Boot Ubuntu Server

We are now ready to boot the device. Insert the micro SD card and power on the device.

Note: The very first startup can be very slow. Be patient. It can take up to 2-3 minutes with no activity lights then all the sudden everything will start blinking and SSH will open up.

Fix apt-get update / Prevent Further Updates

If you try to apt-get update now it will try to update your firmware with older firmware from the Ubuntu repository. The workaround for now is to remove that package so it keeps your existing firmware. Make a note to remember you did this step as later on we will want to reenable updates from the repository once support has been added.

sudo apt remove flash-kernel initramfs-tools

You may now run sudo apt-get update && sudo apt-get upgrade but don’t use dist-upgrade yet because the kernels in the repository it will update you to don’t support the Pi 4 yet. But this should get you all up to date on the packages!

Once the firmware in the apt repositories has been updated for the Pi 4 it will be safe to reinstall initramfs-tools and let it update through the normal process again.

Solid State Drive (SSD) Configuration (Optional)

USB booting has not been added into the Raspberry Pi 4 firmware yet but is being worked on right now. In the mean time you can use your micro SD card as a bootloader and still boot the whole operating system (rootfs) from the solid state drive giving you the full USB 3.0 speed increases system wide. Once the Pi USB booting is officially released you should be able to boot directly from the device without any makeshift bootloader SD card necessary.

First create a fully imaged and booting micro SD card following the earlier steps in the tutorial. After you have created the micro SD installation you should now image your SSD / USB drive with the same Ubuntu image you used to create the SD card.

Now navigate to the “boot” partition on the newly created SSD / USB drive and remove everything in there just like we did with the SD card earlier. Now copy the “boot” folder from the micro SD card to the solid state drive. This is necessary because even though the files in “boot” are read off our micro SD card initially some firmware files in the later load stages are read off the mounted drive and if the necessary firmware files are missing the system won’t boot.

Now that you’ve created the SSD / USB drive partitions and copied the “boot” partition from the SD card to your new drive we need to update your SD card’s cmdline.txt to point to the SSD / USB drive’s partition.

dwc_otg.fiq_fix_enable=2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rootflags=noload net.ifnames=0

The key part we need to change here is the “root=/dev/mmcblk0p2” section. mmcblk0p2 is a hardware identifier for micro SD storage. We need to change this to the device your storage is detected as.

If you are using a USB to solid state drive adapter it’s very likely your drive will be addressed as /dev/sda2. Therefore we will change the root=/dev/mmcblk0p2 to root=/dev/sda2

root=/dev/sda2

The final line will be:

dwc_otg.fiq_fix_enable=2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 rootwait rootflags=noload net.ifnames=0

Plug both the micro SD and the solid state drive into the Pi and boot it up.

Remember: the first boot can take 2-3 minutes for first startup so give it some time before assuming it didn’t work.

Configuration

Default User / Password

The username and password for your initial login to Ubuntu Server will be:

user: ubuntu
password: ubuntu

You will be required to change your password after logging in for the first time. Make sure on the prompt you enter the current “ubuntu” password before typing in your new password or the device will kick you out completely and you’ll have to log in again.

Set Time Zone

To configure the correct time zone for Ubuntu Server use the following command:

sudo dpkg-reconfigure tzdata

This will take you to a very easy to follow menu to select your correct time zone and applies it to the system.

Update System

For best stability, security and performance you should immediately update your system and packages to the latest version. This will also grab all of the latest fixes/improvements making your Raspberry Pi Ubuntu experience much better.

This part is easy. Type:

sudo apt-get update && sudo apt-get upgrade

Change Default GPU Memory Split

The default amount of memory allocated to the GPU on the Raspberry Pi is around 76 MB of our 1 GB. In 2 GB and 4 GB models the amount gained from this is negligible but is still worth it for the 1 GB model.

If you type the command “free” you will see that your Raspberry Pi is missing this memory under the “total” column. We can reclaim most of this memory back by setting the GPU memory split to 16 MB. If you are planning on installing a GUI in the future you should not make this change.

This option is set in the config.txt file. It’s exactly the same file as Raspbian uses but it is located at /boot/firmware/config.txt instead of /boot/config.txt. Open config.txt with the following command:

sudo nano /boot/firmware/config.txt

We will add the following line at the bottom of config.txt:

gpu_mem=16

Press Ctrl + X and type yes to save the file. Now restart the Pi by typing

sudo reboot

After the reboot finishes type “free” again and you will see that your total available memory has increased and can now be used by the system and your applications!

Benchmark Storage (Optional)

It’s very important to have a well performing storage device on the Raspberry Pi. Storage has always been and continues to be one of the biggest performance bottlenecks for Raspberry Pis.

Until the Raspberry Pi 4 we didn’t even have 3.0 transfer speeds. Now that we have them with Raspberry Pi 4 we are discovering there is a very large difference between not only manufacturers and models, and in the case of SD cards the manufactured date / batch produced! This means that if you bought a FakeName Extreme 3.0 in 2015 you could buy the exact same line and brand of SD card one year later and you would get something with a totally different grade of flash memory and microcontroller that would perform much better/worse.

Because no one person could possibly buy all this hardware and benchmark it on their own I created a script to benchmark your storage and anonymously submit it via a basic web form here.

The best thing would be for you to run the script but if you don’t want to run it yourself check out the existing recommendations for high performance storage ideas to get the most out of Ubuntu Server on the Pi.

Conclusion

I’m very excited to see my favorite Linux distributions continue to evolve to the point where they are comparable in performance and stability to Raspbian. I’ve been testing extensively on Ubuntu Server 32 bit and 64 bit for my Raspberry Pi Minecraft Server project and not only is it on par with Raspbian but starting to do things so well it sometimes makes Raspbian feel a little dated.

If you have any questions or suggestions don’t hesitate to leave me a comment on the post or use my contact form to message me privately! I’m good about responding quickly and my articles are constantly revised to address questions or do something a better way that a reader pointed out.

Have fun!

73 thoughts on “Raspberry Pi 4 Ubuntu Server 18.04.3 Installation Guide”

  1. Avatar for Dan

    Comment on SD card choices – we heavily tested read/write and overall throughput of the best Sandisk and Samsung SD cards … the Samsung hands down are better/faster cards! Even when specs are lower the Samsung is faster, for instance the Samsung Pro Endurance is faster than the Sandisk Endurance. Also, when buying Sandisk, realize when you see specs and they look the same and you can’t figure out the difference, for instance in the Ultra vs UltraPlus … the ONLY difference is the length of the warranty, ZERO other difference in the cards, you are paying for a longer warranty!

    1. Avatar for jamesachambers

      Definitely check out my Raspberry Pi storage benchmarks.

      I agree with your recommendations mostly. SanDisk and Samsung are outperforming all other cards. One caveat I will mention though is that the very newest SanDisk Extreme (Pro, Plus, etc) A1/A2 cards are beating all of Samsung’s offerings but it is very close.

      You can go to my Pi Storage benchmarks link and under the “Product” drop down box choose SDXC. Now sort by the Score column and you can see all the user submitted benchmarks for SD cards!

  2. Avatar for Florian Vamosi

    Does WiFi really work with the Pi 4? Just wondering, because I can’t get the wlan0 interface to even show with ifconfig, or lshw. It does show with Raspbian, so there is no hardware failure I think. Could this have something to do with now just the 18.04.03 image being available, and the 18.04.02 not anymore?

    Thanks!

    1. Avatar for Ryan

      Hey Florian, WiFi does work with the Pi 4. Installing Raspbian, wifi worked just fine, but following this guide for ubuntu server I have had no luck as many others are stating.

      I’m running 18.04.3 and one thing I’ve been noticing as I’m trying to check for loaded kernel modules is that “uname -r” is returning “4.19.66.v7l+” but I only have library modules for “4.15.0-1041-raspi2” so any lsmod/modprobe/depmod command is failing and I’m wondering if that has anything to do with wlan0 (80211 module) not showing up. I also tried using my iPhone as a network tether but the ipheth module also doesn’t appear to be loading. Again, I’m thinking it has to do with the kernel version mismatch but haven’t determined anything definitive yet…and, I’m getting ready to call it quits for the day too 🙂

      Guessing this has something to do with the recent updates to the master firmware zip or the fact we’re using 18.04.3 instead of the original 18.04.2. I’ll keep digging through it tomorrow as this seems to be affecting a number of the folks that are following this guide recently (myself included).

      1. Avatar for Ryan

        Success!! I went a bit further down the rabbit hole of the mismatched kernels and ended up pulling the /lib/module/4.19.57* directories from a Raspbian image into my running ubuntu 18.04 pi 4, rebooted and now I have wifi and can run lsmod/modprobe/etc again. I’ll try to write up a bit more detail once I finish what I’ve been working on here at work and maybe James can update the documentation once we get a good handle of all the details. I’ll also try to create an image that I can share to get people up and running by just slapping it on an SD card and booting up.

  3. Avatar for Pete Chua

    Great guide, I am able to boot into ubuntu server on rpi4. However wifi doesn’t seem to be able to be detect. Anyone managed to get wifi working?

    ubuntu@ubuntu:~$ nmcli d
    DEVICE TYPE STATE CONNECTION
    eth0 ethernet unmanaged —
    lo loopback unmanaged —
    ubuntu@ubuntu:~$

  4. Avatar for Stigma

    During the initial boot up it just stops after it says No authorized SSH Keys Fingerprints… “Begin SSH Fingerprint ..End SSH fingerprinting…” and then it will just hang there forever. Left it on for over an hour and just stuck there never booting in.

  5. Avatar for Deen Misic

    I cant get this to work, nothing shows up on the screen, I am using a rpi 4 4gb, and Im trying to install the 32bit version. But when I plug it in nothing shows up and I have left it on for 30mins and nothing, I installed the 32bit github repo (firmware master.zip) file and I added the config.txt and cmdline.txt, I think thats where I went wrong, what I did was create a textedit named the file and copy and pasted the couple of lines that it told me to, I then put it in the root of the micro sd card and booted it up, but nothing shows up. Someone please help me :).

    Please explaining step by step because I am new to this and dont know much.

  6. Avatar for tanon

    Is there and easy way to get the kernel headers for the kernel that ships with the image? When checking uname -r and dmesg, the kernel is reported as 4.19.63-v7l+, but /usr/src/ only has folders for raspi-headers for 4.15.0, which is quite limiting if you need to compile additional drivers…

Leave a Comment

Your email address will not be published. Required fields are marked *

Type here..