On 5/7/05, Todd Walton <[EMAIL PROTECTED]> wrote:
> I have two hard drives.  One is a 4GB and I'm replacing it with a 40
> GB.  I already have everything I need on the 4GB, but I want the new
> one to be the sole hard drive in the computer.  Right now I have the 4
> as /dev/hda and the 40 as /dev/hdb.  The 4 has three partitions;
> /dev/hda2 is swap, so it doesn't matter.  How can get all the info on
> /dev/hda1 to be on /dev/hdb1 and /dev/hda3 to be on /dev/hdb3?
> 
> I was reaching for dd, a command I'm a little unfamiliar with, but
> then I got to wondering about the filesystem underneath.  Would 'dd
> if=/dev/hda1 of=/dev/hdb1' work?  Should I already have a filesystem
> on /dev/hdb1 or no?  The man page doesn't help on this issue.

dd by itself won't do it because it will not change the size of the
underlying file system to fit the size of the new disk drive.

Boot to single user, so you know nothing else is going on.
Copy the boot block and partition table from the old disk to the new one.
# dd if=/dev/hda of=/dev/hdb count=1

Use fdisk to make partitions to taste on hdb.  
# fdisk /dev/hdb           # note fdisk will start out with a copy of the
                                   # old partition table, change it to fit
Use mkfs.ext3 to build file systems on hdb1 and hdb3.
Use mkswap to format hdb2 as a swap partition.

Use dump piped to restore to transfer the information.

# mount /dev/hdb1 /mnt
# dump 0f - /dev/hda1 | (cd /mnt; restore xf -)
# umount /mnt
# mount /dev/hdb3 /mnt
# dump 0f - /dev/hda3 | (cd /mnt; restore xf -)
# umount /mnt

Shut down the system, swap the disk cables, and go.

    carl
-- 
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to