Clone Hard Drive or Partition to an image file easily
REQUREMENTS:-Linux live boot CD (or bootable usb drive)
-Place to store image file like external hard drive (enough size to store partition or whole disk)
BACKUP1. Just boot with a linux live CD, if you lack of a CD-ROM Drive, then you can create a USB bootable stick with a linux image and boot from it.
2. Mount you external storage, for instance mount -t ext3 /dev/sdb1 /media/images. NOTE: just the destination drive have to be mounted, not the source drive.
3. Once you are running the Linux OS, if you found that your hard drive is /dev/sda for instance, then run:
#dd if=/dev/sda of=/media/images/disksda.img
#cd /media/images/
#bzip2 disksda.img <- if you want to compress it.
Now if you want is to create a image just from a partition then change the if=/dev/sda by if=/dev/sdaX, where X is the number of the partition, for instance:
#dd if=/dev/sda1 of=/media/images/disksda1.img
#cd /media/images
#bzip2 disksda1.img
Sometimes we want to move this image directly to other remote host with linux and ssh running on it and a user called "user", the we can do this:
#dd if=/dev/sda of=/dev/stdout bs=1M | bzip2 | ssh user@IPofRemoteHost "cat - > disksda.img.bz2"
this read the /dev/sda hard drive, the send this data to the standard output and compress it in the RAM, take the standart output compressed and using the ssh write it in the remote host in a file called disksda.img.bz2
RESTORE1. Just boot with a linux live CD, if you lack of a CD-ROM Drive, then you can create a USB bootable stick with a linux image and boot from it.
2. Mount you external storage, for instance mount -t ext3 /dev/sdb1 /media/images. NOTE: just the source drive have to be mounted, not the destination drive.
3. Once you are running the Linux OS, found your hard drive name and restore on it, for instance /dev/sda.
to restore from the remote host do this:
#ssh user@remotehost "cat - > disksda.img.bz2" | bzip2 -dc | dd if=/dev/stdin of=/dev/sda bs=1M
to restore from the external storage:
#dd if=/media/images/disksda.img of=/dev/sda
or to restore the partiton image doing:
#dd if=/media/images/disksda1.img of=/dev/sda1
remember to uncommpress the bzip2 file first if it is compressed.
Sometimes the first hard drive is called /dev/sda, sometimes /dev/hda thats why you have to check how the linux call your hard drive.
To clone a hard drive into a second one, just us of=/dev/sdb or whatever the name of the second drive is, without mount any drive.
Partition table is created, MBR is created, but the external drive in size have to be equal or bigger than the drive to be copied.
If you have a question about it, please first read this:
see also:
how_to_easily_secure_datalinux-disk-space-distribution-by-mappingonline-data-storagevia:
backup-your-hard-drive-in-a-image-file-using-dd/
0 comments:
Post a Comment