How to turbo-charge your Raspberry Pi 5 with an NVMe boot drive (Updated)

Setting up an NVMe SSD on the Raspberry Pi 5
(Image credit: Tom's Hardware)

Update: 2/26/2024 09:39 PT

We have updated this guide due to a recent change in how the Raspberry Pi 5 and Raspberry Pi OS work with NVMe drives. The previous means of editing config files and boot orders is now no longer the correct method and this guide now reflects the current correct method.

Updated article

The Raspberry Pi 5 introduced PCIe connectivity to the model B form factor and with it we are slowly seeing a number of boards for NVMe SSDs. The first was Pineberry Pi’s Hat Drives, followed by Pimoroni’s NVMe Base. The official Raspberry Pi M.2 board is just on the horizon, as the PIP, a Raspberry Pi word for PCIe Peripheral, specification has just been released.

For the early adopters, who have just received, or built their first NVMe board, how do we get it to work with the Raspberry Pi 5? We’ve been down that road, made the mistakes and have the knowledge to pass on. So let's turbo-charge our Raspberry Pi 5 with a super-speedy NVMe SSD.

For this project you will need 

  • Raspberry Pi 5 running Raspberry Pi OS from micro SD
  • NVMe SSD
  • NVMe HAT
  • USB-to-NVMe adapter (see best SSD enclosures)

Preparing your NVMe drive 

Depending on your NVMe HAT board you can use any of the best NVMe SSDs, but we would choose a 2280 drive as they are cheap and plentiful, just make sure that your HAT board supports them.

1. Boot your Raspberry Pi 5 from a micro SD card.

2. Connect your NVMe SSD to a USB 3 port on the Raspberry Pi 5 via a USB 3 to NVMe adapter. 

3. Complete all of the steps to download and install Raspberry Pi OS in our guide. Install the OS to the NVMe drive and not the micro SD card!

4. Once complete, eject and remove the NVMe drive from the USB adapter. 

Setting up the Raspberry Pi 5 to use an NVMe drive 

With our NVMe drive created, we now need to tell the Raspberry Pi 5 that we want to boot from NVMe and how fast we expect the connection to run at.

1.  Open a terminal and use nano to edit the config.txt file. This file is used to alter the configuration of the Raspberry Pi. With it we can overclock the CPU and GPU and in this case set the PCIe connection speed. Note: from February 2024 the config.txt file has now moved to /boot/firmware/config.txt. Do not edit /boot/config.txt as it no longer works. 

sudo nano /boot/firmware/config.txt

2. Using the cursor keys, move down to the bottom of the file and add a section for NVMe configuration. We use a comment to denote what this block will do.

#NVMe Configuration

3. Set the PCIe connection speed. There is official support for PCIe Gen 2 speeds, but we’ve tested Gen 3 and it works perfectly. Your mileage may vary, so if it doesn’t work, change this to 2.

dtparam=pciex1_gen=3

(Image credit: Tom's Hardware)

4. Press CTRL + X. Then press Y and Enter to save and exit the editor.

5. Reboot the Raspberry Pi for the change to take effect. 

6.  Open a terminal and start raspi-config command using sudo. Raspi-config is a terminal (ncurses) based config menu to configure the Raspberry Pi. 

sudo raspi-config

7.  Using the cursor keys, navigate to Advanced Options and press Enter. 

(Image credit: Future)

8. Add a line to enable custom PCIe boards to be used with the Raspberry Pi 5.

(Image credit: Future)

9.  Select Latest and press Enter. When prompted, select Yes and press Enter. 

(Image credit: Future)

10.  Select Finish to exit raspi-config. In the past we would need to edit the boot order to ensure that NVMe was selected. Now, the default option is SD card / NVMe. If there is no SD card present, the Pi 5 will try to boot from NVMe. 

11.  Reboot the Raspberry Pi for the change to take effect. Check that your Raspberry Pi 5 reboots correctly before moving on. 

12.  Optional step: Check the bootloader version. Run this command and check that the current and latest bootloader versions are the same. 

sudo rpi-eeprom-update

raspi-config

(Image credit: Future)

13. Power off the Raspberry Pi 5 and remove the USB C power connection from the Pi. We need to make sure that the power is off. 

14. Gently lift the PCIe connector plastic housing so that it unlocks and insert the flat flex cable so that the gold “teeth” are facing the USB / Ethernet ports.  

(Image credit: Tom's Hardware)

15. Gently apply pressure to the plastic connector housing so that the cable is locked in place. 

16. Perform the same procedure on the NVMe board. 

17. Insert your NVMe drive with Raspberry Pi OS into the NVMe board and secure it in place. Follow the instructions for your chosen board.

18. Check all of the connections are correct and then power up the Raspberry Pi 5. 

(Image credit: Tom's Hardware)

Your Raspberry Pi 5 is now booting from NVMe and you can enjoy the speed boost that it provides. 

Les Pounder

Les Pounder is an associate editor at Tom's Hardware. He is a creative technologist and for seven years has created projects to educate and inspire minds both young and old. He has worked with the Raspberry Pi Foundation to write and deliver their teacher training program "Picademy".

  • synthetic hooman
    Very helpful, but please include the make and model of the NVMe HAT you are using, and a link so we know where to purchase.
    Thanks
    Reply
  • if not myString:
    synthetic hooman said:
    Very helpful, but please include the make and model of the NVMe HAT you are using, and a link so we know where to purchase.
    Thanks
    The name of the board is printed on it.

    https://pineberrypi.com/
    Reply