Boot from SSD
Time: 15 minutes
Since September 2020 it is officially possible to boot your Pi from an SSD instead of the microSD. Booting this way gives better performance. In addition, this circumvents the hassle of mounting and telling every piece of software to use the SSD. Since we have the SSD anyway, why not do it?
Insert the microSD and network cable into the Pi after which you connect the power. After about a minute, the Pi will have booted up and will get an IP address from your router. Log into your router, because you'll need this IP address. Most routers can be accessed by going to 192.168.1.1 in your browser, but you know best how your network is set up.
SSH
Secure Shell is an encrypted protocol for logging into another computer and remotely executing commands on the other computer via a terminal. Through this protocol it is possible to control the Pi from our computer.
Open a terminal and type:
ssh pi@IP-ADRESS FROM PI
Replace in the command IP ADDRESS OF PI
with something like 192.168.1.6
. Once you press enter you will get a question that you can answer YES/NO
. Type yes
and press enter. You will now be instructed to enter a password. The default password is raspberry
.
Now what did we just do? You have indicated with the command that you want to use SSH. Next, you specify a user name and a computer. The computer can be reached via an IP address.
Update
Run the following commands:
sudo apt update
sudo apt full-upgrade -y
sudo rpi-update
sudo reboot now
Your Pi will now reboot after which you need to SSH into it again.
Boot configuration
By default, the Pi boots from the microSD. The Pi must be configured differently to boot from the SSD. First, the Pi must be provided with the latest firmware. Run the command below:
sudo rpi-eeprom-update -a
If all goes well, it says that the BOOTLOADER
is up-to-date and the values behind CURRENT
and LATEST
are the same. If you still need to update the Pi because it is not up-to-date or because CURRENT
and LATEST
are not equal, reboot again with sudo reboot now
.
Then it is now time to configure the Pi in such a way that we can boot from the SSD. Run the following:
sudo raspi-config
A screen appears which makes it look like you've landed in the 1980s. Choose 6 Advanced Options
.
Choose A7 Bootloader Version
.
Choose E1 Latest
.
Choose No
and press Ok
.
Choose 6 Advanced Options
again, but this time go for A6 Boot Order
.
Choose USB Boot
and press Ok
.
Choose Finish
to finish the settings.
And finally Yes
to reboot.
Double Check
To verify that everything went well, you need to SSH into the Pi again. Run the following.
vcgencmd bootloader_config
The bottom line should say something like BOOT_ORDER=0xf14 (the number can also be different, like 0xf41). If it says BOOT_ORDER=0x0, you have done something wrong.
Connect the SSD. Run lsblk
to see the storage what your Pi. If all goes well, you will see the screen below appear, or something very similar. The micro SD card will be called something like mmcblk0
and in this example sda
is the SSD.
We are going to "mount" the partitions of the SSD on the Pi. Do that with the following four commands:
sudo mkdir /mnt/bootsudo mkdir /mnt/writablesudo mount /dev/sda1 /mnt/bootsudo mount /dev/sda2 /mnt/writable
If you run lsblk
again you will see a screen like the one below. You can see that the two partitions of your SSD have been given a place in your Pi (under the heading MOUNTPOINT).
Once that looks good, you need to run a script on the Pi. The script is brought in using Git, a version control system used extensively in this guide.
sudo apt install git -y
After Git is installed, the script is retrieved and run.
sudo curl https://raw.githubusercontent.com/TheRemote/Ubuntu-Server-raspi4-unofficial/master/BootFix.sh | sudo bash
Once you see a screen saying it succeeded, you can shut down the Pi with sudo shutdown now
.
Booting
Now that we have the bootloader set up correctly, we can boot from the SSD. Remove the microSD from the Pi and plug in the SSD. Put the power and kaboom, it should work! You now need to SSH your Pi in with a different username and password. Do this as follows.
ssh ubuntu@IP.ADDRESS.OF.YOUR.PI
The default password is ubuntu
.
It might happen that you get the following error message as soon as you try to SSH to your Pi again:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!Someone could be eavesdropping on you right now (man-in-the-middle attack)!(...)
Something like this is easily solved by entering the command nano .ssh/known_hosts
on your computer. The screen that follows lists known computers for your computer. Delete the line with the IP address of your Pi. Save the file with Ctrl + X
and confirm with Y
. You have now told your computer that it may forget the previous relationship with the Pi and establish a new one.
The first time, Ubuntu will ask you to set a new password. Choose a strong password and remember it well. It is the password for the user ubuntu
and this user will later manage everything in the guide.