[CentOS] Transferring system to new drive

Lamar Owen lowen at pari.edu
Wed Sep 29 11:19:50 EDT 2010

On Thursday, September 16, 2010 01:43:19 pm Timothy Murphy wrote:
> Lamar Owen wrote:
> > When a server simply has to have minimal downtime, LVM is worth its LoC in
> > gold for this use.

> What do you mean by "no downtime"?
> What exactly do you do?
> Is it documented anywhere?

Sorry for the delay; been too busy to read CentOS mailing list.

By 'no downtime' I mean moving to a new disk while the system is running.  I did this with a Fedora 12 SPARC (beta) system (Sun Enterprise 6500 with 18 CPUs and 20GB of RAM, two diffSCSI channels to a D1000 SCSI storage shelf, six 36GB 10KRPM SCSI drives in each half of the D1000) a while back; the F12 SPARC beta has some real install issues that only work out right when you don't do anything custom.  So the root filesystem went to a single drive when I really wanted it on a RAID 6 MD.  The procedure I used is documented in the LVM HOWTO ( http://tldp.org/HOWTO/LVM-HOWTO/ ), specifically see section 13.5.2.  In my case the target physical volume was /dev/md0 which was separately built with mdadm by hand.

This won't get /boot; but that's fairly safe to copy while mounted.  Essentially you can set up the new disk's partitions, dd over the MBR boot code and the other areas your boot loader needs, copy over everything in /boot to the new boot partition, since /boot can't be on LVM with GRUB 1, then make the new physical volume on the new drive and add it to the volume group that contains your root filesystem.  Do note that if you have swap on a logical volume, you have to deactivate it before the pvmove or the kernel will panic.  

The pvmove from one physical volume to the other uses the power of LVM to make this 'just work' like an EMC Clariion would work when doing LUN migrations between RAID groups.  It does take a while, and the system will be slower while pvmove is doing its thing, but the only downtime required will be when you reboot to boot off of the new /boot partition.

But pvmove is a MOVE, not a copy, so the data is gone from the source drive when you're done; that can be a downside in some use cases.  

More information about the CentOS mailing list