RSP5 NVMe Boot Setup Guide
This guide explains how to configure a Raspberry Pi 5 to boot from an NVMe drive without an SD card, enable PCIe Gen 3 for improved performance, test the setup, and disable Wi-Fi and Bluetooth. It assumes you’re starting with Raspberry Pi OS Lite on an SD card, have an NVMe HAT installed, and the NVMe drive is detected (check with lsblk
to see /dev/nvme0n1
).
Prerequisites
- Raspberry Pi 5 with NVMe HAT and NVMe drive installed.
- Raspberry Pi OS Lite booted from an SD card.
- Command-line access (via SSH or console).
- Internet connection for updates.
- Git installed.
Equipment
Step 1: Update System and Bootloader
Ensure the system and bootloader are up to date to support NVMe booting (requires firmware from December 2023 or later).
-
Update packages:
sudo apt update && sudo apt full-upgrade
-
Check bootloader version:
sudo rpi-eeprom-update
-
If the bootloader date is before December 6, 2023:
- Open
raspi-config
:sudo raspi-config
- Navigate to Advanced Options > Bootloader Version > Select Latest.
- Exit with Finish (or Esc).
- Apply the update:
sudo rpi-eeprom-update -a sudo reboot
- Open
Step 2: Clone SD Card OS to NVMe Drive
Use rpi-clone
to copy the SD card’s boot and root partitions to the NVMe drive.
-
Install
rpi-clone
(using a fork with NVMe support):git clone https://github.com/geerlingguy/rpi-clone.git cd rpi-clone sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
-
Confirm NVMe device (e.g.,
/dev/nvme0n1
withlsblk
). If the NVMe has unwanted data, wipe it (optional):sudo umount /dev/nvme0n1p* # Unmount any partitions sudo wipefs --all --force /dev/nvme0n1p* sudo wipefs --all --force /dev/nvme0n1 sudo dd if=/dev/zero of=/dev/nvme0n1 bs=1024 count=1
-
Clone the SD card to NVMe:
sudo rpi-clone nvme0n1
- Follow prompts to confirm.
- This copies partitions, updates UUIDs in
/etc/fstab
and/boot/firmware/cmdline.txt
, and resizes the filesystem.
-
Reboot to verify (with SD card still inserted):
sudo reboot
Step 3: Set Boot Order to Prioritize NVMe
Configure the Pi to boot from NVMe, allowing SD card removal.
-
Open
raspi-config
:sudo raspi-config
-
Navigate to Advanced Options > Boot Order > Select NVMe/USB boot (sets
BOOT_ORDER=0xf64
for NVMe first, USB second, with retry). -
Exit with Finish (or Esc).
-
Reboot:
sudo reboot
-
Verify boot order (optional):
vcgencmd bootloader_config | grep BOOT_ORDER
- Should show
BOOT_ORDER=0xf64
.
- Should show
Step 4: Test Booting Without SD Card
-
Shut down:
sudo shutdown now
-
Remove power, remove the SD card, and reconnect power.
-
The Pi should boot from the NVMe drive. If it fails, reinsert the SD card, boot, and recheck boot order or NVMe detection (
lsblk
).
Step 5: Enable PCIe Gen 3
Enable PCIe Gen 3 for faster NVMe performance (if supported by your drive and HAT).
-
Edit the boot configuration:
sudo vim.tiny /boot/firmware/config.txt
- Press
i
to enter insert mode, add the line below under[all]
:dtparam=pciex1_gen=3
- Save and exit: Press
Esc
, then type:wq
and pressEnter
.
- Press
-
Reboot:
sudo reboot
Step 6: Test PCIe Gen 3 and NVMe Performance
Verify PCIe Gen 3 is active and benchmark NVMe performance.
Verify PCIe Gen 3
-
Install
pciutils
:sudo apt install pciutils
-
Check PCIe link speed:
sudo lspci -vv | grep -E 'LnkSta:|LnkCap:'
- Look for
LnkSta: Speed 8GT/s
(Gen 3). If it shows5GT/s
, Gen 3 failed (see troubleshooting). - For NVMe-specific output:
sudo lspci -vv | grep -i nvme -A 10
- Look for
Benchmark NVMe Performance
-
Install
fio
:sudo apt install fio
-
Run sequential read/write tests:
fio --name=write --filename=/home/pi/testfile --size=1G --rw=write --bs=1M --numjobs=1 --iodepth=1 --runtime=60 --time_based --group_reporting --ioengine=libaio fio --name=read --filename=/home/pi/testfile --size=1G --rw=read --bs=1M --numjobs=1 --iodepth=1 --runtime=60 --time_based --group_reporting --ioengine=libaio
- Expect ~700-900 MB/s for Gen 3 vs. ~350-500 MB/s for Gen 2.
-
Clean up:
rm /home/pi/testfile
-
Alternative quick test with
dd
(Optional):sync; dd if=/dev/zero of=/home/pi/testfile bs=1M count=1024; sync sync; dd if=/home/pi/testfile of=/dev/null bs=1M; sync rm /home/pi/testfile
Step 7: Disable Wi-Fi and Bluetooth
I will be powering these devices with PoE so WiFi and Bluetooth will be unnecessary for my use case.
-
Edit the boot configuration:
sudo vim.tiny /boot/firmware/config.txt
- Press
i
to enter insert mode, add the lines below under[all]
:dtoverlay=disable-wifi dtoverlay=disable-bt
- Save and exit: Press
Esc
, then type:wq
and pressEnter
.
- Press
-
Reboot:
sudo reboot
-
Verify Wi-Fi and Bluetooth are disabled:
rfkill list
- No Wi-Fi (
wlan
) or Bluetooth devices should appear.
- No Wi-Fi (
Step 8: Clean Up rpi-clone
Remove rpi-clone
and its files to free up space.
-
Remove executables:
sudo rm /usr/local/sbin/rpi-clone sudo rm /usr/local/sbin/rpi-clone-setup
-
Remove the cloned repository:
cd ~ rm -rf rpi-clone
-
Clean up package cache (optional):
sudo apt autoremove sudo apt autoclean
Troubleshooting
- NVMe Not Detected:
- Check HAT connections and ensure PCIe is enabled (
dtparam=pciex1
in/boot/firmware/config.txt
). - Update firmware:
sudo rpi-eeprom-update -a
.
- Check HAT connections and ensure PCIe is enabled (
- PCIe Gen 3 Not Active:
- Revert to Gen 2 by removing
dtparam=pciex1_gen=3
. - Check drive/HAT compatibility.
- Revert to Gen 2 by removing
- Boot Failure:
- Reinsert SD card, boot, and verify
/etc/fstab
and/boot/firmware/cmdline.txt
UUIDs (blkid
to check).
- Reinsert SD card, boot, and verify
- Performance Issues:
- Confirm drive specs and check for background processes (
top
orhtop
).
- Confirm drive specs and check for background processes (
Notes
- Time: Setup takes ~30-60 minutes, including cloning and testing.
- Risks: PCIe Gen 3 may be unstable with some drives/HATs; revert if needed.