Skip to content
GEEKnodes

Raspberry Pi

Boot the Raspberry Pi 5 From an NVMe SSD (M.2 HAT, BOOT_ORDER)

How to boot the Raspberry Pi 5 from an NVMe SSD: fit the M.2 HAT, update the EEPROM, change BOOT_ORDER, clone the microSD and fix common errors.

The Raspberry Pi 5 has a PCIe connector that, with an M.2 HAT, lets you use an NVMe SSD as the boot drive. You gain speed and, above all, reliability over the microSD. This guide explains the assembly, bootloader configuration and how to move your current system to the SSD.

In short

  • You need an M.2 HAT (official or third-party), a 2230 or 2242 NVMe SSD and an up-to-date EEPROM (newer than December 6, 2023).
  • Boot order is set in the EEPROM’s BOOT_ORDER variable; 0xf416 tries NVMe, then microSD, then USB.
  • You can install a clean system with Raspberry Pi Imager or clone your current microSD to the SSD.

Data from the official documentation: boot loader and M.2 HAT+.

What you need

ComponentDetail
Raspberry Pi 5The Pi 4 has no accessible PCIe
M.2 HATThe official M.2 HAT+ takes 2230 and 2242; the Compact only 2230
NVMe SSDM-key, size compatible with the HAT
Official 27 W supplyThe SSD adds draw; a marginal supply causes freezes
microSD with Raspberry Pi OSTo update the EEPROM and clone

PCIe speed

ModeTheoretical speedStatus
PCIe 2.0 x1 (default)about 500 MB/sSupported and certified
PCIe 3.0 x1about 1 GB/sPossible but not certified; may be unstable

Even on PCIe 2.0, NVMe is several times faster than a good microSD.

Step 1: update the system and EEPROM

Boot from the microSD and update:

sudo apt update && sudo apt full-upgrade -y
sudo rpi-eeprom-update

The command shows the date of the installed version. If it is older than December 6, 2023:

  1. Run sudo raspi-config.
  2. Advanced Options → Bootloader Version → Latest.
  3. Apply the update and reboot:
sudo rpi-eeprom-update -a
sudo reboot

Step 2: fit the M.2 HAT

Always with the Pi unplugged:

  1. If you use the Active Cooler, install it first.
  2. Fit the standoffs and the GPIO extension header.
  3. Insert the ribbon cable into the Pi’s PCIe connector with the metal contacts facing the USB ports and close the latch.
  4. Screw on the HAT and connect the other end with the copper contacts facing up.
  5. Insert the SSD at an angle, lower it and secure it with the screw without over-tightening.

On power-up, check it is detected:

ls -l /dev/nvme*

You should see /dev/nvme0 and /dev/nvme0n1. If nothing appears, check the ribbon cable orientation and latch.

Step 3: move the system to the SSD

  1. Open Raspberry Pi Imager on the Pi itself.
  2. Choose the model, Raspberry Pi OS and, as storage, the NVMe SSD.
  3. Set user, Wi-Fi and SSH in the customization options and write the image.

Option B: clone the microSD

If everything is already set up, you can copy the microSD as is. Raspberry Pi OS with desktop has SD Card Copier (Accessories menu):

  1. Source: the microSD (/dev/mmcblk0).
  2. Destination: the SSD (/dev/nvme0n1).
  3. Click Start and wait.

The copy adjusts partitions to the SSD size. Without a desktop there are community tools such as rpi-clone, but they are not part of the system.

Cloning a running system with services writing (databases, Docker) can leave files half written. In those cases, a clean install and data restore is better.

Step 4: change the boot order

If you remove the microSD, the Pi 5 already boots from NVMe. If you leave it in, by default it tries the microSD first. There are two ways to change that.

With raspi-config

sudo raspi-config

Advanced Options → Boot Order → NVMe/USB Boot, then Finish and reboot.

Editing the EEPROM

sudo rpi-eeprom-config --edit

Change or add the BOOT_ORDER line:

[all]
BOOT_ORDER=0xf416

Save, close and reboot. The change applies on the next boot.

How to read BOOT_ORDER

Each hexadecimal digit is a boot mode and is read right to left:

CodeMode
1microSD card
2Network
4USB (drive or stick)
6NVMe
7HTTP
eStop
fStart over
Reading BOOT_ORDER=0xf416 right to left: NVMe, microSD, USB and repeat
Read right to left: 0xf416 is NVMe, microSD, USB and repeat.

Examples:

ValueOrder
0xf41microSD → USB → repeat
0xf46NVMe → USB → repeat
0xf416NVMe → microSD → USB → repeat

To view the current configuration without editing:

rpi-eeprom-config

Enable PCIe 3.0 (optional)

To try the faster mode, add to /boot/firmware/config.txt:

dtparam=pciex1_gen=3

Reboot. If you get disk errors or freezes, remove the line: the Pi 5 is not certified for Gen 3 and not every SSD and HAT can take it.

Common problems

SymptomCause and fix
/dev/nvme0n1 does not appearRibbon cable wrong way or latch open. Check with the Pi off
Missing with a third-party HATSome do not follow the HAT+ spec. Add PCIE_PROBE=1 in the EEPROM
Still boots from microSDBOOT_ORDER unchanged. Check with rpi-eeprom-config
Boots from nothingOld EEPROM. Update it with a microSD
Freezes or I/O errorsWeak supply or unstable PCIe 3.0. Use the 27 W supply and go back to Gen 2
Incompatible SSDSome controllers cause trouble. Check the HAT maker’s compatibility lists

Frequently asked questions

Can I leave the microSD in?

Yes. With BOOT_ORDER=0xf416 it boots from NVMe and the microSD remains a plan B if the SSD fails.

Does it run hotter?

The SSD adds heat next to the processor. The Active Cooler is compatible with the standard M.2 HAT+ and is a good idea if you overclock.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor