In my video about the brand new Raspberry Pi 5, I mentioned the new external PCIe port makes it possible to boot the standard Pi 5 model B directly off NVMe storage—an option which is much faster and more reliable than standard microSD storage (even with industrial-rated cards!).
Enabling NVMe boot is pretty easy, you add a line to
/boot/firmware/config.txt, modify the
BOOT_ORDER in the bootloader configuration, and reboot!
Of course, you'll also need to get Pi OS onto the NVMe, and there are a few ways to do that—I'll walk you through my favorite method below.
Enable the external PCI Express port
Note: If using a HAT+-compliant NVMe adapter (like Raspberry Pi's own NVMe HAT), you do not need to enable the external PCIe port—it will be enabled automatically. But you can still force PCIe Gen 3 speeds using the option below.
First, enable the external PCIe port on the Raspberry Pi 5. Edit
/boot/firmware/config.txt and add the following at the bottom:
# Add to bottom of /boot/firmware/config.txt
# Note: You could also just add the following (it is an alias to the above line)
# Optionally, you can control the PCIe lane speed using this parameter
I have the
pciex1_gen=3 part commented out above because Raspberry Pi allows you to tweak the bus speed (you can choose Gen 1 for 2.5 GS/s, Gen 2 for 5 GS/s, and Gen 3 for 8 GS/s), but the port is only rated for up to PCIe Gen 2 speeds.
In practice, I have been able to run multiple NVMe SSDs at Gen 3.0 speed (getting up to 900 MB/sec) on my alpha Pi 5, but YMMV—PCIe can be very fickle, depending on the quality of the FFC cable and connections on your own setup.
Set NVMe early in the boot order
The PCIe connection should work after a reboot, but your Pi won't try booting off an NVMe SSD yet (at least, if there are any other boot devices present!). For that, you need to change the
BOOT_ORDER in the Raspberry Pi's bootloader configuration:
# Edit the EEPROM on the Raspberry Pi 5.
sudo rpi-eeprom-config --edit
# Change the BOOT_ORDER line to the following:
# Add the following line if using a non-HAT+ adapter:
# Press Ctrl-O, then enter, to write the change to the file.
# Press Ctrl-X to exit nano (the editor).
Read Raspberry Pi's documentation on BOOT_ORDER for all the details. For now, the pertinent bit is the
6 at the end: that is what tells the Pi to attempt NVMe boot first!
Reboot your Raspberry Pi 5 to make the change take effect.
NVMe boot won't work unless you have the external PCI Express port enabled, and there's a working NVMe drive with a valid boot partition! If you don't have that (e.g. you used Raspberry Pi Imager with an external USB NVMe adapter to flash Pi OS to an NVMe drive from another computer), then follow the steps in the next section to clone your existing Pi OS install to an NVMe SSD.
Flash the SSD with Raspberry Pi Imager
To get the NVMe SSD to boot your Pi, it needs to have an OS. One option would be to clone an existing installation to it using
rpi-clone or some other tool (see below), but my preferred option is to flash a fresh Pi OS install using Raspberry Pi Imager.
- Install Pi Imager and open it
- Plug your NVMe SSD into your computer using a USB to NVMe adapter
- Choose an OS to install
- Choose the drive (connected through your adapter) to flash
- Click write (and set any options you'd like)
Once flashing is complete, pull the NVMe drive, attach it to your Pi 5, and it should boot off it (with or without a microSD card inserted)—assuming you have the bootloader up to date and set the
Clone your microSD boot volume to an NVMe SSD
Assuming you already have Raspberry Pi OS on a microSD card that is booting your Raspberry Pi 5 internally, and the NVMe SSD is connected and visible (check if you see a device
/dev/nvme0n1 after running
lsblk), you can use
rpi-clone to clone the internal microSD boot volumes to your NVMe SSD:
# Install rpi-clone.
git clone https://github.com/geerlingguy/rpi-clone.git
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
# Clone to the NVMe drive (usually nvme0n1, but check with `lsblk`).
sudo rpi-clone nvme0n1
Note: I'm using my fork of
rpi-clone, because the official version has gone unmaintained—see NVMe support. Huge thanks to
Note 2: You may want to wipe all disk partitions before cloning:
sudo umount /dev/nvme0n1p? sudo wipefs --all --force /dev/nvme0n1p? sudo wipefs --all --force /dev/nvme0n1 sudo dd if=/dev/zero of=/dev/nvme0n1 bs=1024 count=1
NVMe behind a PCIe bridge / switch
Currently the Raspberry Pi 5 only exposes one PCIe lane externally—though there are four more lanes taken up by the RP1 chip. Typical PC motherboards have a number of lanes to play with, so you often find two, three, or even four M.2 NVMe slots on high-end motherboards.
Even there, some motherboards have PCI Express switches (or 'bridges') which allow multiple PCIe devices to share the same lane or lanes, in a similar way an Ethernet switch can allow multiple computers to share a single network connection.
On the Compute Module 4, bootloader space constraints prevented NVMe boot if you used a switch, but I wonder if that restriction is lifted on the Raspberry Pi 5—and if so, is it already implemented?
As of now, no. I can see and use an NVMe SSD through a PCIe switch, but I am not able to boot the Raspberry Pi 5 from it, unless it is directly connected (as the lone PCIe device on the bus).
I've opened an issue to ask about this feature in the Raspberry Pi firmware repo: Can't boot Pi 5 via NVMe behind PCIe switch / bridge.