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

Diese Seite gibt es auch in Deutsch

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!

Publication: 2022-05-11 from Bernhard 🔔


Top articles in this section


Windows : create a missing recovery partition
When cloning a large hard disk to a smaller one, I lost the recovery partition. So far not bad, Windows works without recovery partition, but in case of an error the partition helps to get the PC up and running again. To summarize, here's how it works with the recovery partition: As long as the partition is still there, it can be deactivated and written to a file. If the partition gets lost unexpectedly, it can be recovered from the Windows setup media. This post is also available as a vide...

clone a large hard disk to a smaller one with the help of free tools
Free tools for cloning a hard disk cannot usually clone a large partition and thus a large hard disk onto a smaller one. Thanks to the command "Shrink Volume" in the disk management of Windows, the hard disk can be prepared for the cloning process and then cloned with the help of open source tools. Thus, for example, a Windows installation with all data can be moved to another disk.To speed up the PC with very little effort, a smaller SSD is usually used as the target. With the procedure describ...

Install Grub setup and set up Linux bootloader
Ubuntu and most other Linux-based operating systems use GRUB2 as a boot loader. In GRUB, settings such as the default operating system or the use of a background image can be set. In addition, GRUB can be configured to load multiple operating systems: Dualboot.

Questions / Comments


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