Cloning a drive under linux.

Cloning a drive under linux.

Post by Wyver » Fri, 22 Jun 2001 06:15:38



Hi,

I want to clone a hard disk to another hard disk in the same system, and
keep the partition structure. I would also like the cloned hard drive to be
bootable, just like the main one, so I have a 'hard copy' that I can put on
a shelf somewhere.

A simple dd doesn't do the trick... I tried 'dd if=/dev/hda of=/dev/hdb' and
it appeared to work but I think the fact that the second hard drive is
larger than the first one is affecting things, because I can't see any of
the partitions after the dd on the second drive.

Any suggestions?

Thanks,

Jan Van Uytven

 
 
 

Cloning a drive under linux.

Post by N. Yeama » Fri, 22 Jun 2001 08:25:10



Quote:> Hi,

> I want to clone a hard disk to another hard disk in the same system, and
> keep the partition structure. I would also like the cloned hard drive to be
> bootable, just like the main one, so I have a 'hard copy' that I can put on
> a shelf somewhere.

> A simple dd doesn't do the trick... I tried 'dd if=/dev/hda of=/dev/hdb' and
> it appeared to work but I think the fact that the second hard drive is
> larger than the first one is affecting things, because I can't see any of
> the partitions after the dd on the second drive.

> Any suggestions?

Copying the whole image doesn't really work for hard drives that
are different sizes (and perhaps even ones that are the same size,
but from different vendors or are different models)  There is data
stored on the first sector that contains information about the
size/geometry of the drive.  Just copying it from another drive is
probably confusing the BIOS and/or Linux.  That is probably why
you can't see the partitions on the second drive.

Try making partitions on the second drive that are the *exact* same
size as the partitions on the first using fdisk.  If it is not
possible to make the partitions the exact size as the first, (if
the cylinder sizes are different) you'll have to make them slightly
larger and you'll lose a little bit of space.  Then dd for each
partition.  To make the second drive bootable, mount the
corresponding root partition (and any other partitions necessary
for lilo) somewhere, then run 'lilo -r /your-mount-point'

For example, if you had a /boot partition as #1, and your root (/)
was partition 2, then the procedure might look something like this:

(run fdisk/cfdisk and create your partitions on hdb)
dd if=/dev/hda1 of=/dev/hdb1
dd if=/dev/hda2 of=/dev/hdb2
...
mount -t ext2 /dev/hdb2 /mnt
mount -t ext2 /dev/hdb1 /mnt/boot
lilo -r /mnt

You can always use mkfs and cp -a to copy the data instead.  It
may take longer, but you have less risk of messing things up with
a typo, and you will have more assurance that the filesystem is
properly sized for it's partitions.

And if you are intending to periodicly 'clone' your drive, it
shouldn't be to hard to create a script that parses either
/proc/partitions or (s)fdisk -l /dev/hda with awk or sed and
uses sfdisk to create the partitons on hdb, then creates the
filesystems and copies the data.  In fact, I imagine if you
look on freshmeat.net you may find a script/program that does
it for you.

--


 
 
 

Cloning a drive under linux.

Post by Mike Thar » Fri, 22 Jun 2001 12:53:10


If this is going to be for redundency, use RAID mirroring.



> > Hi,

> > I want to clone a hard disk to another hard disk in the same system, and
> > keep the partition structure. I would also like the cloned hard drive to
be
> > bootable, just like the main one, so I have a 'hard copy' that I can put
on
> > a shelf somewhere.

> > A simple dd doesn't do the trick... I tried 'dd if=/dev/hda of=/dev/hdb'
and
> > it appeared to work but I think the fact that the second hard drive is
> > larger than the first one is affecting things, because I can't see any
of
> > the partitions after the dd on the second drive.

> > Any suggestions?

> Copying the whole image doesn't really work for hard drives that
> are different sizes (and perhaps even ones that are the same size,
> but from different vendors or are different models)  There is data
> stored on the first sector that contains information about the
> size/geometry of the drive.  Just copying it from another drive is
> probably confusing the BIOS and/or Linux.  That is probably why
> you can't see the partitions on the second drive.

> Try making partitions on the second drive that are the *exact* same
> size as the partitions on the first using fdisk.  If it is not
> possible to make the partitions the exact size as the first, (if
> the cylinder sizes are different) you'll have to make them slightly
> larger and you'll lose a little bit of space.  Then dd for each
> partition.  To make the second drive bootable, mount the
> corresponding root partition (and any other partitions necessary
> for lilo) somewhere, then run 'lilo -r /your-mount-point'

> For example, if you had a /boot partition as #1, and your root (/)
> was partition 2, then the procedure might look something like this:

> (run fdisk/cfdisk and create your partitions on hdb)
> dd if=/dev/hda1 of=/dev/hdb1
> dd if=/dev/hda2 of=/dev/hdb2
> ...
> mount -t ext2 /dev/hdb2 /mnt
> mount -t ext2 /dev/hdb1 /mnt/boot
> lilo -r /mnt

> You can always use mkfs and cp -a to copy the data instead.  It
> may take longer, but you have less risk of messing things up with
> a typo, and you will have more assurance that the filesystem is
> properly sized for it's partitions.

> And if you are intending to periodicly 'clone' your drive, it
> shouldn't be to hard to create a script that parses either
> /proc/partitions or (s)fdisk -l /dev/hda with awk or sed and
> uses sfdisk to create the partitons on hdb, then creates the
> filesystems and copies the data.  In fact, I imagine if you
> look on freshmeat.net you may find a script/program that does
> it for you.

> --


 
 
 

Cloning a drive under linux.

Post by Jami » Fri, 22 Jun 2001 22:36:50


Hi,

I use partition image for linux http://www.partimage.org/

You can take exact copies of the partitions and then write then back, the
only thing I have to do is manually write out the partition table on the new
disk, (just copy it from fdisk on the original machine).

Write all the partitions to the new disk then boot from a boot floppy, and
run lilo, then you'll have an exact copy!

Jamie

 
 
 

1. Made a clone of Linux server and that clone is very ill....

There is sever with two identical disks. Let's call
them Disk_A and Disk_B. When Disk_A is connected
(only this one) to server everything is okey.
I have cloned Disk_A to identical Disk_B with
Norton Ghost, and then connected it to sever
exclusively. After restart I get Lilo error

"L 01 01 01 01".

Can you help me... I have searched Net, but
nothing have found... What should I do?

Leszek

2. ISA Modem isn't recognised?

3. Cloning Linux Drives

4. SLIP/PPP server , Where ?

5. Cloning a hard-drive with Linux and NT

6. can't run syslogd

7. Hard Drive cloning tool in linux

8. ***** Homegrown High Availability Solaris Print Server Solution. *****

9. Cloning a Hard-Drive in Linux

10. how to clone a linux hard drive?

11. Weird issues cloning a Linux system to new hard drive

12. Cloning LSM disks and using the clones on 5.1A

13. Cloning an AIX/Unix Drive