Raspberry Pi 4 recently started supporting booting from SSD drives directly rather than using a slower, more fragile SD card.
Although, there’s a lot of content describing how to create a new system on SSD, it doesn’t seem like there’s a good summarizing article describing how to take your existing Ubuntu install, with all your existing server configurations and files etc, and move that existing install from SD card to SSD.
I’ll try to answer the many unclear steps in the process.
- Raspberry Pi’s bootloader has a 2020/09/03 version that just started supporting booting from SSD.
- Ubuntu 20.10 supports booting from SSD “out-of-the-box” without messing with the boot folder’s kernel files yourself.
Given the above and given the assumption that you bought your Raspberry Pi 4 before September 2020 and you already have a <20.04 Ubuntu you spent time configuring, this guide is for you.
Optional read. You don’t have to understand Raspberry Pi 4’s boot sequence, but it could help with terminology.
First, there’s a bootloader which isn’t on your SD card or the SSD. It’s a small 512KB chip on the board itself. It decides what the boot hardware sequence is.
Then there’s a boot folder which contains the next basic steps like the firmware and Linux kernel etc. For both the Raspbian OS and Ubuntu, it’s on a separate partition on your SD card or SSD when you flashed your OS card initially.
Finally, the second partition on your SD or SSD is the root mount directory for your OS. That’s where all your files are.
The goal is to copy the SD card’s 2 partitions to the SSD.
Backup your SD card
Optional but probably really wise to backup your SD card first. Turn off your Raspberry Pi and insert the SD card into another machine (probably with a bigger drive than your SD card).
If it’s a *nix machine like macOS or Linux, first find out what the SD card’s name is.
diskutil list # for macOS; or
lsblk # for Linux
You also need to unmount the drive first. Eject on a Mac, or
Then byte-wise copy everything from the SD card into a file.
sudo dd if=[location of your SD card] of=[location of a file where you want to save to] status=progress
Update your Ubuntu to 20.10
Ambiguity 1: can any existing Ubuntu install be booted from SSD.
Answer: sort of. Assuming you don’t want to go through the trouble of manually configuring your boot partition, just upgrading to 20.10 might be the easiest solution.
While still booted in your SD card install, upgrade to 20.10.
Ambiguity 2: do all Ubuntu variants’ 20.10 support external USB/SSD?
Answer: yes, it doesn’t matter if you have Desktop/Server or Ubuntu MATE etc.
lsb_release -a for your current Ubuntu version (which is probably not 20.10 if you’re reading this).
First stay updated
sudo apt update
sudo apt dist-upgrade
If you’re on Server, you might need to install the update manager
sudo apt install update-manager-core
If you started off with something like 20.04 which is a long term support version, it’ll stay on that track and not update to 20.10 unless you change the track. Use your favorite editor:
sudo emacs /etc/update-manager/release-upgrades
If it said
Prompt=lts, change it to
Save the file. Then
Give it a while to upgrade. Then confirm you have 20.10 by running
lsb_release -a again.
Update your bootloader
Prep work #2, you need to update the bootloader as mentioned above.
Ambiguity 3: it seems like Raspbian OS has a dedicated tool to do all the bootloader management stuff, what do I do in Ubuntu?
Answer: as far as I can tell, the Raspbian tool isn’t special. You can just install the package in Ubuntu.
Get the bootloader tool
sudo apt install rpi-eeprom
Then check your current bootloader version to see if you need to do anything. The bootloader also has tracks. Critical or stable.
The 2020/09/03 version is the latest critical version with the stable version being monthly and having more recent versions. Just opting here to be conservative and update to 2020/09/03.
If yours already says something like
CURRENT: Thu Sep 3 12:11:43 UTC 2020 (1599135103)
you can skip this whole section. Otherwise, there’s a whole bunch of ways of tweaking your bootloader configs and update your version etc, but the easiest 1 step way is:
sudo -E rpi-eeprom-config --edit
This opens an editor (that you specified in your $EDITOR, or just opens nano) with the bootloader configuration displaying. Here, if you’d like to customize the order of boot for your Raspberry Pi, you can do so by adding a
BOOT_ORDER row (details here).
BOOT_ORDER=0xf41 will try SD card first, then USB. If neither works, the Raspberry Pi reboots and retries everything again.
BOOT_ORDER=0xf14 does the reverse. Tries USB first, then the SD card. Then if both fail, reboot and retry again.
Save and exit the file. It should then prompt something like the bootloader will be re-written on the next boot. Double check that the bootloader image being written looks something like
Copy your SD card to an SSD
Ambiguity 4: will the Raspberry Pi pump enough power through USB to power my portable SSD enclosure?
Answer: magnetic drives will use more power. But if you supplied a full 3A to your Raspberry Pi, it should work. I used a Samsung T7 SSD. If it doesn’t, you can use a powered USB hub.
At this point, don’t reboot yet, since you don’t have an SSD card with your OS yet.
There’s a bunch of ways you can do this. I used this script https://github.com/billw2/rpi-clone, which worked fine for me. To “install” it, just clone the GitHub repo and move it. See https://github.com/billw2/rpi-clone#on-other-os.
$ git clone https://github.com/billw2/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone /usr/local/sbin/sys-clone
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
It just uses a combination of
dd for the first partition and
rsync for the second partition to not copy some junk over like /tmp/ etc.
Connect your SSD at this point. It should get recognized automatically. Run
to find its name (probably something like
sba depending on how many USB drives you have connected).
Then just run the rpi-clone thing
sudo sys-clone sba
replacing sba with the location of your drive as needed.
The script will ask you for a label. It’s actually important since your SD card’s boot partition’s configuration (and thus your future SSD boot partition’s configuration) actually specifies how to find the drive to mount as root. In this case, the coupling is really loose. The configuration file is at
/boot/firmware/cmdline.txt. There’s a part in that file that says
root=LABEL=writable. That’s the label. So your label (the script asks for the label of the second partition) must be
At this point, you can try shutting down your Raspberry Pi, removing the SD card and try booting again. If it works, you’re done.
Update the boot folder
In my case, upgrading to 20.10 didn’t actually update the boot folder on my SD card in the first place. I had to do it manually to get everything to work.
Using the same SD that’s now copied to the SSD (you did backup right?) or with a different SD card, write a fresh Ubuntu 20.10 install.
Specifically, go to https://www.raspberrypi.org/software. The easiest way is to download an imager tool for another machine’s OS. The burn a new 20.10 (server or otherwise) install on an SD card.
Then boot into that card (by removing the SSD first if needed). The default Ubuntu ssh password is
ubuntu. Once in, then mount the SSD drive again by plugging it in, then finding the name of the drive with
Mount it to a mount point, such as
sudo mkdir ssd-boot
mount /dev/sba1 /mnt/ssd-boot
# replace sba1 with the first partition of your SSD as needed
Then copy off everything from the new Ubuntu install’s boot folder (mounted by default to
/boot/firmware to the SSD. Such as via
rsync -avh /boot/firmware/ /mnt/ssd-boot/ --delete
Old Ubuntu versions have a bunch of other kernels and firmware for older Raspberry Pi hardware. The 20.10 image seems cleaner so
--delete gets rid of all the old files too.
Shutdown, remove the SD card and reboot and it should work now.