[mdlug] Linux VMs - virtual disk best practices

Jonathan Billings billings at negate.org
Thu Mar 21 09:22:31 EDT 2013


On Wed, Mar 20, 2013 at 11:54:32PM -0400, Michael ORourke wrote:
> So I'm curious to hear from some other admins out there and what you
> have tried and what seems to work best.

If you've got more than one partition, and you're not using LVM, if
you expand the size of the virtual disk, the only partition you can
easily expand is the last partition on the disk, and that's typically
an extended partition if you've got more than 4 partitions.  With LVM,
you can just make 2 partitions, one for /boot and one for the LVM
physical volume.  You can extend the physical volume to the new space
if the virtual disk size is increased, or if there's a new disk added,
you can add it as another physical volume.  Either way, the pool of
available space grows, and you can extend the logical volume of
whatever volume you want, and use your filesystem tools to resize the
filesystems.  ext3 and ext4 can be extended online (without a reboot
or even an unmount) if you've got a modern kernel, but most
documentation suggest unmounting the volume you plan to extend,
running fsck and then resizing, which definitely the safer option.

I don't have the ability to add storage while the OS is running on the
VMware VMs I manage (I don't run the VMware cluster) so it takes a
reboot for it to see the new storage anyway.  Most often, if I'm going
to be resizing a VM's disks, if it isn't / (root) that's being
resized, once it has been rebooted I just unmount the volumes and
perform the above operations, and then remount it.

However, I've resized partitions on running VMs, taking space from one
partition and giving it to another.  It is MUCH easier to do this if
you're using LVM.  The only reason I was able to do it with the
non-lvm system was because I was taking space away from /tmp and the
partition for /tmp was at the end of the disk and right after the
partition I wanted to add space to.  I just deleted /tmp and recreated
it after resizing the important volume.  Had it not been that way, I
would have had to reinstall. 

I think the hope is that btrfs will make this a lot easier, all
storage will just be part of a pool and you can reallocate it all
online without needing to jump through so many hoops.

-- 
Jonathan Billings <billings at negate.org>


More information about the mdlug mailing list