The Orange Pi 5 has a nice M.2 NVMe slot but unfortunately most of the official images will not boot if you try to directly image a NVMe drive. Fortunately there is an easy way to get this working that people who frequent the blog will almost certainly have seen before.
We are going to bootstrap the boot process using a SD card and then clone that SD card to our SSD to be used as the root partition. This essentially will let us have our system’s root partition on the SSD (much faster).
Let’s get started!
Hardware Used
The Orange Pi 5 the latest release from Orange Pi and is the most powerful model yet. It has a 6 core CPU and options from 4GB of RAM all the way up to 32GB of RAM!
Links: Amazon.com*, AliExpress*, Amazon.ca*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*
The Kioxia (Toshiba) 128GB M.2 2230 PCIe NVMe drive is much shorter than most NVMe drives (full size is 2280). It fits great with single board computers / tablets / other smaller form factors.
Links: Amazon.com*, Amazon.ca*, Amazon.co.uk*, Amazon.co.jp*, Amazon.com.au*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*
The Geekworm copper heat sink set is designed to fit many different single board computers. It uses thermal conductive adhesive which many “cheap” heat sink kits for SBCs don’t have. Eliminates hot spots and reduces throttling. Can be further enhanced by powered cooling over the heat sinks.
Links: Amazon.com*, Amazon.ca*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*
The StarTech USB 3.1 to 2.5″ SATA adapter is one I have recommended for many years for use with all kinds of devices including the Raspberry Pi, Orange Pi, ODROID, Libre “Renegade” and Tinker Board. It’s widely compatible and works with gaming consoles as well.
Links: Amazon.com*, Amazon.ca*, Amazon.com.au*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*
The Orange Pi official mouse uses 2.4GHz wireless to give you a wireless mouse experience with the Orange Pi
Links: Amazon.com*, AliExpress*
The Orange Pi monitor is meant to be a portable monitor you can take anywhere. It has a resolution of 1080P and features a hinge in the back that folds out to support the monitor.
Links: Amazon.com*, AliExpress*
Note for USB Booting
Important: Only the top blue port of the Orange Pi 5 is fast for using USB storage. You can use a USB-connected SSD.
The bottom port, despite being blue, is USB 2.1.
Keep in mind that if you are using a USB SSD then in the instructions anywhere it says /dev/nvme0n1 you will need to use /dev/sda or whatever drive was assigned when you plug in your drive via USB.
Note for Official Debian / Ubuntu Images (Updated 1/10/2023)
Orange Pi has updated their official images to support directly booting from NVMe. This means that if you are using the official Ubuntu or Debian from orangepi.org then you can actually write the image directly to the SSD. This is the easiest way to get it going.
You first need to write the image to a SD card and then run:
sudo orangepi-config
Then choose System->Install->Boot from SPI and install the new updated boot loader to the SPI flash.
This did not work at launch but is working now. It is now possible to simply write the official images directly to NVMe and boot with it after updating the boot loader! The following instructions will still be useful for other operating systems or operating systems that do not support booting directly from NVMe.
Note for Armbian (Added 1/20/2023)
Armbian has a similar install utility as orangepi-config. For Armbian you will use:
sudo armbian-config
Then choose System->Install->Boot from eMMC and install the new updated boot loader to the SPI flash.
You should also install the system to Armbian using this method. The instructions in the rest of the article are meant for operating systems that will not boot natively from NVMe. It uses a SD card as the boot loader to essentially let you boot anything (even ones not designed to boot directly from NVMe).
Supported SSD Sizes (Updated 1/26/2023)
Important: There is also a type of M.2 drive called a M.2 SATA drive. This is an older type of drive that most of you won’t have but some of you will. This type of drive is supported by the Orange Pi 5 but you have to add a special overlay (overlays=ssd-sata). If your NVMe drive shows up as /dev/sda instead of /dev/nvme0n1 then you have a M.2 SATA SSD. If you have a M.2 SATA drive follow this excellent guide by u/jng98908 on reddit.
You can use either a 2230 or a 2242 size NVMe drive.
There are actually holes for mounting hardware at both places.
Using a 2230 size NVMe drive looks like this:
It’s totally fine to use a larger one but they will be hanging off the edge of the board. As you can see I do not have the mounts installed on my board. I just leave the 2230 drive in the port like this but it is on my to-do list to find some mounts for the M.2 drive for this board.
SD card boot loader – Preparing SD Card
First you should have a completely working installation on a SD card of the OS that you would like to use. I used the official Debian desktop image for this guide (recommended) so if your partitions are different it may be your flavor of Linux and need slightly altered instructions.
If you have an already working installation you want to move to your SSD you can use this as well most likely.
Note that some operating systems like Armbian will require you to manually go in and modify files on the “boot” partition. If you stick with the official images you should be able to follow the guide as-is but note that some operating systems may have text files (or even files that need to be recompiled with mkimage like for Armbian) for this method to work.
You should completely update first with:
sudo apt update && sudo apt full-upgrade
Preparing SSD
First we are going to completely remove all partitions from the drive so it’s completely blank. Your drive should typically be /dev/nvme0n1:
sudo gdisk /dev/nvme0n1
Now remove all partitions from the device. If you press “p” it will print out the partitions. You can then use “d” to delete them.
Here’s an example on mine:
root@orangepi5:~# sudo gdisk GPT fdisk (gdisk) version 1.0.6 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): p Disk /dev/nvme0n1: 250069680 sectors, 119.2 GiB Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): E3017ECA-4571-4F62-A39F-4BA2A4323BD8 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 250069646 Partitions will be aligned on 64-sector boundaries Total free space is 8350 sectors (4.1 MiB) Number Start (sector) End (sector) Size Code Name 1 64 8063 3.9 MiB 0700 loader1 2 16384 24575 4.0 MiB 0700 loader2 3 24576 32767 4.0 MiB 0700 trust 4 32768 1081343 512.0 MiB EF00 boot 5 1081344 250069646 118.7 GiB 8300 rootfs Command (? for help): d
Keep pressing d until all the partitions are deleted. Once they are gone use the ‘w’ command to write your changes.
Cloning Installation to SSD
We’re now ready to clone your installation to the SSD. We can now copy your drive to the SSD with the following command:
cat /dev/mmcblk1 > /dev/nvme0n1
Wait for the operation to complete (there won’t be any output but you will have a cursor again and be able to type new commands). Remember that you are copying an entire drive from one to another basically with that one command.
Mine took about 30-45 minutes (although I was using a 64GB SD card and the larger SD card you use the longer it will take to copy the whole drive).
If you are having any trouble with permissions try becoming “root” first with:
sudo su
Now try running the command again and as the superuser you should not encounter any permission errors.
Change SD card’s rootfs UUID
We need to change our SD card’s UUID so that it doesn’t try to boot from that partition. We can set it to a random one with the following command:
sudo tune2fs -U random /dev/mmcblk1p2
If you get an error with the previous command regarding csums try the following command instead:
sudo tune2fs -O metadata_csum_seed -U random /dev/mmcblk1p2
We can verify that it has changed with blkid like this:
root@orangepi5:~# sudo blkid /dev/nvme0n1p1: SEC_TYPE="msdos" LABEL_FATBOOT="opi_boot" LABEL="opi_boot" UUID="0257-2A31" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="bootfs" PARTUUID="0a65713b-d4b4-0642-a3a4-ebc357e507a1" /dev/nvme0n1p2: LABEL="opi_root" UUID="ae948e48-3646-4f5c-be01-73168e079bc8" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="7490e84a-f585-944e-9ce6-f275f067a023" /dev/mmcblk1p1: SEC_TYPE="msdos" LABEL_FATBOOT="opi_boot" LABEL="opi_boot" UUID="0257-2A31" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="bootfs" PARTUUID="0a65713b-d4b4-0642-a3a4-ebc357e507a1" /dev/mmcblk1p2: LABEL="opi_root" UUID="37a6ee0a-e61d-470a-9e53-eaf51726942c" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="4f32d51c-0523-1248-9bc3-092d1f11c594"
Notice that /dev/nvme0n1p2 and /dev/mmcblk1p2 no longer have matching UUIDs. This is exactly what we want.
Change SSD’s boot UUID
Next we are going to change the boot partition’s UUID on the SSD. This will make it so that the mounted /boot folder inside your operating system actually mounts the SD card (which is your actual boot loader in this configuration).
First make sure you have mtools with:
sudo apt install mtools -y
Now we can change the UUID with:
sudo mlabel -N aaaa1111 -i /dev/nvme0n1p1 ::
You can verify these are different using the same sudo blkid command as the previous section.
Run fsck
Before we reboot run fsck on the drive like this:
sudo fsck -yf /dev/nvme0n1p2
This will prevent you from having to run fsck on the CLI the first time you try to boot.
Reboot and Verify
Now reboot the Orange Pi 5 with:
sudo reboot
With any luck you should be booted using your SSD! We can verify this with the mount command like this:
root@orangepi5:~# mount /dev/nvme0n1p2 on / type ext4 (rw,noatime,errors=remount-ro,commit=600) /dev/mmcblk1p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=936,iocharset=utf8,shortname=mixed,errors=remount-ro) /dev/nvme0n1p2 on /var/log.hdd type ext4 (rw,noatime,errors=remount-ro,commit=600)
Here we can see that our root partition (/) is indeed on /dev/nvme0n1p2 and not /dev/mmcblk0p2. We can also see that my /boot folder is properly mounted is /dev/mmcblk0p1 (the SD card which is serving as our boot loader). Success!
Resize NVMe Partition (Added 1/24/2023)
You can use Orange Pi’s built in resize application if you are using one of the official operating systems:
sudo /usr/lib/orangepi/orangepi-resize-filesystem start
Testing Performance
For the guide I used a SSSTC 128GB 2230 M.2 NVMe drive. These are available on Amazon for around $10-12 (also see Kioxia 128GB M.2 2230 module*).
You can verify the performance of your drive on Pi Benchmarks using the following command:
sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash
Here are the results:
Category Test Result HDParm Disk Read 375.32 MB/s HDParm Cached Disk Read 381.15 MB/s DD Disk Write 234 MB/s FIO 4k random read 47080 IOPS (188321 KB/s) FIO 4k random write 35128 IOPS (140514 KB/s) IOZone 4k read 75628 KB/s IOZone 4k write 67285 KB/s IOZone 4k random read 35874 KB/s IOZone 4k random write 70620 KB/s Score: 17,718
The full Orange Pi 5 benchmark can be viewed here on Pi Benchmarks.
That is an outstanding score. We are getting NVMe performance. This score actually even beats my ODROID M1 benchmark.
The Orange Pi 5 is without a doubt a very powerful board and is performing exactly where it should be.
Other Resources
I’ve also covered how to install Steam on the Orange Pi 5 here
I’ve also reviewed the Orange Pi portable monitor here (with the Orange Pi 5 connected)
If you are looking for alternative WiFi adapters for the Orange Pi 5 see my using E-keyed WiFi adapters with the Orange Pi 5 guide here!
It would be great if you did this tutorial for an odroid c4 in armbian.
Hey Apolo,
I don’t have one of those yet but if I pick one up I’ll definitely write one!
Hi James, excellent resource for OrangePi. I wonder how to configure the Opi5 bootloader to boot from NVMe SSD drive instead of TF ? The Orange Pi Arch OS or Ubuntu 22.04 doesn’t seem to have ‘orangepi-config’ file anywhere after installation. Is there any way to configure the bootloader?
Hello James,
Thanks for this wonderfull site. It helped me a lot to get my Kingspec SSD going on my Orange pi 5 16GB. Doing the performance test: https://pibenchmarks.com/benchmark/70437/ I hoped to see a reading speed somehere around 300MB/s Checking other tests with similar setups e.g.: (512 instead of 256GB) or (8GB RAM instead of 16 GB) They show substantial higher values. What can be the reason for such a noticeable difference?
Hey kbfifi,
Great question! So the answer is usually that 512 and 1TB drives have faster memory and better storage controllers than the lower sizes. This has been true for a long time across most brands (Samsung even puts higher I/O numbers advertised on the boxes of the larger sizes).
In this case though the answer is that someone is using the 2280 version of the drive. Notice on the 512GB benchmark you posted that their model # is NXM-5122242. That’s the 2242 version of the drive. In the faster 256GB benchmark though you posted the model is just NXM-256. That means that person is using a full 2280 version of the drive (more space for components, longer).
In other words these aren’t exactly the same drives. They’re from different series. The 2242 series looks like it might perform a little bit faster. That may be because they were forced to use smaller and higher quality memory modules on the 2242 version vs. the 2280 version where they can get away with using larger and cheaper (and usually slightly slower) modules.
Hopefully that helps!
Hi James,
Thanks for your reply. You’re right about that NXM-256 is a different drive. Didn’t notice that yet. I found many other tests with opi5 and NXM-2562242 that confirm my performance. So nothing strange there. On the other hand there are tests still substantially faster.
Like this one : https://pibenchmarks.com/benchmark/68998/
or this one https://pibenchmarks.com/benchmark/66197/
or this one https://pibenchmarks.com/benchmark/68889/
I guess that there might be different ones in the model NXM-2562242 as well? Of course I hope to find something that makes my device perform as fast as well 😉 I’m just curious about the read speed difference of 192MB/s vs 365MB/s for what looks to be the same drive.
Hey kbfifi,
Great observations. So have you noticed if you take the benchmark over and over your score tends to go down? You’ll get the highest HD parm score if you reboot the device and don’t do anything other than run the benchmark. If you run it again before rebooting your drive’s cache will be used less. The reason for this is that the first run it will do a lot of heavy caching and then figure out that the HDParm benchmark wasn’t a very good use of the cache and will cache the next run.
The more important metrics are all of the 4k random read/write benchmarks. Those generally don’t change between runs because it’s not based on caching. If you take the benchmark immediately after booting the system you’ll get slightly higher numbers on the DD Write. It won’t actually mean anything for real world performance though. It’s just oddities based on how the caching works if that makes sense.
Hopefully that helps!
Sorry. I see that my first reply suddenly WAS send. So I (even cleared browser cache!) reproduced the reply again. Just remove either one.
I am facing an issue with my Orange Pi 5B, as it does not have an available NVMe slot. Therefore, I would like to transfer data from the SD card to the eMMC, but my attempts thus far have been unsuccessful.
Hey Kumar,
Yes, this is always tricky on RockChip boards. Cloning almost certainly won’t work for it. The closest thing I’ve found is here. If you are using Armbian you probably need to make that change to the fdt files.
For the official operating systems I’m not sure if orangepi-config can do it yet after choosing install but that’s the next thing I’d try. If that won’t work you probably need to use RKDevTool. This will require translating the Orange Pi 5 documentation from Chinese but it does cover how to do it. It’s not easy but it should be the same as doing it on the Orange Pi 4 and other similar boards.
Hopefully that helps!
Hi! Thanks for this awesome guide. Which program do I need to transfer the OS to the SSD and do I still need an SD Card?
Also which image should I download for your Minecraft server script? Desktop plasma, Desktop xfce or server? Or should I just download the arm Debian bullseye release from Debian directly?
Also, I found that in your blog you have these called “dockers” which I’m not familiar with. Should I set up my new server with them or just use your regular script for raspberry pi?
Hey TopasMusic,
It’s all your personal preference honestly. I can’t answer this question for you. No matter which you choose they are all covered in the guides. None of this will have any impact on the performance of the server.
You should try whatever you are comfortable with or try all of them and decide which one is best for you. The guides cover installation of all of those operating systems as well as the Docker or installation script.
Hopefully that helps!
hello,
Wondering if grub 2 is an option ( or something similar) on the pi 5? Can’t find any direct info, and figure you likely know the answer.
I am running the spi flash/nvme setup with Ubuntu. I have batocera on my SD.
Can grub (or anything) be loaded as part of the bootloader on flash so the option to choose between the SD or Nvme can be made? I have no idea what I’m doing but figure there is probably a way via logic to step from one option or another.
Would be kind of cool if the GPIO could be configured with switches or something that let you manually set your boot path.
Thanks
Hey Jkels,
Welcome, and what an incredible question! So theoretically yes this should absolutely be possible. In fact I did find someone claiming they were able to do this with the Armbian bootloader here.
They said there were some limitations at this time though. No TF/SD boot as well as no booting over the USB-C port (which I believe is still the case actually for the USB-C port). They even gave some instructions to get as far as they did. The limitations they ran into sounded pretty severe though such as no HDMI and only uart.
That was the only post I could find of someone doing this but it honestly sounds like they got impressively far. It seems like a lot more work has been done for this on the Radxa Rock 5B. That 5 page post may be worth a read because the Rock 5B is honestly very similar to the Orange Pi 5. A lot of the hints people are giving in there will probably apply to this board.
It sounds like the Armbian boot loader may already be using grub internally. The Orange Pi 5 and Rock 5B both need the Armbian boot loader written to SPI flash. I’m sure it would work on the Orange Pi 5 too but I’m not sure if anyone else other than the first link I posted has ever done it.
It’s possible that there’s mega forum threads like that in other languages related to the Orange Pi 5 and that more people have figured it out. I’d guess it’s only a matter of time before more things pop up like this. That person at least documented their attempt with it and it sounds like a lot of it was working without modification for the Orange Pi 5. It doesn’t sound like it has been perfected yet though into as easy as a package as it is on the Radxa Rock 5B yet.
Hopefully that helps!
Thanks for the info. I’ll take a read. I may need to get another board as a test board since I don’t know enough about what I’m doing, that way I’ll be ok if I blow something up.
Hey Jkels,
No problem at all, let me know what you find, I’m interested to see how it goes!
Please Help, I am performing these steps on an OP4 lts. everything was going okay until the “changing boot SSD UUID” step. when i use sudo mlabel -N aaaa1111 -i /dev/sda1 :: , I get error init :: non DOS media cannot intitalize ‘::’ mlabel: cannot initialize drive. I’m not sure where to go from here
Hey Andrew,
Clearly it’s not the same operating system as everyone else’s. What is it?
Do you even have a boot partition? That’s a serious question. What does your
lsblk
look like?If you aren’t using the operating system I used for it then it’s not going to be the same. We can only guess what you are using. There’s dozens of them available. If it’s Armbian I’ve talked about that many times in the comments previously so don’t reply if it’s Armbian and go back and read the previous comments about Armbian. Others such as RebornOS have come up as well so there’s virtually no chance that we haven’t already covered this with someone in the comments by this point whatever your OS ends up being.
This was the last one I wrote that wasn’t operating system specific. I’ve changed how I write these and only write them for the operating system I’m using for this exact reason. Who knows what yours is. You didn’t say and there’s so many it could be. They aren’t all the same. I don’t think you’ve read any of the many comments like this before either as I always ask people for their lsblk and which OS they’re using and you specified neither here.
We just don’t live in a world where there is a standard for this. It’s whatever partitioning your OS decided they wanted to use. Yours is different than everyone else’s so I would need to know what it is and what your lsblk looks like to help. You’re doing it on ultra-hard mode using a non-standard OS which will require you to know or be able to look up whether you even have a boot partition and what format it is in.
Please read the previous comments first though as there’s a good chance it has already been discussed here. You aren’t the first person to completely ignore which OS I was using (and multiple warnings for them in the article) that followed this guide verbatim and posted the first snag you hit. I have notes specifically both for Armbian and the official operating systems (which has helped, it has been a while since I got one of these). If it hasn’t come up ever before then let’s take a look at the lsblk and the OS and I’m sure we can figure it out here.
In fact it’s unlikely you need to do the manual process at all. Both Armbian and the official operating systems just install right to the NVMe drive if you’ve installed the boot loader (covered in the article). If you are using Armbian you just use sudo armbian-config and choose “Install”. For the official operating systems you use orangepi-config and then choose “Install”. This whole process was before that was even working. Most people should only make it about half way through the article if they are running the official OS or Armbian. You don’t have to do the manual partitions anymore unless you’re running something weird.
Another easy method for those operating systems is that you can just clone your SD card to the SSD like I did in the article (sudo su and then cat /dev/mmcblk1 > /dev/nvme0n1) and then run armbian-config or orangepi-config and choose to install the bootloader to SPI/Flash. That’s what I did when I installed Armbian yesterday. It avoids you having to have your partitions setup exactly right before running the “Install” method from the configuration tool. You don’t even need to do the partition labels anymore unless you’re running a weird OS (totally possible). If I were to bet though this is just Armbian and none of what you are trying to do is necessary with Armbian (see the Armbian sections).
Hopefully that helps!