Penguin-polar-bear-symbols

Resize Linux LVM with live server

This is here mostly for me since figuring out how to do it took forever and combined bits-n-pieces of instruction from no fewer than 4 different web sites. I’m not really driven by documenting technical “how to’s” online in the hopes of generating ad revenue, but if this helps you, great.

The scenario is this: I have a personal ESX 3.5 server that has a few VMs running, mostly Windows. Playing with Ubuntu Server and Nagios, I found that the hard disk I created for the vm was too small once I started installing stuff. I’m a stingy bastard and don’t necessarily have all that much space on the ESX host so a 2Gb vmdk is about all I was interested in using.

The problem is that Ubuntu didn’t create standard, run-of-the-mill volumes and used something called an LVM (which I still don’t even care to know the definition of). Resizing one of these fuckers is no easy task. Well… it actually isn’t that hard, but finding straight forward information on how to do it was a real bitch. Site after site after site I looked at until I pieced together enough information to get it done.

Bare metal: VMWare ESX 3.5 U5
Virtual machine: Ubuntu Server 10.04 LTS
Original Disk: 2Gb
New Disk: 3Gb (again, because I’m a stingy bastard)

1. Using the VI3 client, shut down the VM and change the size of the disk. Restart the VM. SSH or use the console to login to the Linux VM as all further commands are to be done on the running VM.
2. fdisk -l (that’s an “L”, to list the existing partitions)
2. fdisk /dev/sda (assuming single vmdk)
3. n (for new)
4. p (for primary)
5. # (partition number depending on which one is next. Mine was 3.)
6. t (change the type. it will ask which partition #)
7. 8e (Linux LVM)
8. p (if you want to view changes before committing)
9. w (commit the changes and exit fdisk)
10. pvcreate /dev/sda# (# of the partition you just created. fdisk -l if you forgot already. This will create a new physical disk.)
11. vgextend your_volume_group /dev/sda# (adds the physical disk to the volume group)
12. Then pick up the instructions here from number 4

For reference, here are links to the different sites I used to come up with this article…

Leave a Reply

Your email address will not be published. Required fields are marked *