Friday 11 January 2013

Troubleshooting - Hard Disk Cloning

To Replace the hard disk need to be taken the clone of the new hard disk

The procedure is as follows:

Cloning a hard drive is a good way to create an "image," or snapshot of our current operating system as a back-up. It is also useful if we want to transfer the contents of the running mangement node computer exactly as it is, complete with all preferences, from an old drive to a new one.

Instructions:

--Back up all important data, in case anything goes wrong.

--Detach any storage devices--including external drives, memory cards, cameras and memory cards--besides the drive you want to clone and the destination drive where you want to store the image.

--Boot the computer where vx64 is running with Linux live CD.
--Learn the naming scheme for the computer's drives by opening a Linux terminal window and typing the following command:
 
#sudo fdisk -l
--Take note of (and preferably write down) the information under the "Device" column. It will include a list of one or more items named /dev/sda1, /dev/sda2, /dev/sdb, and so forth. The letters (sda, sdb) indicate separate hard drives. The numbers (sda1, sda2) indicate separate partitions within each drive.

Note: The new hard disk is raw..hence need to format the raw hard disk by typing the command

#mkfs

hence the fdisk will show the new hard disk as dev/sdb as if the old one is dev/sda.

--Using the information you obtained from the previous step(#fdisk -l), determine which is your source drive (/dev/sda) and your destination drive (dev/sdb).

--Some clues include the size of the respective drives and their partitions. For example: You are trying to clone a 60-gigabyte source drive onto a 120-gigabyte destination drive. If the previous step tells you /dev/sda has a 60-gigabyte capacity and /dev/sdb has a 120-gigabyte capacity, you can use their respective sizes to tell which is which. Another example: You are copying a three-partition source drive onto a blank destination drive. You see four rows labelled: /dev/sda1, /dev/sda2, /dev/sda3 and /dev/sdb. Next to them are numbers that correspond to each of your partitions and a blank field next to /dev/sdb. You can conclude that sda is your source drive and sdb is your destination drive.

--Open a terminal window.
--Type in the following command, replacing SOURCE with the name of the source drive and DESTINATION with the name of your destination drive:

#dd bs=4k if=/dev/sda of=/dev/sdb conv=noerror,sync

--Here, if=... sets the source and of=... sets the destination. "dd" doesn't care of the contents of the hard disk. It just reads bytes from /dev/sda and writes them into /dev/sdb. It doesn't know what are files. So, the hard disk file system and how many partitions it has are not important. For example, if /dev/sda is splitted into three partitions, the /dev/sdb will have the same partitions. i.e. "destination" is completely same with "source"

Note:To clone only one partition from the source drive, specify the partition (e.g., /dev/sda1 or /dev/sda2). To clone the entire drive, specify only the drive name, with no partition number (e.g., /dev/sda).

to execute "dd" you should login as "root" or switch to "root" using "su" command. And you must be careful, a small mistake may cause a serious problem!

--Wait. Cloning a large drive using dd can take hours, and according to some accounts, even more than a day.

Tips & Warnings:

--After the process is complete, test whether cloning took place properly by attempting to boot from your destination drive.

--Giving dd to the wrong source and destination drives can cause you to overwrite important data. Be sure to input the correct source and destination drives. Always back up important data before attempting this process.

Most of time we don't want to make a complete duplication of hard disk. Then we may prefer to creating an image file of the hard disk and save it in other storage devices. The following command will create an image file "disk1.img" in your user's directory from /dev/sda:

#dd if=/dev/sda of=~/disk1.img

Since you have created an image file, you can compress it with "gzip" or "bzip2":

gzip disk1.img #generates disk1.img.gz or

bzip2 disk1.img #generates disk1.img.bz2

You can save much storage space with compression. But it will take very long time.

To restore a partition or a hard disk from an image file, just exchange the arguments "if" and "of". For example, restore the whole hard disk from the image file "disk1.img":
#dd if=disk1.img of=/dev/sda

Restore the first partition of /dev/sda from the image file "disk2.img":

dd if=disk2.img of=/dev/sda1


My practical test in our lab environment

-Created on virtual machine(min10GB) on esxi box

-After success ful installation shutdown the virtual machine and added new hard disk form the vsphere client add and remove console with incresing the disk size upto 12 GB

-now the boot priority changed to cdrom as the first boot device and the vm is booted with the live cd of Ubuntu linux.

-- formated the new hard disk and mounted the volume and cloned the old hard disk to the new one with "ddcommand"
-- after completion of the process the boot priority is chnaged the new harddisk and booted

-- after successful boot the os on the new hard disk is running fine and proper.

No comments:

Post a Comment