Copying a Disk with DD
It often happens that you need to copy disks or DVDs, making exact copies. The ideal tool is dd.
This little command-line program copies from one source to another. Typically, if you want to make an image copy from an external disk, proceed as follows:
- Connect the disk
- Connect the disk via USB. Make sure it is USB 2; at USB 1 speed it could take all day. To check, just run
lsusb -tand verify that the disk is under an ehci 480M bus and not a uhci at 12M. - By looking at the system log you can see which device is associated with the disk (
tail -f /var/log/messages o tail -f /var/log/syslog). You should see something like (if you have Ubuntu): - From which you can tell that the disk has been assigned sdb
Making an image of the disk
- To copy the disk to an image file, just specify the source (
if – input file) and the destination (of – output file) - Since the copy can take some time, it is useful to send the SIGUSR1 signal to get the progress status. For example, if the pid (
ps -Af | grep dd) of dd were 2534:
- Don't worry, the process continues; the kill simply tells the process to print its progress status.
Writing the disk image
- To write the image, just swap if and of
Other uses
- dd is often used together with nc to perform the copy operation over the network
- Or to check the performance of a disk (below, my laptop on that fine day when I had a solid-state disk to try out):
