Expand LVM guest filesystem VMware

First, increase the size of the virtual disk (VMDK) by 10GB for example

vmware-vdiskmanager -x 10GB /path/machineName.vmdk

(vCenter users can increase disk sizes easier via the Settings dialog of the VM)

# fdisk /dev/sda 
Command action
   e   extended
   p   primary partition (1-4)
Partition nr

Take defaults as from here

First cylinder (1045-2610, default 1045):
Using default value 1045
Last cylinder or +size or +sizeM or +sizeK (1045-2610, default 2610):
Using default value 2610

Change a partition’s system id

Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.


# partprobe -s
/dev/sda: msdos partitions 1 2 3

Create PV

# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

Extend VG with new partition

# vgextend VolGroup00 /dev/sda3
  Volume group "VolGroup00" successfully extended

Extend LV to maximum available

# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 17.88 GB
  Logical volume LogVol00 successfully resized
# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4685824 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4685824 blocks long.

Check the result

# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       18G  1.3G   16G   8% /
/dev/sda1              99M   14M   81M  14% /boot
tmpfs                 502M     0  502M   0% /dev/shm