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.
- Power down the vm.
- 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
- Power up the vm and verify the new max size.
- 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. - Reboot the virtual machine to effectuate the partition table change.
- Run
pvresize
to make the extra disk visible to LVM.
pvresize /dev/sda2
- Verify LVM can see the additional physical disk by running
vgdisplay
. - 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