[CentOS] Re: How to upgrade hard drive in a single drive (with LVM2) computer

Wed Jan 4 00:02:28 UTC 2006
Barry L. Kline <blkline at attglobal.net>

Bryan J. Smith wrote:
> "Barry L. Kline" <blkline at attglobal.net> wrote:
> 
>>Hi Bryan.
>>I gave that a shot, but I get the error:
>>/dev/mapper/vg1-sysroot does not have any corresponding
>>BIOS drive.
> 
> 
> Okay, now we're getting somewhere.
> 
> First off, you did chroot, correct?

Yes.

> 
> Secondly, how was /dev/mapper/vg0-sysroot setup on the old
> system?

It was /dev/mapper/vg0-lvsysroot -- I renamed it when I created it.

> 
> Is the rescue mode creating a /dev/mapper/(whatever)?

Yes

> 
> In a nutshell, GRUB must understand how to load the root at
> boot.  It would really help if you'd post your old _and_ new
> /boot/grub/grub.conf and /boot/grub/device.map files as well
> as _detail_ your _exact_ disk arrangements.
> 

I needed to put the system back online again.  That being the case, 
things are going to get out of sync with the new drive, so I'm going to 
start from scratch and try the migration again later tonight.

That being said,  here's the procedure I'm going to use:

* Install new hard drive and boot from old hard disk into
   single user mode.
* Duplicate partitioning on the new drive from the old drive
	100 Mb boot,  1G swap,  remainder LVM (all primary parts)
* Format the /boot partition:   mkfs.ext3 -L BOOT1 /dev/hdd1
         (assuming that's where the drive ends up.)
* Activate swap:  mkswap /dev/hdd2
* Set up the LVM partition as a physical volume: pvcreate /dev/hdd3
* Create a new volume group: vgcreate vg1 /dev/hdd3
* And activate it: vgchange -ay vg1
* Create and format two partitions in the LV:
   lvcreate -L10G -n sysroot vg1 ; mkfs.ext3 /dev/mapper/vg1-sysroot
   lvcreate -L20G -n home    vg1 ; mkfs.ext3 /dev/mapper/vg1-home
* Create mount points for the new partitions and mount them:
   mkdir /mnt/sysroot ; mount /dev/mapper/vg1-sysroot /mnt/sysroot
   mkdir /mnt/sysroot/home ; mount /dev/mapper/vg1-home /mnt/sysroot/home
* Now copy of the data:
   tar -cf- -X EXCLUDE / | (cd /mnt/sysroot ; tar -xf- -p -s)
      Where EXCLUDE contains:  mnt/* proc/* sys/* tmp/*
* Shut down the system, disconnect original drive, replace it with the
   new drive
* Boot into rescue mode, chroot /mnt/sysimage
* Edit /boot/grub/grub.conf to changes instances of
   'vg0' to 'vg1'
* Edit /etc/fstab to ensure things are pointing to the right place
* Run:  grub-install /dev/hda
* shut the system down, reboot to HD and pray that things come up.

Does this sound reasonable?

Thanks again Brian!

Barry