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