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.
- 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.
- Start up your RPI, if it’s not already running.
- From the RPI desktop, click the start button, Accessories, SD Card Copier.
- The From Device will be your SD card (probably /dev/mmcblk0)
- The To Device will be your new drive (probably /dev/sda)
- Select New Partition UUIDs
- Click Start. This copied everything from the SD card onto the new drive.
- When this is finished, open a terminal window.
- Enter sudo nano /boot/cmdline.txt
- 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
- Then CTRL-X, Y when prompted to save, and ENTER to confirm.
- Reboot your RPI (type sudo reboot in the terminal)
- 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.
- 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.
- 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.