Wednesday, November 26, 2008

dd - the silent but strong type.

In the years as an XP user, copying one disk to another, or making a mirror, involved using Norton Ghost. Since the version that I had was DOS based, I had to go through the bootable Win98 partition/floppy route to get the job done.

Today I faced a similar issue, and went hunting for the linux version of Ghost, and found the ridiculously simple dd command. After using it, I am reminded of the type of folks who are all business with hardly time to utter pleasantaries.

While dd can do much more, for the job at hand, all I needed to do was issue "dd if=/dev/hda1 of=/dev/hda2" where hda1 was the source and hda2 the destination. To correctly figure out which is which, use the fdisk - l command to list all detected hard drives. This step is important, since it is easy to overwrite the wrong disk, since dd does not offer a prompt before going about it's business.

In my case, inspite of the fdisk command, I ended up deleting the Puppy installation in a flash drive that I had used to run the dd command to copy from one hard disk to another. It took me a couple of seconds to figure out the mistake, but it was too late. Now with the installation wiped out, I cannot use the flash drive at the next boot. The problem with that situation is that it has been close to 90 mins and dd has been working without any feedback, another quirkiness of dd.

The solution to this silence is to use another console to poke, literally, dd to offer information about what it has achieved. The Control - F1 (to F7) key combination can be used to launch a second console and from there issuing the command " $ watch -n X kill -USR1 PIDXX" where PIDXX needs to be replaced with the PID number of the dd process that can be found by issuing the "top" command. The "X" here is the time interval in seconds where the progress info is provided, which can be set according to user preference. And the kill -USR1 command is the actual poking that starts dd into giving the info.
A more detailed explanation is offered here :
http://linuxcommando.blogspot.com/2008/06/show-progress-during-dd-copy.html

Oh, in my case the power company had other plans, and an impromptu power loss brought the transfer process to a stop.

No comments: