[CentOS] Replacing a hard drive

Wed Mar 14 21:46:07 UTC 2007
John Summerfield <debian at herakles.homelinux.org>

John R Pierce wrote:

> I'm assuming you're using straight ext3 without LVM or raid....

Good point. A while ago I copied an 80 Gb drive to existing partitions 
on 120 Gb. The source didn't use LVM, the destination did.

I got it working, but I couldn't describe what I did with any reliability.

> I'd probably boot the regular CD into rescue mode, without mounting the 
> file systems, then partition the new disk to suit (making each partition 
> at least as large as the original drive, and in the same order, then run 
> something like....
> this assumes new drive is hda, old drive is hdb
> mkdir /mnt/src /mnt/dst
> for f in 1 2 5 6; do
>    mount /dev/hdb$f /mnt/src
>    mount /dev/hda$f /mnt/dst
>    dump 0f - /mnt/src | (cd /mnt/dst; restore rf - )
>    umount /mnt/dst /mnt/src
> end
> mkswap /dev/hda3
> mount /dev/hda2 /mnt/dst && mount /dev/hda1 /mnt/dst/boot
> chroot /mnt/dst
> grub-install /dev/hda
> ^z
> umount /mnt/dsk/boot; umount /mnt/dsk
> adjust file and device names to suit.     dump to restore like that 
> creates a very accurate copy of a file system, complete with special 
> files, links, ACLs, permissions, etc, etc intact.

And presumably, fairly quickly. I've never used dump/restore, but if it 
does the obvious and decides which blocks top copy, sorts the list then 
copies, it should be quickest of all, regardless of the data content.

> now, swap the new drive
> (where 1, 2, 5, 6 are your file system partitions, leaving out your swap 
> which I'm guessing is hda3)
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos



-- spambait
1aaaaaaa at coco.merseine.nu  Z1aaaaaaa at coco.merseine.nu

Please do not reply off-list