2022-03-03    Share on: Twitter | Facebook | HackerNews | Reddit

Clone Partition in Linux

clone partition

dd if=infile | pv > outfile

create a disk image

(from arch wiki: https://wiki.archlinux.org/index.php/Dd#Disk_cloning_and_restore)

dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c  > /path/to/backup.img.gz

Finally, save extra information about the drive geometry necessary in order to interpret the partition table stored within the image. The most important of which is the cylinder size.

fdisk -l /dev/sda > /path/to/list_fdisk.info

Restore system

To restore your system:

gunzip -c /path/to/backup.img.gz | dd of=/dev/sda