You shouldn't make a backup of a "live" filesystem with
dd - it has its uses, but backing up a "live" system is not one of them. It's been said of one who follows this practice: "If you're lucky, the filesystem corruption will be detected as soon as you try to mount the copy. If you're unlucky, it won't be detected until later."
I'll assume you know how to configure your RPi to boot from an external SSD, & won't cover that. But if you're unsure about this, read USB mass storage boot.
Cloning your existing microSD to a bootable SSD from the command line on a single RPi is a two-step process:
Step 1: Install
image-utils & make an image file clone of your SD card. Start at the
Show Me How heading of this post, or do something like this (Note: my exe copy of
image-backup lives in
$ sudo /home/pi/bin/image-backup
Answer the questions when prompted. Creation of the image file required approx 2.5 minutes to complete on my system.
My image file was saved as:
Yours will likely be different, but note its name and location as you'll need this in Step 2.
Step 2: We'll now use
dd to copy the image file created in Step 1 to the SSD. This avoids issues with
dd mentioned previously because neither the input file (
if), nor the output file (
of) are mounted/active.
Connect your SSD to one of the USB ports, then use
lsblk to examine all block storage devices connected to your system. For example, here's mine:
$ lsblk --fs
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
└─sda1 ext4 PASSPORT2TB 86645948-d127-4991-888c-a466b7722f05 1.5T 11% /mnt/Passport2TB
├─mmcblk0p1 vfat 6969-16D1 206.5M 19% /boot
└─mmcblk0p2 ext4 f6ea6ef9-68be-479d-b447-5f76391cc02f 22.7G 18% /
sda1 is a mounted USB drive where I saved the image file created in Step 1. Confirm that this partition/device is mounted by reviewing the
MOUNTPOINT column in the output.
sdb is the SSD on my system. Your SSD may be assigned a different device designation (
sdf, etc). Confirm that your SSD drive (or
sdb in this example) is not mounted by confirming there is nothing listed for it in the
MOUNTPOINT column. If it is mounted, un-mount it using
sudo umount /dev/sdb & verify this by re-running
mmcblk0 is your microSD card - the card you currently boot from. Of course it is mounted at two points: the root ext4 partition
/, and the boot FAT partition
Once you're satisfied with your examination, you are ready to copy the image file created in Step 1 to the SSD:
$ sudo dd bs=4M status=progress if=/mnt/Passport2TB/img_backups/20210701_Pi4B_imagebackup.img of=/dev/sdb conv=fdatasync
# sample output :
4383047680 bytes (4.4 GB, 4.1 GiB) copied, 160 s, 27.4 MB/s
1048+1 records in
1048+1 records out
4396003328 bytes (4.4 GB, 4.1 GiB) copied, 165.296 s, 26.6 MB/s
man dd if you've any questions re the options.
You may now remove your microSD card, and boot from your SSD.
If you had a 2nd system with a GUI, you might consider using
rpi-imager in Step 2 - but think of all the fun? you'd be missing.
Step 2: Install
rpi-imager on a desktop/laptop system & use it to "install" the image file you created in Step 1. Installation of
rpi-imager on a Linux system using
apt (e.g. Debian/Ubuntu) is as follows:
sudo apt-get update
sudo apt-get full-upgrade
sudo apt install rpi-imager
note that the update and upgrade steps should always be performed prior to installation of new packages.