I sell dedicated servers, I was wondering if there was an easy way for me to clone my hard drives so I do not need to install the centos OS on every hard drive.
I have a sata to usb adapter to connect it to my mac/pc, Does anyone know any software I can use to clone a bootable linux hhd?
It comes with Linux.
To clone the disk /dev/sdb to a file image.img:
dd if=/dev/sdb of=image.img
To write the contents of image.img to the disk /dev/sdb:
dd if=image.img of=/dev/sdb
Note that the hard disk you want to clone/restore must be either unmounted or mounted read-only, otherwise the image will change while you're cloning which is not good! If you pipe it through gzip, it significantly reduce the size of the image.
dd if=/dev/sdb | gzip > image.gz to create the image,
gzip -dc image.gz | dd of=/dev/sdb to write the image to disk.
If you have both disks plugged in you can skip a step and just write from one to another. Suppose the disk set up correctly is /dev/sdb and the one you want to clone onto is /dev/sdc. Provided that both are unmounted or only mounted read-only, you can do:
dd if=/dev/sdb of=/dev/sdc
Thanks for your solution Fire Boar,
I plugged the hdd into a parallels desktop centos.
It mounts the hard drive as "/boot"
Would it be possible to save the image file on the paralles computer so when ever I need to move one over onto a new hard drive I dont need the master hdd?
Could you give me the command to run for that =)
Mounts it as /boot? That's strange, /boot is normally where the bootloader goes, mounting something on that folder is silly. Regardless, you need to plug in and unmount the hard disk in the CentOS session. Find out the device filename (/dev/sd? where ? is a letter, sometimes /dev/hd? for older hardware): the command fdisk -l should give you a clue because it lists each disk's device filename and partition structure. After that just use the first command in my post above to create a file image.img in the working directory. It will take a while, and you must make sure you have enough space (more space than the total capacity of the master hard disk). You then no longer need the master hard disk. If you don't have enough space (which is very likely) then using gzip is recommended (third and fourth commands in bold for creating the image and writing it respectively).
The master hard disk only needs to be plugged in to create the image, or if you're using the last command in my post above, which clones directly.