Assumptions made:
You must have basic knowledge of LVM to follow the instruction.
Linux Environment : I have done this on SLES 11; However the LVM commands used are the generic Linux commands. Thus, this instruction should work on wide flavors of Linux.
Volume Group (VG) name: testvg
Logical Volume(LV) name: testlv
Root file system is on /dev/testvg/testlv file system and I want to increase the file system size by 5 GB.
Step1: Provision an extra disk space to the Virtual Machine [ i.e Increase the VMDK size of the VM via vSphere client if you are on VMWare environment]
# pvcreate <partition_name>
If you get an error reporting that system can't see the partition, reboot the Virtual Machine.
And re-run the pvcreate command once the system is back up.
Note: You can run #vgdisplay command to check what Volume Groups are available
Note: You can run #lvdisplay command to check what logical volumes are available
Step5: Extend the Logical Volume [ Say increase by 5GB ]
#lvextend -L +5G /dev/<vgname>/<lvname> <partition_name>
Warning!!! Check if a space is free in the physical volume or not. You can run the command #pvdisplay and check how much free space is available in the physical partition.
Step6: Resize the file system
#resize2fs /dev/<vgname>/<lvname>
You must have basic knowledge of LVM to follow the instruction.
Linux Environment : I have done this on SLES 11; However the LVM commands used are the generic Linux commands. Thus, this instruction should work on wide flavors of Linux.
Volume Group (VG) name: testvg
Logical Volume(LV) name: testlv
Root file system is on /dev/testvg/testlv file system and I want to increase the file system size by 5 GB.
Step1: Provision an extra disk space to the Virtual Machine [ i.e Increase the VMDK size of the VM via vSphere client if you are on VMWare environment]
[Note: If you provision an additional disk (some VMs doesn't allow to increase the VMDK size), check if you can see that additional disk. Say an additional disk is /dev/sdb. Then, run the command #fdisk -l . It should show /dev/sdb. If you cannot see /dev/sdb, then reboot the system and run #fdisk -l command again]
Step2: Partition the additional disk
space you just added [ Say your system sees disk as /dev/sda ]
# fdisk /dev/sda
# fdisk /dev/sda
- Create a new partition (primary if possible) Let's say /dev/sda4
- Define size
- Change the partition type from 83 (EXT3) to 8e (LVM)
- Write the change
# pvcreate <partition_name>
If you get an error reporting that system can't see the partition, reboot the Virtual Machine.
And re-run the pvcreate command once the system is back up.
Note: You can run #vgdisplay command to check what Volume Groups are available
Step4: Extend the Volume Group [ i.e Add the physical volume we just created to the existing volume group]
# vgextend <vgname> <partition_name>
Note: You can run #lvdisplay command to check what logical volumes are available
Step5: Extend the Logical Volume [ Say increase by 5GB ]
#lvextend -L +5G /dev/<vgname>/<lvname> <partition_name>
Warning!!! Check if a space is free in the physical volume or not. You can run the command #pvdisplay and check how much free space is available in the physical partition.
Step6: Resize the file system
#resize2fs /dev/<vgname>/<lvname>
Note: If resizze2fs doesn't work, reboot the system. For example: SLES 10 doesn't support online resize of the mounted file-system. Thus, SLES10 requires reboot after 'lvextend' of root file-system.
Validate if the size of the file system has been increased or not.
#df -h
Best of Luck!