13

I was wondering if you could install Ubuntu on the RPi 4 because on Ubuntu's official guide, it said it's only available for the 2 and 3. Would the edition for the Raspberry Pi 3 work on the RPi 4?

13

There is an unofficial guide at https://jamesachambers.com/raspberry-pi-ubuntu-server-18-04-2-installation-guide/ if you don't want to wait for the official release.


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 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
  StarTech 2.5″ SATA to USB 3.0 Adapter -AND- Kingston A400 SSD 120GB SATA 3 2.5" SSD
  Or for a compact setup: SanDisk Extreme Pro 128 GB USB Solid State Flash Drive
  For a micro SD card setup: SanDisk Extreme 64 GB A2 Application Class Micro SD Card

Getting Ubuntu Server

Head to the official Ubuntu Raspberry Pi page at https://wiki.ubuntu.com/ARM/RaspberryPi and scroll to the "Official Images" section.

32-bit (armhf) vs. 64-bit (aarch64)

Getting the 32-bit version of Ubuntu Server booting is easier and faster than the 64-bit version right now. If you choose to install 64-bit pay close attention to the 64-bit specific steps in the instructions as missing any of them will cause your Pi to not boot!

Right now there is a memory limitation of 1 GB in 64-bit mode on the Raspberry Pi 4. 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.

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.

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).

For now 64-bit support works on the Pi but due to Raspbian and the Pi's firmware not having an official 64-bit release it can be quirky and more difficult to configure.

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

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

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.

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 login 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 commandfree 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.

| improve this answer | |
7

No, you cannot:

RPi4 has a newer CPU, that is not compatible with the older 2/3 CPUs. Therefore, you need to wait for an RPi4-compatible release.

| improve this answer | |
  • 2
    what is the expected release date? – waspinator Sep 10 '19 at 1:43
4

Raspberry Pi preinstalled Ubuntu 20.10 Desktop and preinstalled Ubuntu 20.10 Server images are available from ubuntu.com. The preinstalled images allow you to unpack a preinstalled version of Ubuntu onto a target device.


Install Ubuntu Server

We will walk you through the steps of flashing Ubuntu Server on a Raspberry Pi 2, 3 or 4. At the end of this process, you will have a fully fledged development or production environment.

Minimum requirements

  • Raspberry Pi 2, 3 or 4
  • microSD card
  • Ubuntu Server image
  • monitor with an HDMI interface
  • HDMI cable
  • USB keyboard

Installation instructions

  1. Download the Ubuntu Server image:

    Ubuntu 19.10 Raspberry Pi 32-bit and 64-bit preinstalled images (raspi3) now support the Raspberry Pi 2, 4, and 4 platforms out of the box. The below links will be updated when 20.04 is officially released.

  1. Flash the microSD card

    Copy the Ubuntu image on a microSD card by following the installation media instructions.

  2. Install Ubuntu Server

    Attach the monitor and keyboard to the board. You can alternatively use a serial cable.
    Insert the microSD card and plug the power adapter into the board.

  3. Login

    When prompted to log in, use "ubuntu" for the username and the password. You will be asked to change this default password after you log in.

First boot tips

You can install a desktop environment if you like. Here are some popular ones:

sudo apt install xubuntu-desktop  
sudo apt install lubuntu-desktop  
sudo apt install kubuntu-desktop   
sudo apt install ubuntu-mate-desktop^ # full desktop + applications
sudo apt install mate-desktop-environment-core # very basic set of programs that are necessary to start a MATE desktop environment session

For more details about Raspberry Pi specific packages included with this image and further customizations, such as accelerated video drivers and optional package repositories, you can refer to the RaspberryPi wiki.

Source: Revised from: Install Ubuntu Server on a Raspberry Pi 2, 3 or 4

| improve this answer | |
3

People are saying it will be available in a while:

Ubuntu MATE for Raspberry Pi 4

The lead developer of Ubuntu MATE 18.04.2 for the Raspberry Pi 3, Martin Wimpress, has tweeted a photo of a Raspberry Pi 4, saying:”This should keep me occuPIed 4 a while.”

| improve this answer | |
0

See this video https://www.youtube.com/watch?v=HMo9C7LCzE0 It shows you how to install Ubuntu server 19.10 with a Desktop

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.