[CentOS] Upgrading to larger HD with LVM

Thu Dec 21 05:21:14 UTC 2006
Aleksandar Milivojevic <alex at milivojevic.org>

Paul wrote:
> What's the easiest way to transition to a larger HD when using LVM2?  I'm
> running Centos 4.4.  I'm going from a 20gb HD to a 40gb HD.  I've already
> DD'd it to the 40gb HD.  So now I have 20gb of unused space.  Ideally, I'd
> like to make it one big physical space for the logical space instead of
> making another physical partition to expand the logical.  Here is what I
> have now with the system on hda, and with another HD of hdb for moving
> data if i need to:

You should let LVM do the move, not dd.  The last paragraph has some
advice what you might try to do since you already did dd thingie.  First
how you should have done it:

What you wanted to do is to leave first drive as is in the system.  Add
second drive, create new physical volume on it, and add it to the volume
group.  See manual pages for pvcreate and vgextend.  Than migrate all
extents from physical volume on the first drive to physical volume on
the second drive.  See manual page for pvmove command.  Once all extents
are migrated, you can remove physical volume that was on the first drive
(since all extents on it are free now), and after that remove first
drive from the system.  See manual page for pvremove command.  Other
than physical addition and/or removal of drives from the system, the
rest can be done while the system is up and all services on it running.

Once data is migrated, you can either create new logical volumes using
free space that you have (lvcreate).  Or you could expand existing
logical volumes (either lvextend or lvresize will do the job) and resize
filesystems (ext2online).  You are enlarging file systems, so you want
to do it in exactly this order, first extend logical volume, than extend
file system.  Since you are extending file system, this can be done
while the system is up and running and file system(s) mounted and in
use.  No need for downtime.

If you had anything outside of LVM on the old hard drive (for example
/boot partition was there), you'd have to move that separately by hand.
 The easiest way would be to simply create new partition for it on new
drive, than dump/restore /boot onto it.  You'd also need to handle boot
loader (LILO or Grub) separately if it was present on the drive you want
to remove.

Since you already did that dd thingie, you might also try simply
enlarging the partition used for physical volume, than use pvresize to
make physical volume use all the space on the partition.  Do note that
pvresize wasn't available in original CentOS 4, it was added in one of
the updates (to be more precise, command was there, but it would only
print out that it is not functional and than exit).  So if it is an old
system without updates, you'd need to update at least lvm2 related
packages and kernel to the latest versions before you could use
pvresize.  If it's CentOS 4.4 box you should be fine.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
URL: <http://lists.centos.org/pipermail/centos/attachments/20061220/f3e406fc/attachment-0005.sig>