2

What is the best practice in expanding a linux partition in VMWare? My example scenario would be: I have an /storage partition initially setup with 100GB. In the course of 6 months, I am required to add an additional 200GB to that partition. Is LVM the right way to go for disk expansions? Will there be any fragmentation problems if the 100GB and 200GB resides on two separate disks?

--John

4 Answers 4

5

While having two different .vmdk's on different disks acting as two LVM extents isn't perhaps the perfect way of doing this I wouldn't worry about it one bit. Certainly it'll work just fine, I don't believe fragmentation will be significantly more than if it were one disk.

3

How is your filesystem currently laid-out on the VMDK files? Is your largest partition (/storage) the last partition on the drive? Or is it on a separate VMDK file? The right process in either of those cases would be to shut down the virtual machine. Edit the machine's configuration from your VMWare client and expand the VMDK file to the desired total size. Boot your system and use the appropriate resizing tool for your filesystem, (e.g. xfs_growfs for XFS, resize2fs for ext2/ext3).

1

That's the way I'm doing that now with LVM.

With your VM create:

Disk1 - /OS = 20gb for example Disk2 - /storage = 100gb for your application (LVM)

Depending on your OS, it will probably use some LVM by default for the OS.

Then at some point you can increase the size of Disk2 to 200gb in the VM properties, add the extra 100gb to your LVM Volume Group, and then you can increase the size of the Logical Volume /storage

1

A: If your .vmdk is thin-provisioned, you're able to enlarge the .vmdk file, even while the VM is running (with vSphere 4, that is).

Say you didn't use LVM, but have a single partition that filled the whole disk (/dev/sda1):

  • First resize the partition in the partition table (using parted or fdisk) to fill the enlarged disk. You probably have to reboot your guest first in order to realize the size change of the disk.

  • Then, use resize2fs (xfs_growfs) to resize the file system to use the enlarged partition.

If you're using LVM, you might then just enlarge your physical volume:

  • Resize the physical volume (pvresize)
  • Enlarge the logical volume (lvresize)
  • Finally, resize the file system (resize2fs or xfs_growfs).

B: If your .vmdk is thick-provisioned, though, it's not possible to enlarge the .vmdk file. In this case, you'll have to add another disk (i.e. .vmdk file) to the VM in order to gain more disk space.

If you didn't use LVM, your only option is to partition the new disk and mount it somewhere.

If you're using LVM, you'll add the new disk to your volume group:

  • Create a LVM partition on the new disk (fdisk)
  • Set it up as another physical volume (pvcreate)
  • Add this PV to the volume group (vgextend)
  • Enlarge the logical volume (lvresize)
  • Finally, resize the file system (resize2fs or xfs_growfs).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .