I recently bought an SSD hard drive and in order not to lose all the information from my old hard drive I had to clone it exactly in the new one. As you can imagine, it is not copying and pasting files, so I used the dd command. It is possible to do the same with Clonezilla, but I prefer a simple command.
The most important parameters are 3:
- if: source file
- of: destination file
- bs: limit of bytes that are read and written every moment.
Of course, you can see more options with the dd –help command.
Before starting, you have to know what hard drives or USB drives have connected to the computer. To do this, we execute the command fdisk -l as superuser. Assuming that the hard disk we want to clone is in /dev/sda and the target hard drive is in /dev/sdb, perform the cloning executing the following command:
sudo dd bs=1M if=/dev/sda of=/dev/sdb
With the option bs=1M, we are saying that the speed of reading and writing in blocks is of 1 Megabyte. The lower, slower and safer. The higher, the faster, but we risk that doesn't copy well. To create an ISO image from a CD, execute this command:
sudo dd if=/dev/cdrom of=/home/user/diskimage.iso
To save an ISO on a DVD, source, and destination would be exchanged:
sudo dd if=/home/user/diskimage.iso of=/dev/cdrom
The dd program offers many possibilities when working with hard drives, external memories, and CDs or DVDs. I use it a lot, and the truth is that it is more comfortable than any other program to burn discs.