use dd to clone the hard disk block by block or create an image

 

The Linux command dd can be used to write one hard disk block by block to another. Since all blocks are transferred, it does not matter which file system, partition layout or operating system is to be cloned, only the target hard disk should not be larger than the partition layout of the source hard disk, see: cloning a large hard disk to a smaller one using free tools.

With the help of a bootable Linux media the PC can be started and any installation can be cloned, see also: install Ubuntu or start live system.

Show hard disks and partitions

First of all the hard disks or partitions can be read out with the command fdisk -l or in the GUI with gparted.

Clone

To clone one hard disk to another, the following command can be used:

sudo dd if=/dev/sda of=/dev/sdb bs=100M status=progress

(sda and sdb are adjusted according to the output of the fdisk command.) This command overwrites the 2nd hard disk, appropriate caution is required.

if ... source disk

of ... Destination disk

bs=100M ... Size of the blocks which are read and written:

without this parameter I had about 46MB/s, with 320MB/s throughput

status=progress ... shows the progress

Image

For creating an image this command can be used:

sudo dd if=/dev/sdg status=progress bs=100M > /daten/image/W10.img

For creating a compressed image this command can be used:

sudo dd if=/dev/sdb status=progress | gzip -c > /daten/image/W10.img.gz

If the source disk is faulty, the following parameter continues copying even if errors occur:

conv=sync,noerror, like this

sudo dd if=/dev/sdb status=progress conv=sync,noerror bs=16M | gzip -c > /daten/image/W10.img.gz

A quick word about speed:

Originally I used bzip2 for compressing, the image process was extremely slow with it:

delivered about 3.4MB/s; the gzip command runs at 15MB/s for me.

the following command can be used for restoring:

gunzip -c /daten/image/W10.img.gz | sudo dd of=/dev/sdc3

dd progress display - output status

If the parameter status=progress was not specified at startup, it can be output afterwards:

the status of running dd jobs can be updated with the following command:

sudo kill -SIGUSR1 $(pidof dd)

dd then prints a status in the terminal:

3184084+0 Datensätze ein
3184083+0 Datensätze aus
208672063488 bytes (209 GB, 194 GiB) copied, 13861 s, 15,1 MB/s

Output status every 30 seconds:

The command must be executed in a second terminal:

watch -n30 'sudo kill -USR1 $(pgrep ^dd)'
positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details