How to extend LVM disks in vCenter

LVM disk extension can be a challenging experience for who are not familiar with unix environment.  I will try to explain it as simple as possible in this guide.

  • Heads up: You need to reboot the virtual machine twice! There is no live-extension way for LVM in vSphere environment.
  • If you want to do it live-extension, you need to add new VMDK hard disk to the VM and extend in the LVM console. I will write about that later.
  • This guide is based on Ubuntu 12.04 LTS.

 

1. Enter your VM’s “Edit Properties” menu. Choose your hard drive and give more space as you want:

haddisk

haddisk

2. In the same window, click “Options” tab, choose “Boot Options” and enable “Force BIOS Setup” on the right side:

biosboot

3. Click “OK”.

4. Go to g-parted web site and download the ISO file from there: http://gparted.org/

5. Right click on your VM and click “Open Console”. Click the “Connect CDROM” button on top right and choose “Connect to ISO image on local disk”.

bootfromcdrom

6. Choose your g-parted ISO file and click “OK”.

7. Now reboot your VM. You will see the BIOS screen. Go to “Boot” tab. Using UP-DOWN arrow select “CD-ROM drive” and bring it before Hard Drive using “+” sign on your keyboard. Go to Exit tab and select “Exit Saving Changes”. This will reboot your virtual machine.

biosscreen

8. You will see boot screen of g-parted. Click “Enter” for G-Parted Live. (You can hit Enter for default selections for 9-10-11 steps)

9. Choose “Don’t touch keymap” for Configuring console-data.

keymap

10. It will ask for language selection. Type your language number and hit Enter. Default is 33 (English).

language

11. Choose G-Parted mod, default is “0”.

mod

12. G-parted will boot and Device manager screen will be shown in the screen. Now select LVM device which’s File System is “extended”. It is /dev/sda2 in this example.  Click “Resize/Move” button on top.

gpartedmain

13. You will see a new popup resize screen.

gpartedmain2

14. Extend it by using scroll on the screen or by typing here. Click Resize/Move button. On main screen “Apply” button will be activated, click it to apply the configuration. It will ask again to be sure about it. After operation is successful, click “Close”. Exit the main screen and reboot your VM.

gpartedmain3

15. Your system will be boot normally, but you need to format the new size in order to use it in the LVM.

16. Check your disks in the OS, here are the some examples :

ls -al /dev/sda* output:

fdisk -l output:

As you can see we have sda5 device for LVM volume group.

17. We need to format and add the disk to sda.

Type:

Type “n” and “l” letters. Here we created /dev/sda6 (6 number is automatically selected by system):

Change the type of the file system to LVM:

Type “t”, “6” and “8e”   (We typed 6th device as we need to change sda6. 8e is the LVM type code)

Type “p” to check if it is correctly set:

Type “w” to write the changes and use q to quit:

As warning mantioned, we need to reboot the server.

After reboot, check if we can see the new device or not:

18. Create physical volume for sda6:

19. Add sda6 disk to Volume Group:

Check the name of the volume group

Extend the Volume group with sda6:

20. Extend the Logical Volume:

Check the logical volume:

Extend the logical volume using all free space in the volume group:

Check the mount points:

Thats it!