Raspberry (and older versions) running Raspbian on SSD
Why running on SSD?
Reliability
SD Cards are not reliable enough to safely run Raspbian on a Pi. The lifetime of Flash cards is limited by the maximum number of writes per memory cell. A flash card has an on-card memory controller that performs wear leveling management. This tries to spread write actions over all memory cells - through time - evenly, to prevent premature partial wear out. The wear levelling unfortunately does not completely prevent microSD cards in Raspberry Pi’s (and similar devices) from wearing out.
Performance
SSD are showing far much greater performances. Some tests on the net are showing a factor of 3 to 5 (read/write) performance.
Type of SSD
I like to use tiny mSATA SSD that I buy for less than 30$. Any other SSD can be used. Pay attention to have a power supply strong enough to feed both the Pi and the SSD.
How?
Transfering the whole filesystem on the SD Card to the SSD is a piece of cake.
Identifying your SSD
Your SSD should be on /dev/sda.
You can further check it using:
$ lsblk
Stopping critical services
To avoid any issues during cloning, one should better stop all critical services / applications running on your Pi.
Identify running services:
$ systemctl list-unit-files | grep enabled
Stopping enabled services:
$ stop systemctl stop application.service
# where application is the name of your service
Cloning SD Card, and booting from SSD
Many websites are describing a “step-by-step” process, with lot of command lines to carry out this operation. As a linux fellow user, I did it many times, but it’s boring and not error proof. I was super happy to discover a magic shell script that does everything for you: rpi-clone.
Just follow the 3 + 1 optional steps below.
Step 1: download and install rpi-clone
If not already done, install git on your raspbian or just skip the first command below
$ sudo apt-get install git
Then, install rpi-clone
$ git clone https://github.com/billw2/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
Step 2: clone your SD card to USB disk, and tell the SD card to boot from disk
Depending on the ftab configuration the script command will be slightly different. First check your fstab file to check whether it is using PARTUUID or device names to describe the filesystems the system can mount.
$ cat /etc/fstab
Then, run rpi-clone with:
hostnamebeing the host name you have selected for your Pisdabeing idenfied as your SSD idenfier with lsblk
If fstab uses PARTUUID:
$ rpi-clone -s hostname -l sda
If fstab uses device names:
$ rpi-clone -s hostname -l sda -e sda
After successful execution of the script, the SD Card will only be used to tell the Pi to boot from disk.
Step 3 (optional): boot directly from SSD, without SD card
If you are using a pi3 (or older versions) you can boot from SSD only while activating USB mass storage boot. This is not possible on pi4 at the time I am writing this article. This feature is known to be supported in a future update. All details are provided on the raspberry documentation.
Step 4: reboot your Pi
$ sudo reboot
Comments