Most of the time you might have seen a Raspberry Pi booting from an SD card. Don’t be in the presumption that an SD card is the only option to boot a Pi. Raspberry Pi can be booted from any type of USB storage, no matter whether it’s a thumb drive or a superfast PCI SSDs. We are pleased to show you how to boot Raspberry Pi from a USB drive in this tutorial. In this tutorial we are going to cover why you should boot a Raspberry Pi from a USB drive, what difference you may see when booting a Raspberry Pi from a USB drive, and three ways to boot a Raspberry Pi from a USB drive. First, it is necessary to know why you want to use USB drives to boot Raspberry Pi. The answer to this question lies in the following section.
Booting From USB Drive Is Right for You?
You may see using an SD card to boot a Raspberry Pi in most of the tutorials. Even official Raspberry Pi documentation is no exception. But there is a reason for that. SD cards are portable to use. You need not maintain a separate unit for storage. It’s been seen that there is a dramatic reduction in performance when flash drives have been used against SD cards. You may ask how the Pi would perform if you use HDDs/SSDs. They have a track record of an impressive performance against SD cards. Well, yes, you may yield better performance if you use hard drives. But, you may need to bear with additional components like a USB cable for the data transfer hard drive itself with a case for protection. Additionally, an extra power unit if the power drowns from the Pi is not sufficient to run the hard drive. All these requirements make this option inconvenient. If you are ready to compromise with all these inconveniences, then you will get a stable, durable, and performance-oriented Pi for your project. Both ways are better in their way, and both of them have their own pros and cons in practical. See this table which tells the difference in a simple way. We feel this table would help you to decide what is right for you.
|Booting from SD card||Booting from Hard Drive|
|More convenient||Faster than SD cards which increase performance|
|Portable||Hard drives must remain attached|
|Finite lifespan||Longer lifespan|
|Simple Backups||More complicated Backups|
Which Method Is to Use to Boot From USB?
If you are made up your mind to try booting your Pi from a USB hard drive. Then you are in the right place. We always encourage you to try exploring different options. We can tell you what we have experienced. But it may not be true in your case. You should try this practically. You are not going to learn until you get your hands dirty. All right, let’s hop on to the actual topic. There are multiple different methods to boot a Raspberry Pi from USB hard drives. Ultimately, it all depends on which model of Pi you are using. We are going to show you three different methods of booting a Pi in this tutorial. It is important to know each one of them before getting started. Each method is better in some terms than others. Let’s have some knowledge of all three methods one after another.
Method #1: Raspberry Pi Imager.
This method is very simple and straight as Raspberry Pi Org starts supporting the USB boot option on the new upcoming models. There is no need to tweak bootloader settings and flashing of EEPROM in the latest model. Booting from a USB drive is as same as booting a Pi from an SD card using the Raspberry Pi imager tool. You just need to select the hard drive instead of the SD card in the imager application while writing the boot image. Bear in mind that this method will work only on Raspberry Pi OS 2020–08–20 or newer and Raspberry Pi 400 and later models. Please check out our post “How easy to set up a Raspberry Pi ” to know more about booting a Raspberry Pi from an SD card.
The other two methods are a debatable topic. One method says to hijack the complete root file system from the SD card into the USB drive. Other methods say to upgrade the firmware from the official Raspberry Pi org to boot the Pi from USB storage. We would like to compare both of the methods using a table here in this section.
|Upgrade Firmware||Moving the root file system|
|Only works with newer models||Works with all models|
|Requires a change on the Pi itself||Portable from one system to another|
|Procedure may differ between models||Universally applicable to all models|
|No need of SD card||SD card is mandatory to have|
Method #2: Moving the Root File System.
This method is closer to the universe. No matter what model you have, starting from its early release to the present, it works flawlessly. Let’s get into it from scratch. This procedure is divided into Five simple steps.
- Backup your SD card
- Trigger the file system check
- Clone the SD card to a hard drive
- Configure the hard drive as a boot partition
- Expand the swap
Time needed: 30 minutes.
Moving the root file system:
- Take a backup of your SD card:
Let’s start the procedure by taking a backup of your SD card. Use a built-in ‘SD card copier’ or any other program of your choice to copy the content of the SD card before processing.
- Trigger the file system check:
It’s good to start with a file system checkup to ensure everything is correct before moving the file system to the USB drive. Create a file named ‘forcefsck’ in the root directory. This file indicates the system to check the file system in the next reboot. If your Pi is hooked up to a monitor, you can see what is going on on the Pi. If not, just give a little extra time to the Pi to complete the boot process and come up. If you see your Pi booted without any errors, then your pi passed the file system test successfully. The file ‘forcefsck’ will disappear from the root directory. This is only a one-time test. However, you can trigger another test by repeating the process.
$ sudo touch /forcefsck
$ sudo reboot
- Clone the SD card to a hard drive:
The first step to booting from a hard drive is to copy the content of the SD card to the hard drive partition. All of you know that the Raspberry Pi imager creates two partitions on the SD card. We need to copy the content of the boot partition of the SD card to the hard drive. To do this let’s find out the data to be copied from which SD card’s partition to which hard drive’s partition. Let’s check the boot partitions now and take note of PARTUUID.
$ cat /boot/cmdline.txt
- List all the storage partitions using blkid command
List all the storage partitions using blkid command. Here we have a hard drive attached and connected to the Pi with three partitions created on it. Please check our post “How to Partition and Format the Hard Drives on Raspberry Pi:” to know how the hard drive has been partitioned..
$ sudo blkid
- Match the PARTUUID of boot partition in the result of blkid command
All right, now we know the data to move from which partition to which partition. Let’s break it down for you. Match the PARTUUID of boot partition in the result of blkid command. this gives the information about the data to be copied from /dev/mmcblk0p2 partition to /dev/sda1 partition. Let’s copy the content using ‘dd’ command. dd command will not show any progress information. You need to wait until the backup process gets completed. Time depends on the size of the data. It may take a longer time if you have more data on your SD card. It tests your patience.
$ sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=32M conv=noerror,sync
dd: A command used to copy files or a partition.
if: input file
of: output file
bs: block size
conv: conversion options
- Check the target partition for errors
After completion of the data transfer, check the target partition for errors using the file system consistency check command.
$ sudo e2fsck -f /dev/sda1
- Try Remounting the drive for errors
If you see something like Cannot continue. Remount the drive and try the same command.
- Reboot the Pi
You may see some errors like this, and there is something corrupted on the SD card file system. Try to repeat the process by turning off the Pi without shutdown. Or try taking the previous backup again. The safest way is to do this by copying the contents of the SD card to a place and using that as a source for the dd command, which prevents copying any files on the fly from the SD card. After all, errors go off. Reboot the Pi.
$ sudo reboot
- Pi will read the partition by itself
Soon after reboot, your Pi will start reading the whole boot partition by itself. You can do this manually, too, by Issuing this command. This shouldn’t take a long time. When you finish this command, the new root system will have access to the full OS partition.
$ sudo resize2fs /dev/sda1
- Configure the hard drive as a boot partition:
To set up the hard drive as your boot device, you need modification in these two places:
Substitute the PARTUUID of /dev/sda1 in /boot/cmdline.txt
$ sudo blkid
- Edit the cmfline.txt
Copy the PARTUUID of /dev/sda1. Edit the /boot/cmdline.txt file using any text editor and replace the PARTUUID of the boot partition with the PARTUUID of /dev/sda1.
$ sudo nano /boot/cmfline.txt
- Delete the PARTUUID of /dev/mmcblk0p2 and write the PARTUUID of /dev/sda1. Save and reboot the Pi.
- Edit the /etc/fstab and replace the PARTUUID of /dev/mmcblk0p2 with PARTUUID of /dev/sda1
After the reboot, it starts using the hard drive. For any reason, your Pi didn’t boot with your hard drive, you can connect your hard drive to your desktop computer and edit the /boot/cmdline.txt file. But you should have PARTUUID of /dev/sda1 or /dev/mmcblk0p2 handy to update and boot your Pi with your choice of storage.
Edit the /etc/fstab and replace the PARTUUID of /dev/mmcblk0p2 with PARTUUID of /dev/sda1.
- Mark the PARTUUID from the fstab table
- Mark the new PARTUUID from the fstab table
- Reboot the Pi
Reboot one more time.
$ sudo reboot
- Expanding the swap:
Now you are booting your Pi from your hard drive. If you are running new PI models which have 4 or 8 GB of RAM on them. You may need to expand the system swap. Raspberry Pi is already using swap partitions but in a very small amount. Use swapon command to see how much space is configured as a swap. It’s just 100 MB.
$ swap -s
- Increase the swap size
To increase the swap size edit the file ‘/etc/dphys-swapfile’. And, reboot the Pi.
- Confirm the increase of SWAP size
Comment the ‘CONF_SWAPSOZE-100’ line and uncomment the CONF_SWAPFACTOR=2. This would automatically pick up the swap size as twice the RAM size. When next time you reboot, your swap size will be 8 GB on a 4 GB model of Pi. Please make sure you have enough space on your boot partition before touching the swap configurations. We recommend doing this when you have a boot disc larger than 32 GB.
Method #3: Updating the Bootloader Eeprom
This method is suitable only for Raspberry Pi 4 and 4B models. Depending on when your Raspberry Pi 4B was manufactured, the bootloader EEPROM may need to be updated to enable booting from USB mass storage devices. If you have older models of Pi with you, you are probably going to break down your Pi if you follow this procedure. The procedure would differ with different models. Please pay attention to your procedure and Pi model before taking any decision. Visit this site to see how to upgrade the EEPROM of Raspberry Pi.
Now, we hope you have some idea of different ways to boot a Raspberry Pi from a USB drive. It’s a debatable topic to decide on SD card vs USB storage. If you have new models of Pi, we recommend using USB storage. If not, just fine to stick with an SD card. Again, we recommend using super-fast SSD or at least faster HDDs if you are decided to go for a USB boot. Because flash drives are never found to be the best performers, you can use them as long as you are okay with their performance.
If you have older models of Pi, we never recommend using USB storage as your default boot device. You may need to flash EEPROM on your Pi. This is a one-time procedure. You can’t undo this once you do the flash. This procedure is quite complex. It’s not for beginners. Moreover, the procedure would differ with different models. There are chances of damaging the Pi if you follow the wrong procedure. It’s better to use an SD card to boot up the Pi and use the USB storage as an extended drive to increase the storage capacity.
Thanks for reading this article. If you find this article interesting, please visit our site to read more such interesting articles.
For method 2, after the reboot on step 17 I now only have a flashing cursor at the top left of the screen. I'm working with the Pi 4B with 8Gb RAM, a 3.5A power supply and the SSD I'm trying to boot from is the Kingston A400 plugged into a USB-SATA adapter (same result whether I use the USB 3 or 2 slots).
Now it's only trying to boot from the SSD via USB, I don't know how I can fix it since I now can't boot from the SD card and amend things via the GUI – help please!
I am sorry to hear that you have ended up in trouble. Answer these questions to help fix this problem.
Did you check the target partition for errors? Did you notice any errors?
Did Pi read the partitions?
Did you follow all the steps that make the hard drive bootable? (step 10 to 16)
If all the above things are perfect, then you should try powering the Hard drive with additional power input.
If nothing works for you, try booting the Pi in recovery mode: https://drjohnstechtalk.com/blog/2019/08/raspberry-pi-recovery-mode-or-interrupting-the-boot-process/
Let me know if this solves your problem.
Very nice manual. Worked out but how do you solve the reboot issue? I removed the sd-card and powered it on with the usb drive attached and the raspb pi-4 started without any problem. However after a reboot the raspb pi 4 didn't start. Seems there is a power-issue with the usb 3 slot. Powering off and on again resolved the problem. So no problem when you are at home. In my case there is a problem because I use the rpb at a different location with rdp so I won't be able to pull the plug.
Did you try this on which Pi module and storage? I tried this with SSDs, I don’t see any problem on my Pi 4 mod B 8 GB.
I did the copy process with BalenaEtcher. now I got this:
[email protected]:~# blkid
/dev/mmcblk0p1: UUID=”6725-6501″ BLOCK_SIZE=”512″ TYPE=”vfat” PARTUUID=”0e2887fb-01″
/dev/mmcblk0p2: UUID=”98fa3b6b-e750-4e39-8191-3b4eae912463″ BLOCK_SIZE=”4096″ TYPE=”ext4″ PARTUUID=”0e2887fb-02″
/dev/sda1: UUID=”6725-6501″ BLOCK_SIZE=”512″ TYPE=”vfat” PARTUUID=”0e2887fb-01″
/dev/sda2: UUID=”98fa3b6b-e750-4e39-8191-3b4eae912463″ BLOCK_SIZE=”4096″ TYPE=”ext4″ PARTUUID=”0e2887fb-02″
/dev/sda3: UUID=”65b6c8f8-0fde-42c2-8014-16d1c20701f7″ TYPE=”swap” PARTUUID=”0e2887fb-03″
How to find out, if the SSD is working as intended?
It is simple to ensure the partition is working. Just mount the partition and try writing some data on that or create a text file.