Re: Upgrading to larger HD with LVM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux