Changes

Jump to navigation Jump to search

NVMe SSD boot with the Raspberry Pi 5

4,157 bytes added, 13:16, 8 December 2023
Created page with "{{GD Template Impl}} Most of the content of this tutorial comes from Jeff's blog: [https://www.jeffgeerling.com/blog/2023/nvme-ssd-boot-raspberry-pi-5 NVMe SSD boot with the..."
{{GD Template Impl}}

Most of the content of this tutorial comes from Jeff's blog: [https://www.jeffgeerling.com/blog/2023/nvme-ssd-boot-raspberry-pi-5 NVMe SSD boot with the Raspberry Pi 5], Thanks fo Jeff

==Enabling PCIe==
By default the PCIe connector is not enabled. To enable it you should add the following option into <span class="tb_blue">/boot/firmware/config.txt</span> and <span class="tb_blue">reboot</span>:
sudo nano /boot/config.txt
Then add the following comment;
# Enable the PCIe External connector.
dtparam=pciex1
# This line is an alias for above (you can use either/or to enable the port).
dtparam=nvme

Press Ctrl-O, then enter, to write the change to the file.

Press Ctrl-X to exit nano (the editor).


And the connection is certified for Gen 2.0 speed (5 GT/sec), but you can force it to Gen 3.0 (10 GT/sec) if you add the following line after:
dtparam=pciex1_gen=3

You also can refer to official documentatio:[https://www.raspberrypi.com/documentation/computers/raspberry-pi-5.html#enabling-pcie Enabling PCIe]

Then DON'T forgot to reboot
sudo reboot

==Set NVMe early in the boot order==
The PCIe connection should work after a reboot, but your Pi won't try booting off an NVMe SSD yet. For that, you need to change the '''BOOT_ORDER''' in the Raspberry Pi's bootloader configuration:
<pre>
# Edit the EEPROM on the Raspberry Pi 5.
sudo rpi-eeprom-config --edit

# Change the BOOT_ORDER line to the following:
BOOT_ORDER=0xf416
</pre>

- Press Ctrl-O, then enter, to write the change to the file.

- Press Ctrl-X to exit nano (the editor).

Read [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#BOOT_ORDER Raspberry Pi's documentation on BOOT_ORDER] for all the details. For now, the pertinent bit is the '''6''' at the end: that is what tells the Pi to attempt NVMe boot first!

Reboot your Raspberry Pi 5 to make the change take effect.


NVMe boot won't work unless you have the external PCI Express port enabled, and there's a working NVMe drive with a valid boot partition! If you don't have that (e.g. you used Raspberry Pi Imager with an external USB NVMe adapter to flash Pi OS to an NVMe drive from another computer), then follow the steps in the next section to clone your existing Pi OS install to an NVMe SSD.

'''Flash the SSD with Raspberry Pi Imager'''

To get the NVMe SSD to boot your Pi, it needs to have an OS. One option would be to clone an existing installation to it using ''rpi-clone'' or some other tool (see below), but my preferred option is to flash a fresh Pi OS install using [https://www.raspberrypi.com/software/ Raspberry Pi Imager].
# Install Pi Imager and open it
# Plug your NVMe SSD into your computer using a USB to NVMe adapter
# Choose an OS to install
# Choose the drive (connected through your adapter) to flash
# Click write (and set any options you'd like)
Once flashing is complete, pull the NVMe drive, attach it to your Pi 5, and it should boot off it (with or without a microSD card inserted)—assuming you have the bootloader up to date and set the '''BOOT_ORDER''' appropriately!

'''Clone your microSD boot volume to an NVMe SSD'''

Assuming you already have Raspberry Pi OS on a microSD card that is booting your Raspberry Pi 5 internally, and the NVMe SSD is connected and visible (check if you see a device /dev/nvme0n1 after running lsblk), you can use rpi-clone to clone the internal microSD boot volumes to your NVMe SSD:
<pre>
# Install rpi-clone.
git clone -b 123-nvme https://github.com/geerlingguy/rpi-clone.git
cd rpi-clone
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin

# Clone to the NVMe drive (usually nvme0n1, but check with `lsblk`).
sudo rpi-clone nvme0n1
</pre>

'''Note''': You may want to wipe all disk partitions before cloning:
<pre>
sudo umount /dev/nvme0n1p?
sudo wipefs --all --force /dev/nvme0n1p?
sudo wipefs --all --force /dev/nvme0n1
sudo dd if=/dev/zero of=/dev/nvme0n1 bs=1024 count=1
</pre>



Return to [[X1001]]

<!--Add review function! -->
<comments />

<!--Please choose the -->
<!--Remove other categories, just keep the appropriate categories -->

[[Category:Product Manual]]
[[Category:Raspberry pi]]

Navigation menu