Run a Raspberry Pi from a hard disk or SSD

Many of us use Raspberry Pi computers in our home automation. I personally use a Raspberry Pi as my node-red server. (See https://community.hubitat.com/t/node-red-nodes-for-hubitat/34386).

I hear that a problem with RPI is the limited lifespan of the SD cards from which it runs. So I looked into making my RPI model 4 run from a USB SSD I had laying around. After much research and trial and error, I now have my RPI4 running from the SSD. It is much faster also! RPI4 doesn't support booting directly from the SSD, so a SD card is needed, but only to boot it. Here's how to do it:

Here’s how to set it up.

  1. Plug your drive into one of the Blue USB ports. These are the USB3 ports and provide more power and speed than the black ports.
  2. Start up your RPI, if it’s not already running.
  3. From the RPI desktop, click the start button, Accessories, SD Card Copier.
  4. The From Device will be your SD card (probably /dev/mmcblk0)
  5. The To Device will be your new drive (probably /dev/sda)
  6. Select New Partition UUIDs
  7. Click Start. This copied everything from the SD card onto the new drive.
  8. When this is finished, open a terminal window.
  9. Enter sudo nano /boot/cmdline.txt
  10. Paste the following text at the end of the first (and likely only) line of cmdline.txt (after a space). root=/dev/sda1 rootfstype=ext4 rootwait
  11. Then CTRL-X, Y when prompted to save, and ENTER to confirm.
  12. Reboot your RPI (type sudo reboot in the terminal)
  13. RPI will then be running from the hard drive. You still need the SD card to boot as RPI cannot boot from a hard disk. But once running, the SD card is not used.
  14. If you have a problem, you can take the SD card out of the RPI, put it in a PC, and edit out the change in cmdline.txt. It will then operate from the SD card again.
  15. If this SD card ever crashes, you can just make a new one using the RPI configuration, change the cmdline.txt file, and you are all set.
6 Likes

I been doing this a while now and use a 120 SSD it is fast.

I installed an 8 node rpi 4 cluster/docker swarm this week. Glusterfs for docker persistent files.

No real reason. Just needed something to do. It is cute.

No SSD though, just Samsung endurance sd cards.

2 Likes

If you already have a system up an running simply format your drive to ext4, mount it somewhere, rsync your mem card over to the partition, edit your cmdline.txt and replace the root line with the dev location of the SSD, reboot. If your system is up to date you should already have the rootfs and rootwait commands in line.

Really simple.

Bonus points, multiple partitions and systems set up, which are easily swapped between with a quick comment and uncomment of a line in cmdline.txt. Use rsync to backup your system to one every so often and you have a fallback should your main system ever get borked.

I've had a 500G SSD running entirely off the USB3 port for quite some time now. The speed difference alone makes it worth it.

Note: Depending on your drive you may need to enable quirks on your drive to get good speed out of it

1 Like

Are those cards any "better" than the regular? I was looking at them when I bought a couple of PI4's. I have had mostly good luck with sdcards anyway. With the PI3 the usb is slow so external HD solutions can be problematic but maybe okay for headless operation and simple server stuff.

also doing a pi cluster.... nice!!! :sunglasses:

1 Like

Can I make an SBC suggestion? Look into the Odroid SBCs. They're slightly more expensive than their Pi equivalents, but run circles around them. Plus, they come with eMMC support - so data reliability is way better than with SDs.

I've used both Odroid XU4s and Odroid N2s with Ubuntu 18.04 - the XU4 is arm32 (so comparable to the Pi3, and the N2 is aarch64 (so comparable to the Pi4).

The XU4 has an octacore Samsung Exynos 5422 CPU. The N2 has a hexacore Amlogic S922X CPU

Here's some CPU benchmarks comparing the Pi3, XU4 and N2:

1 Like

And now you are probably going to force me to spend more money... sigh.. shame on you @aaiyar..

:wink:

2 Likes

Here's the kicker to push you even more in that direction - unlike the Chinese RPi-clones (like the BananaPi and OrangePi line of SBCs), the Odroids have well documented pinouts and the hardware is super reliable. They also release GPU drivers ...... so rock-solid 4K video (with the N2).

I like the odroid, they are just too expensive relative to an rpi4 for my tastes though. When deployed in bulk that cost difference matters.

1 Like

Very true. When it's one or two units, the difference doesn't matter much. But at scale .... $40 adds up fast.

I will say they have a lot more variants than last time I looked at them. Pretty cool.

The XU4s look interesting to me.

Might get an MC1 stack to play with next month from here, need to think on it though as it is arm7 32bit which impacts a few things I'm working on:
https://www.hardkernel.com/shop/odroid-mc1-my-cluster-one-with-32-cpu-cores-and-8gb-dram/

2 Likes

If you use dietpi this is easier to set up if ur dumb like me

Wow @aaiyar Odroid N2s get into NUC territory pretty fast. Cool, but they seem a bit pricey. Admittedly, I couldn't resist 128GB of eMMC, but I hit $176 before I could blink! Lol

S.

3 Likes

True true.

The thing is very fast. I read a post - I think on the Odroid forums that by early next year, they're expecting a cluster version of the N2, much like the MC1 is a cluster version of the XU4.

Other than just noticing if RPi is responding faster, how can I confirm this worked?

In the RPI desktop, open the File Manager. Click on root (/). Check the Free Space.

image

Mine didn't work then. I still have 28.4Gib. If I click on rootfs, I have 116.6Gib (Its a 128 SSD).

My cmdline wasn't empty. It contained:
console=serial0,115200 console=tty1 root=PARTUUID=ea7d04d6-02 rootfstype=ext4 elevator=deadline fsck.repair=$

I added the text in step 10 after that. Should the text in your instructions replace what was already in there?

No, the text goes at the end of the line, not on a new line. And it doesn't replace the old line.
I am far from an expert on Linux, so someone else might be able to help you.

Also - if you are running an earlier RPI than the model 4, you can boot directly from the SSD. There are a number of articles describing this.

Ok, moved it to end of 1st line and also changed to SDA2 because when I tried SDA1, it never booted. Now, i have the 116.GiB Total under /root. Thank you. This is a RPi 4 running my Node Red. Now, I need to figure out why I can't do the same on my other RPi 4. It's having an RPi problem with the external drive; nothing to do with your instructions.

Thank you for your help.

1 Like