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)'

{{percentage}} % positive

THANK YOU for your review!
Top articles in this section
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 video, se...
Mirroring is the simultaneous writing to two hard disks, also called Raid 1. Mainly a hard disk mirroring is used for the protection against the failure of a hard disk. If a hard disk fails, the data is available on the second disk, the computer continues to work and can be started with the setup described here even after the failure. Mirroring the Windows partition is very easy, but not setting up the partitions so that it is possible to boot from the 2nd hard disk in the event of an error. Thi...
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.