Clone SD card to SSD/HDD for raspberry
How to clone raspberry SD card to boot your Pi on SSD/HDD disk
Brian McGowan©
- Step 1: Preparing the Raspberry Pi
- Step 2: update the firmware to be able to access the USB boot
- Step 3: Clone SD card to SSD or HDD disk
- References
The SD card
is good and practical, however when using a raspberry 24 hours a day, the wear and tear of the SD card
is very limiting.
So why not use an SSD
or HDD
disk, and transfer the contents of the SD card
to it. In addition to a large space, you will gain in reliability.
Step 1: Preparing the Raspberry Pi
- Disconnecting all services that could write to the SD during data transfer
For examples
sudo systemctl stop cron
sudo systemctl stop nginx
sudo systemctl stop docker
sudo systemctl stop plexmediaserver
Step 2: update the firmware to be able to access the USB boot
Open a terminal, either from Putty if you have installed Raspberry Pi OS Lite, or from the Raspberry if you have installed the full version of the OS with the graphical interface. Type the following commands to update the system and firmware:
sudo apt update
sudo apt full-upgrade
sudo rpi-update
Confirm the sudo rpi-update
command with a Y (Yes)
or O (Yes)
. Unlike sudo apt full-upgrade
, the default response for this command is No/Non
.
Then restart the machine:
sudo reboot
Once the machine has started, we will take the opportunity to update the bootloader (the small program that allows you to boot, on USB
or micro-SD
).
Type the following command:
sudo rpi-eeprom-update -d -a
And that’s all. It was simple, fast, without risk.
Step 3: Clone SD card to SSD or HDD disk
Now you download the script billw2/rpi-clone
that will do the cloning all.
cd
git clone https://github.com/billw2/rpi-clone.git
cd rpi-clone
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
now connected your SSD
or HDD
disk to the raspberry Pi. When the usb connects, it should be named sda
. You can check by listing the /dev
folder or using the lsblk
command. Then you run the command
sudo rpi-clone sda -f
The script will ask you just 2 questions :
Initialize and clone to the destination disk sdb? (yes
/no
): yes <-
your answer
Optional destination ext type file system label (16 chars max): <-
you can leave empty
The script changes the UUIDs
in boot
and fsatb
, so don’t worry.
References
- Git repository billw2/rpi-clone