Complete Disk Backup
The Unix tool dd copies data at device level (not at file system level). With that you can create images of complete drives or restore them to a drive.
The following examples were created under macOS, but under
Linux it is almost the same.
Creating an image using an SD card as an example
-
Insert SD card formatted with VFAT.
-
show list of drives
$ df -h -
Select the correct drive from the list. On the left are the Devices, Mountpoints are on the right. In the case of an SD card, e.g.
/dev/disk5s2. -
Unmount device (Under Linux
umountinstead).$ sudo diskutil unmount /dev/disk5s2 -
Copy image. It is important that here as the source (if) not only the partition (here
/dev/disk5s2) is set, but the entire device (here/dev/disk5). The parameterof=\....is the target image to be generated. The parameterbs=1mspecifies to create a boot sector with 1 MB on the target image.$ sudo dd if=/dev/disk5 of=./any_name.img bs=1m -
To have a backup of
any_name.imgit would make sense to compress and encrypt the file, e.g. withgzipandgpg:$ gzip any_name.img $ gpg -c any_name.img.gz Passphrase: ************* $ ls any_name.img.gz.gpg
Restore the backup
-
decrypt accordingly with
gunzipandgpgwithout the-cParameter.$ gpg any_name.img.gz.gpg Passphrase: *********** gunzip any_name.img.gz $ ls any_name.img -
Insert a SD card formatted with VFAT.
-
show list of drives.
$ df -h -
Select the correct drive from the list. On the left are the Devices, Mountpoints are on the right. For an SD card for example you have on the left side
/dev/disk5s2. -
Unmount device (Under Linux
umountinstead).$ sudo diskutil unmount /dev/disk5s2 -
Restores the image. It is important to set the entire device (here
/dev/disk5) as the target (of) but not only a partition (here/dev/disk5s2). The parameterif=...is the source image to read. The parameterbs=1mspecifies that a boot sector with 1 MB is to be created in the target device.$ sudo dd if=./any_name.img of=/dev/disk5 bs=1m