Backup An SD Card In Linux

If you are like me, you have various projects on SD cards. Raspberry Pi images are a huge example of this. I’ve had a Raspberry Pi Zero W2 running as a server on solar power in my shed and decided it’s a good time to back the card up.

Here’s one way to do this in Linux.

The first thing I usually do is bring up the “Disks” utility in Ubuntu. Your distro of choice likely has something very similar to this. I use this to double check that I’m targeting the correct drive. I don’t want to accidentally backup or erase the wrong drive!

As you can see, “/dev/sdb/” is the correct drive.

The linux command we can use to view the drives in a terminal is:

sudo fdisk -l

You will have to sort through all the drives until you find the right one, which in this case is:

fdisk -l

We have confirmation from the two methods and can confidently determine that the drive is “/dev/sdb”. So now it’s time to make a backup image of this SD card.

sudo dd bs=4M if=/dev/sdb of=backup_sd.img

Please replace “/dev/sdb” with your drive and feel free to change the name “backup_sd” to whatever suits you.

Once the file is done, it is a good idea to compress it for storage.

tar -czvf backup_sd.tar.gz backup_sd.img

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: