Skip to main content

Raspberry Pi 5 NVMe boot

Introduction

This guide will show you how to boot your Raspberry Pi 5 from an NVMe drive. This guide is based on the official Raspberry Pi documentation and the guide from the following YouTube videos:

Prerequisites

NVMe boot setup steps

  1. Make sure you boot from SD card

  2. Update & Upgrade Raspberry Pi OS

sudo apt update
sudo apt upgrade
  1. Make sure the NVMe drive is connected to the Raspberry Pi

  2. Check the NVMe drive status. If you use an already partitioned NVMe drive (especially with exFAT for FAT32 format ), you will come across the error Failed to write to sector 0: Invalid argument while trying to use rpi-imager to write the Raspberry Pi OS to the NVMe drive.

    sudo fdisk -l
    # you may see something like this
    Device Start End Sectors size Id Type
    /dev/nvme0n1p1 2048 1050623 1048576 512M c W95 FAT32 (LBA)
    /dev/nvme0n1p2 1050624 62521343 61470720 29.3G 7 HPFS/NTFS/exFAT
    /dev/nvme0n1p3 62521344 62531583 10240 5M 83 Linux
    lsblk
    # you may see something like this

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    mmcblk0 179:0 0 29.7G 0 disk
    ├─mmcblk0p1 179:1 0 43.9M 0 part /boot/firmware
    └─mmcblk0p2 179:2 0 29.7G 0 part /
    nvme0n1 259:0 0 238.5G 0 disk
    ├─nvme0n1p1 259:1 0 512M 0 part
    ├─nvme0n1p2 259:2 0 29.3G 0 part
    └─nvme0n1p3 259:3 0 5M 0 part

    If it is the case, you will need to erase the NVMe drive and create a new partition table using fdisk. Please refer to Linux Crash Course - Formatting & Mounting Storage Volumes by Learn Linux TV.

  3. Use rpi-imager or SD-card copier to write the Raspberry Pi OS to the NVMe drive.

    • rpi-imager: top-left corner -> Accessories -> Raspberry Pi Imager
    • SD-card copier: top-left corner -> Accessories -> SD Card Copier
  4. Update the boot order to boot from the NVMe drive.

    • open terminal and run sudo raspi-config
    • Advanced Options -> Boot Order
    • You will see NVMe boot option. if it is not on the top, move it to the top. Or you can also remove the SD card and reboot the Raspberry Pi.
  5. (Optional) Upgrade the NVMe Gen2 to Gen3 speed

    • Use pibenchmarks command to check the speed of the NVMe drive. The speed should be around 350~450 MB/s.
    • Use sudo lspci -vvvv to check the PCIe gen, you should see something like Speed 5GT/s, Width x1 (downgraded)
    • To upgrade the speed, you need to add dtparam=pcie_gen=3 to the bottom of /boot/firmware/config.txt and reboot the Raspberry Pi.
    • Rerun the pibenchmarks command to check the speed. The speed should be around 700~800 MB/s. and Speed 8GT/s, Width x1 should be shown while running sudo lspci -vvvv.