How I Got More Speed Out Of My Raspberry Pi 5 By Installing An SSD

Move from SD to SSD (the extra S stands for speed). The Raspberry Pi 5 is the fastest and most powerful device put out by the Raspberry Pi Foundation. Its … Read more

Taylor Bell

Taylor Bell

Published on May 08, 2024

How I Got More Speed Out Of My Raspberry Pi 5 By Installing An SSD

Move from SD to SSD (the extra S stands for speed).

Build parts for the Waveshare PCIe to M.2 HAT for the Raspberry Pi 5

The Raspberry Pi 5 is the fastest and most powerful device put out by the Raspberry Pi Foundation. Its release was like a breath of fresh air after the supply chain disruptions following COVID-19 made obtaining a Raspberry Pi 4 at a reasonable price all but impossible. Even though the new Pi is fast, it could be faster with just a few modifications.

To address the RPi5’s speed issues, you’ll have to open up a few bottlenecks before its potential can be fully unlocked. Opening up those bottlenecks is a very simple process that requires a bit of new hardware and tweaking a couple lines of configuration.

Your SD card is slowing you down

The default storage for the RPi5 is a microSD card. For a computer the size of the RPi5, this is a perfect solution because microSD cards are small, and they can hold up to 1.5 TB of data. The RPi5 can support SD card speeds of up to UHS-1, which means a minimum write speed of 10 MB/s and a theoretical maximum read speed of 104 MB/s. And, when I run the storage benchmark test from PiBenchmarks.com, I get read speeds of 86.32 MB/s and write speeds of 21.2 MB/s (your mileage may vary based on which SD card you’re using).

PiBenchmarks.com benchmark out put for an SD card on a Raspberry Pi 5

That’s not bad, but it could be better. The Raspberry Pi 5 has a PCIe interface that allows you to add an M.2 expansion slot to your Pi via a HAT. By default, the RPi5 uses PCIe 2.0 over one lane which allows for read speeds of around 500 MB/s. Let’s get that speed.

  • A render of the Raspberry Pi 5

    Raspberry Pi 5

  • KingSpec NX Series 2242 SSD on transparent background

    KingSpec NX Series Gen 3 SSD

    $30 $36 Save $6

  • Waveshare PCIe to M.2 HAT+ on transparent background

    Waveshare PCIe to M.2 HAT+

Boot your Raspberry Pi 5 with an SSD

It will be much faster

The first way to take advantage of those speeds is by booting your RPi5 from your SSD card. You will have to image the OS onto the drive in some way. The easiest way is with an NVMe-to-USB adapter and flashing the OS with the Raspberry Pi Imager. Once that’s done, you’ll have to change the EEPROM on your Pi.

  1. Boot your Pi up as you normally would with an SD card and jump into the terminal. Type in “sudo rpi-eeprom-config –edit” and press enter. EEPROM stands for electrically erasable programmable read-only memory, and it’s used here to store information about your boot configuration.
    LInux command to edit the EEPROM

  2. Find the line that says “BOOT_ORDER=0xf41” and change it to “BOOT_ORDER=0xf416” to enable booting from your SSD. Each character to the right of the “x” signifies a device from which to attempt booting. On start up, your Pi will check the device associated with each character from right to left. A “6” indicates an NVMe SSD, a “1” indicates the SD card, and “f” indicates the device should restart.
    Raspberry Pi EEPROM boot.cnfg file

  3. Once you’ve made the changes, press Ctrl+O to save, then Ctrl+X to exit.

Enabling PCI Express on the Raspberry Pi 5

Before we can test our new SSD, we have to make one more change to a configuration file.

  1. The file we’re looking for is config.txt in the boot/firmware directory. To edit it, type “sudo nano /boot/firmware/config.txt” into the terminal. Feel free to use the text editor of your choice if you don’t like nano.
    Linux command to edit config.txt file

  2. Add the line “dtparam=pciex1” to the bottom of the config file. Just for some context, “dtparam” stands for devicetree parameter. The devicetree is how the Raspberry Pi’s hardware is represented internally. Next, “pciex1” indicates that we are enabling the one lane of PCI Express traffic the Pi is capable of.
    Raspberry Pi 5 firmware config file

  3. Once you’ve made the changes, press Ctrl+O to save, then Ctrl+X to exit.

Installing the PCIe to M.2 HAT

Now that the configuration on your Pi has been updated, it’s time to install your HAT. I’m installing the Waveshare PCIe to M.2 HAT+, but there are a number of options out there to choose from.

  1. Start by installing the four standoffs on the Raspberry Pi. I like to hold the screw in place from below with my fingertip while screwing down the standoff, then tighten the screw with a screwdriver.
    Raspberry Pi 5 with standoffs installed

  2. Next, place the FPC cable into the Pi’s PCIe port. To start, gently lift the tab on top of the slot, then place the FPC cable into the slot vertically with the exposed circuits facing towards the motherboard. Make sure that the white arrow is on the same side as the power button.
  3. Now that our Pi is ready, start with the HAT by inserting the NVMe SSD card into the M.2 slot. If you’re using a 2242 SSD card, the mounting screw will already be on the board. If you’re using a 2230 drive, you’ll have to use the included hardware to mount it.
  4. Take the GPIO extenders and place them through the holes in the HAT. Take your time and apply firm, even pressure to ensure that none of the pins get bent.
  5. Place your assembled HAT, and press it down onto the Pi’s GPIO pins. Again, apply firm, even pressure as you press down. Take care to move your fan cable if you’re using an active heat sink.
  6. Screw down the HAT to the spacers attached to the Pi earlier.
  7. Finally, connect the FPC cable to the HAT’s PCIe slot. Again, gently lift the tab on the slot. Whereas the tab on the Pi lifted straight up, this one will hinge. Insert the FPC cable into the slot horizontally. If you inserted it correctly into the Pi, the arrow should be on the opposite side to the GPIO pins.

Now that you have your Raspberry Pi 5 put back together, you can run the storage benchmarks from PiBenchmarks again. Your results may vary, but on my machine I got a write speed of 290 MB/s and a read speed of 440 MB/s. What’s more, my boot speed jumped from 20 seconds down to 12 seconds! But we can do more.

Getting every last drop of speed from the Raspberry Pi 5

There’s still one more change you can make to your Pi to get a little bit more speed out of it. Go back to the firmware configuration file from earlier by typing “sudo nano /boot/firmware/config.txt” into your terminal. You can upgrade your PCIe connection from the default up to generation 3, which will enable up to 1 GB/s of read speed. To do that, add the line “dtparam=pciex1_gen=3” to the bottom of the file. This popped my write speed up to 435 MB/s and my read speed up to 837 MB/s, but added a second to my boot time (though this may be an anomaly since I haven’t checked boot times repeatedly).

SSD benchmark over PCIe3

No matter what you do with your Raspberry Pi, this added boost of speed will be sure to help you. If you’re using it as a budget PC, being able to open files ten times faster will make a noticeable difference. If you’re recording video with your Pi, you’ll definitely appreciate the new write speeds. Now that you’ve got your Pi up to speed, take a look at these five projects to put it to the test.

Partager cet article

Inscrivez-vous à notre newsletter