1753543 Members
5574 Online
108795 Solutions
New Discussion юеВ

Re: hard disk clonning!

 
SOLVED
Go to solution
ajay_25
Occasional Contributor

hard disk clonning!

Hi everybody,

i want to clone my mail server hard disk in to a new hard disk as like we can do with norton ghost for windows. in linux is there any way to copy entire hardisk in to a new one?

example:
1.i have 20 GB hardisk A(linux installed) with important data.
2.i have one more harddisk B(20 GB). i want to copy each and every file and directory from harddisk A to harddisk B.
3.can i boot from the harddisk B with out installing anything after copying entire disk.?

please advise me the steps to do that.

thanks in advance..
ajay
10 REPLIES 10
Hoefnix
Honored Contributor

Re: hard disk clonning!

Ajay,

You should be able to copy the disk using the dd command (check man dd), but first take a look at the next url: http://www.mondorescue.org this softwarepackage will work like Ghost is doing for Window$.

HTH,
Peter
Gopi Sekar
Honored Contributor

Re: hard disk clonning!


dd is one method but it requires both hard disks to be exactly of same size (including geometry).

* otherwise you can connect the backup harddisk as secondary to the mail server.
* Boot with a rescue CD (you can use RH or SUSE installation CD 1 and enter in to rescue mode)
* create partitions on it in exactly same way as the primary hard disk.
* copy corresponding partitions from primary hard disk to secondary hard disk (remember to use cp with options -avxf which will handle links)
* run lilo/grub boot loader on the secondary hard disk (chroot ; grub-install )

now you should be able to boot back with ur backup harddisk.

You can also use any rescue utilities like Ghost has its own linux edition. you can also use HP's RDP product which can do this and much more.

Regards,
Gopi
Never Never Never Giveup
Steven E. Protter
Exalted Contributor

Re: hard disk clonning!

I've been pretty successfull using Ghost. I've even gotten away with using whole disk replication using the Windows product.

Mondorescue has good long term possibilities as well.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
rveri
Super Advisor
Solution

Re: hard disk clonning!

Hi Ajay ,

For cloning linux disk , you can use own dd command , thats best for linix and unix.

Example:
-------

If you have filesystems like that :

Device Boot Start End Blocks Id System
/dev/sda1 1 9 72261 83 HPFS/NTFS
/dev/sda2 10 75 530145 82 Linux swap
/dev/sda3 76 467 3148740 fd Linux raid autodetect
/dev/sda4 468 2200 13920322+ 83 Linux
---------------------------------
And if you have a similar 2nd disk connected as sdb (IDE or SCSI).

you can do as follows:

1. Partition second disk sdb identical :


Device Boot Start End Blocks Id System
/dev/sdb1 1 9 72261 83 HPFS/NTFS
/dev/sdb2 10 75 530145 82 Linux swap
/dev/sdb3 76 467 3148740 fd Linux raid autodetect
/dev/sdb4 468 2200 13920322+ 83 Linux

2. Run the dd command:
a. copy MBR.
dd if=/dev/sda of=/dev/sdb bs=446 count=1

b. clone rest partition except swap , no need to copy swap , as its raw.
dd if=/dev/sda1 of=/dev/sdb1
dd if=/dev/sda3 of=/dev/sdb3
------------------------------
This may help you.

Cheers,

Raj.



Raj D.
Honored Contributor

Re: hard disk clonning!

Ajay ,

Simply dd it and check if it works , Data will transfer not not sure about booting..

1. Create identical partition.
2. dd if=/dev/sda of=/dev/sdb bs=446 count=1 ( MBR copy).

3.
dd if=/dev/sda1 of=/dev/sdb1
skip sda2 ( swap )
dd if=/dev/sda3 of=/dev/sdb3
dd if=/dev/sda4 of=/dev/sdb4.
-------------------------------
Remember it will take time to clone..

HTH.
RajD.
-----
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: hard disk clonning!

Hi Ajay ,

Have you done the disk cloning in linux , got any luck.
Pls update ..

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
ajay_25
Occasional Contributor

Re: hard disk clonning!

Hi friends,
I really appreciate your help.

1st of all i followed RAJ&RAJD's solution .that works gr8.
I created identical partitions as like my 1st harddisk using fdisk coammand in my 2nd harddisk .
After that I used dd command to copy MBR and other partitions to the 2nd harddisk.
i booted through 2nd harddisk. It was successfully booted. but what about swap partition? Anyway i created swap partition manually.

Gopi! what are the benefits in the way you suggested instead of using dd command. Here also I need to create the partitions exactly same way, as the primary hardisk isn├в t it? I need a bit clarity.

Next I will try Gopi,peter and stevens suggestions and get back to you guys.

If you help me in this way for a few months I will be an expert in Linux soon. LOL.

Thanks a lot guys.
ajay

Gopi Sekar
Honored Contributor

Re: hard disk clonning!


The only and main distinctive advantage of my suggestion is the procedure can be used on any type and size of the hard disk. Incase of dd if you are having 40GB source disk then you should have 40GB destination disk (minimum) for replication to work successfully.

In my suggestion you can have 80 GB or 20GB destination disk and it will work properly.

Hope i am clear this time,
Gopi
Never Never Never Giveup
Sudeesh
Respected Contributor

Re: hard disk clonning!

Hi Ajay,
I had used ghost for clonning linux disks and was successful. You need to do a disk to disk clone.

Sudeesh
The most predictable thing in life is its unpredictability