I’m gonna explain another method to backup your whole hard disk. We are going to make an exact clone of our hard disk. In this howto, we will use a very useful command: dd. If your hard disk is /dev/hda and you have a spare hard drive being external in /media/sda1 or internal, just type:
dd if=/dev/hda of=/media/sda1
Be careful, sda1 must be of the same or greater size than hda. If you want to make an image of the whole hard disk into an image file, just type
dd if=/dev/hda of=/media/sda1/image.img
Then, this .img file can be mounted as a loopback filesystem to see its contents.
To restore it, then proceed the other way round:
dd if=/media/sda1/image.img of=/dev/hda
When restoring, the best way is to boot from a live cd and restore the hard disk. There are lots of live cds out there, but I recommend using Knoppix.
September 17, 2006 at 6:19 pm |
Well… Ubuntu is the same or may be better. You might also wanna play around with -bs option to dd to increase the block size. And make sure it’s a power of two. Usually I use -bs=8192 when cloning disks, it sure speed things up. If you don’t specify this IIRC the default value is 512.
September 17, 2006 at 6:51 pm |
Thanks for the tip. We can reach the I/O limit with bs. I have an external usb hard drive and the maximum writing speed is limited by the usb 2.0 bandwidth.
September 19, 2006 at 6:45 pm |
i would recommend partimage instead of full dd. The problem with dd is that the unused bytes also are copied ………… partimage does it intelligently ……… copy only those blocks which are used …….. rest are skipped ………
September 20, 2006 at 1:32 am |
[...] It was of today that I was a reader of some tips known most ancient for users of Unix and Unixlike systems, but also of some use. My readers, I am of the know that some of you have been switchers to Ubuntu Linux and Kubuntu Linux after being most active readers of my blog. So happy I am that you have been making a decision most prime! And I am of the know that many of you are but likers of backups. That is but an idea rightfully made. Backups of our datas are something we must be doers of in these days of commodity hardwares. The article, it is but a writer about the usages of dd to be a maker of backups of hard drives. My writings, but they will be a teller of my lookings into the history of dd. [...]
September 22, 2006 at 8:40 pm |
gnuyoga,
You are right. Partimage is more practical as it only copies the used blocks. dd copies “all” the hard drive. If the size is 40Gb, then it will copy 40Gb regardless of unused space.
September 28, 2007 at 6:29 pm |
Isn’t it possible to compress that image?
May 28, 2008 at 9:31 am |
Yes you can compress an image, but you dont get much compression out of it.
I compressed a 40gig image to about 32gb, with gzip
June 17, 2008 at 3:10 pm |
Dear all,
do you guys know how cloning hd from host to guest in VMware ?
thanks 4 the advise
December 5, 2008 at 6:14 pm |
Migrating a live machine to a VM can be done by VMware converter. It is free on VMware’s web site.