Orange Pi Zero 2 USB SSD Boot Guide

Orange Pi Zero 2 SSD Boot Guide
Orange Pi Zero 2 SSD Boot Guide

During my recent coverage of SBCs I’ve been benchmarking them using SSDs. The process for booting from a SSD varies across different boards. I’ve found the documentation for some of these to be lacking / nonexistent and the Orange Pi Zero 2 is one of these.

Today I wanted to benchmark the Orange Pi Zero 2 with the SSD and given the lack of documentation I’m going to document my process for setting it up. The Orange Pi Zero 2 will require a sacrificial SD card to bootstrap the process and has USB 2.0 ports. With those limitations in mind let’s set it up and see how it performs!

Hardware Used

Orange Pi Zero 2
Orange Pi Zero 2

The Orange Pi Zero 2 is a low-cost board from the Orange Pi line of SBCs. It has both a 512 MB or 1 GB RAM option available. Built-in WiFi with included external antenna. Also includes case and a short USB-c power cable. Seems to be pretty widely available in most countries.

Links: Amazon.com*, AliExpress.com*, Amazon.ca*, Amazon.co.jp*, Amazon.co.uk*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*

StarTech 2.5" SATA to USB 3.0/3.1 Adapter
StarTech 2.5″ SATA to USB 3.0/3.1 Adapter

The StarTech USB to 2.5″ SATA adapter is one I have recommended for many years for use with all kinds of devices including the Raspberry Pi and Orange Pi. 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*

Sabrent Powered USB Hub
Sabrent Powered USB 3.0 Hub

The Sabrent powered USB hub delivers a whopping 2.5A of dedicated power for your USB attached devices. It will easily power the most thirsty of setups such as NVMe enclosures.

Links: Amazon.com*, Amazon.ca*, Amazon.com.au*, Amazon.co.uk*, Amazon.es*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*

Note: Make sure Amazon doesn’t try to take you to the non-powered version and that it’s the one with the AC adapter that plugs in to provide extra power

Choosing a Drive

Some possible drive types include 2.5″ SATA, M.2 SATA, mSATA and M.2 NVMe.

I do not recommend using a NVMe drive with the Orange Pi Zero 2 because it has USB 2.0 ports. That is a total and complete waste as we are definitely going to max out the USB 2.0 bus with even a garbage-tier unbranded 2.5″ SSD.

I typically do not recommend USB flash drives either. No matter how fast you think it is unless it is a REAL solid state drive (SSD) it’s slower than your SD card.

The best choices are definitely something like an older cheap 2.5″ SATA or M.2 SATA SSD. I will be using a 2.5″ SATA drive (Crucial MX200 250GB*) to write this guide.

First Step – Have Working Installation

The first step in this method is to already have a working installation of the OS you want to use for SSD booting installed on your SD card.

Many of you will have this already unless you’re installing something totally new. The next thing you should do is make sure it is fully updated with:

sudo apt update && sudo apt full-upgrade -y

Having a fully updated installation will make everything much simpler as we are going to clone a fully working and up to date installation to our SSD instead of try to do a fresh image on a board that isn’t really intended for SSD booting.

Clone Installation

With the Orange Pi Zero 2 booted up using your working installation it’s time to plug your SSD into the Orange Pi Zero 2 using your USB to X adapter.

You should see devices pop up for /dev/sda in lsblk:

orangepi@orangepizero2:~$ sudo lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 232.9G  0 disk 
├─sda1        8:1    0     1M  0 part 
├─sda2        8:2    0    15M  0 part 
└─sda3        8:3    0 232.9G  0 part 
mmcblk1     179:0    0  59.5G  0 disk 
└─mmcblk1p1 179:1    0  58.9G  0 part /
zram0       252:0    0 492.1M  0 disk [SWAP]
zram1       252:1    0    50M  0 disk /var/log
zram2       252:2    0 492.1M  0 disk /tmp

First clean off the SSD by running:

sudo fdisk /dev/sda

Delete all partitions until it is completely blank.

Now we can copy the entire SD card to our SSD with the following command:

sudo cat /dev/mmcblk1 > /dev/sda

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).

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 UUID

Now unplug the SSD and plug it back in. 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/mmcblk1

We can verify that it has changed with blkid like this:

orangepi@orangepizero2:~$ sudo blkid
/dev/mmcblk1p1: UUID="9c0a441b-5aaf-4cf1-bec7-b457d3966cb6" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e8ce0794-01"
/dev/zram0: UUID="66b180ff-2899-431b-b8b7-8347d9af85eb" TYPE="swap"
/dev/zram1: LABEL="log2ram" UUID="d87403e0-1d2f-4356-905d-9dfaba14b6ee" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram2: LABEL="tmp" UUID="9abe5f8e-49b7-41d6-839b-3d2e0aa3b9cd" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sda1: UUID="5dd5b836-fb32-4678-908e-d23f7a028780" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e8ce0794-01"

Notice that /dev/sda1 and /dev/mmcblk1p1 no longer have matching UUIDs. This is exactly what we want.

Reboot and Verify

Now reboot the Orange Pi with:

sudo reboot

With any luck you should be booted using your SSD! We can verify this with the mount command like this:

orangepi@orangepizero2:~$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=431840k,nr_inodes=107960,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=100776k,mode=755)
/dev/sda1 on / type ext4 (ro,noatime,errors=remount-ro,commit=600)
/dev/sda1 on /var/log.hdd type ext4 (ro,noatime,errors=remount-ro,commit=600)
/dev/zram1 on /var/log type ext4 (rw,relatime,discard)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=100772k,nr_inodes=25193,mode=700,uid=1000,gid=1000)

Here we can see that our root partition (/) is indeed on /dev/sda and not /dev/mmcblk1. Success!

Resize SSD Partition

Once you’ve rebooted and verified you are booted from the SSD we can resize the SSD’s partition to be the same size.

We can use a built in service on the Orange Pi to do this. Use the following command:

sudo systemctl start orangepi-resize-filesystem.service

This will take a few minutes depending on how large your SSD is. Once it is finished verify you are using the full space on your SSD with:

orangepi@orangepizero2:~$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 232.9G  0 disk 
└─sda1        8:1    0 230.5G  0 part /
mmcblk1     179:0    0  59.5G  0 disk 
└─mmcblk1p1 179:1    0  58.9G  0 part 
zram0       252:0    0 492.1M  0 disk [SWAP]
zram1       252:1    0    50M  0 disk /var/log

Here we can see that my SSD’s partition is now the correct size for a 250GB SSD and is no longer only 58.9G like our original partition from the SD card.

Troubleshooting Note

The first time you try rebooting you may get an initramfs screen that says you need to do a manual fsck. This usually means you didn’t completely clean the partitions off the SSD (don’t be ashamed, I didn’t the first time either which is why I know it can be fixed). That can be fixed by using:

e2fsck /dev/sda1 -y 

or:

fsck.ext4 /dev/sda1

It should say the filesystem is clean after this and let you boot normally. Once it boots up it wouldn’t hurt to give it a:

sudo e2fsck /dev/sda1 -y

Fixing these may take a while. I had to do this second fsck because even though my system booted after the first fsck the disk was mounted as read-only due to additional errors (which is why it will let you fsck the root partition while actively booted which is normally a no-go, it’s in a protected read-only mode due to errors).

After this comes out clean reboot one more time and you should be all set with a read-write root partition on your SSD!

Testing Performance

You can verify the performance of your SSD on Pi Benchmarks using the following command:

sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

I ran the benchmark with full knowledge that we were using USB 2.0 and were going to be limited in our score. Nevertheless I wanted to see what the improvement over using the SD card was.

Here are the results:

     Category                  Test                      Result     
HDParm                    Disk Read                 37.08 MB/s               
HDParm                    Cached Disk Read          36.94 MB/s               
DD                        Disk Write                37.8 MB/s                
FIO                       4k random read            4745 IOPS (18980 KB/s)   
FIO                       4k random write           4426 IOPS (17704 KB/s)   
IOZone                    4k read                   8094 KB/s                
IOZone                    4k write                  10667 KB/s               
IOZone                    4k random read            8020 KB/s                
IOZone                    4k random write           10652 KB/s               

                          Score: 2,593                                        

You may view the full benchmark on Pi Benchmarks for this guide here.

Wow, that is a score of 2,593! That absolutely smashes any other tests for the Orange Pi Zero 2 on the site and is the new world record.

To give some context here the maximum score you can achieve over USB 2.0 is something around 2500-2600 points. This is true on Raspberry Pi Model 3s and older which only have USB 2.0 ports. They also max out around the same score.

This is more than double the fastest SD card score anyone has ever achieved on the board. That means it is absolutely worth it to use a SSD with the Orange Pi Zero 2!

Conclusion

It’s working 100%! We are getting full USB 2.0 speeds and maxing out the bus and substantially outperforming any micro SD card. It’s not too difficult to achieve this setup using this method.

It’s also very cheap. You can find 2.5″ SATA drives for less than $20 as well as M.2 SATA drives and those will more than max out the bus.

I highly recommend trying this for all Orange Pi Zero 2 owners! It was worth it on the Raspberry Pi 3 even over USB 2.0 (and I was doing it back then like in this benchmark with an almost identical score on the Pi 3 due to the USB 2.0 bus just like with this one). It’s worth it on the Orange Pi Zero 2 over USB 2.0 as well. A 2x-2.5x increase in speed is worth it for a relatively easy setup process.

Just make sure to use a cheap drive as anything more is massive overkill / a waste due to USB 2.0 limitations!

Other Resources

Make sure you check out my Orange Pi Zero 2 review and tips/tricks guide

If you have the Orange Pi i96 check out my updated image available for it here

Another amazing cheap use of 2.5″ SATA adapters is using them for upgrading your last-gen PS4 or Xbox One gaming consoles!

Want to see an even insanely cheaper board than the Orange Pi Zero 2? Check out my guide on the Orange Pi i96 headless board which is available for something like $7.

If you like retro gaming you may be interested in my ODROID Go Super Guide!

guest

6 Comments
Inline Feedbacks
View all comments

Wano
Wano
3 days ago

Hey.
It’s all wonderful. Only this does not allow you to boot the operating system from a USB drive. The bootloader (U-boot) is located on the SD card. The system will not start without an SD card.

Wano
Wano
3 days ago
Reply to  jamesachambers

You are absolutely right: this trick was originally used on raspberries. The only difference is that raspbian uses a DOS partition for /boot.
I tried to learn methods of transferring the bootloader to spi-flash. But I understood almost nothing and did not try because of the fear of turning zero2 into a brick.
But anyway, thanks for your instructions! Using a usb drive is still better than using a sd card.

David
David
9 days ago

Thank you for these instructions, but I wasn’t able to run the ‘sudo tune2fs -U random /dev/mmcblk1’ step due to the partition manager being Msdos and GPT. This seems to be done at the balanafetch stage of copying debian server image onto the microsd. Do you have any suggestions.