20071212 resizing a vmware disk - plembo/onemoretech GitHub Wiki

title: Resizing a VMWare disk link: https://onemoretech.wordpress.com/2007/12/12/resizing-a-vmware-disk/ author: lembobro description: post_id: 591 created: 2007/12/12 18:18:49 created_gmt: 2007/12/12 18:18:49 comment_status: open post_name: resizing-a-vmware-disk status: publish post_type: post

Resizing a VMWare disk

Working on testing yet another Oracle product and found the disk in my target virtual machine running under VMWare Server (formerly called GSX Server) was full.

Resizing (growing) a VMWare Server disk is pretty easy, but making that extra space usable takes some doing. My test virtual machines are all CentOS 4, using the default partitioning scheme that creates a small /boot partition and the balance of the disk (/) in one big Logical Volume (โ€LVโ€, /dev/Volgroup00/LogVol00) using the Logical Volume Manager (โ€LVMโ€).

All the following steps are performed as root.

  1. Power down the vm.
  2. Use the vmware-vdiskmanager command with the โ€œ-xโ€ switch, specifying the size which you want the disk to be able to grow to and the target disk name. For example:

vmware-vdiskmanager -x 25Gb mydisk.vmdk

  1. Power up the vm and verify the new max size.
  2. With the vm up and running, run fdisk (/sbin/fdisk /dev/sda). Dropping a โ€˜pโ€™ should print your partition table. The LV should be the second partition. Itโ€™s type will be โ€œ8eโ€, Linux LVM. Delete this partition by dropping a โ€˜dโ€™ and designating โ€˜2โ€ฒ as the partition number to delete. Now immediately drop an โ€˜nโ€™ to add this partition back in, accepting the defaults to use all available physical disk. Make sure to change the โ€œnewโ€ disk partition type to โ€˜8eโ€™ by dropping a โ€˜tโ€™ (this all works because all youโ€™re doing is changing the partition table to increase the size of the partition, your data isnโ€™t affected because the partition still starts at the same point). Finally, use a โ€˜wโ€™ to save the change.
  3. Reboot the virtual machine to effectuate the partition table change.
  4. Run pvresize to make the extra disk visible to LVM.

pvresize /dev/sda2

  1. Verify LVM can see the additional physical disk by running vgdisplay.
  2. Use lvextend to grow the LV into this space.

lvextend -L22G /dev/VolGroup00/LogVol00

You may need to play around with the size (alas, in a downward direction), because what vgdisplay shows is not exactly right. 9. Resize the filesystem on the fly using ext2online. The syntax will be ext2online [mountpoint] along with any switches (like โ€˜-vโ€™ for verbose).

ext2online -v /

Restart the machine again and verify the volume is now larger, using du -h.

Copyright 2004-2019 Phil Lembo