This howto is mostly built on the great tutorial available at http://www.comnetslash.com/…hout-reboot/. My spot tries to be more Ubuntu and LVM specific. This manual was tested on Ubuntu 9.04 (jaunty) Server edition guest OS.
Add Virtual Hard Disk
A new hard disk can be added easily to a running virtual machine in VMWare Infrastructure Web Access by clicking Add Hardware and following the wizard.
Note: I assume that all of the commands given are run under superuser (root) rights. To become root type
sudo su root
Detect new SCSI Disk
The package scsitools provides the script rescan-scsi-bus.sh, which does exacly what we need. Install it and run it:
apt-get install scsitools rescan-scsi-bus.sh
This should detect the newly added hard disk and make it available in
/dev/sdb in the case you are adding a new
drive for the first time. The output of
fdisk -l should include the
newly detected disk.
Format the new disk
Format the newly detected drive using fdisk
fdisk /dev/sdb n (for new partition) p (for primary partition) 1 (partition number) (keep the other values default) w (write changes)
Change the type of the partition to LVM Linux:
fdisk /dev/sdb t (change the partition type) 8e (for Linux LVM) w (write changes)
Initialize LVM Physical Volume
Add Physical Volume to Volume Group
List the Volume groups available at your machine.
Replace VolGroupName with what you read from the output of the last command.
vgextend VolGroupName /dev/sdb1
You should see the newly aquired free space in the output of
Resize Logical Volumes
After adding some free space to your Volume Group, you can distribute it to the Logical Volumes. The list of Logical Volumes can be obtained by running
Run the following commands for each Logical Volume you want to resize (add space to). Again – replace /dev/VolGroupName/Name with the Logical Volume name you can read from the output of the last command. The +10G means Add 10 GB
lvextend -L +10G /dev/VolGroupName/Name
The last step is to resize the ext3 filesystem (use different tool is you use different filesystem):