Skip to content

Instantly share code, notes, and snippets.

@ishworgurung
Created July 7, 2012 00:43
Show Gist options
  • Save ishworgurung/3063622 to your computer and use it in GitHub Desktop.
Save ishworgurung/3063622 to your computer and use it in GitHub Desktop.
Increase partition size using lvm2
No need to reboot!!!!1
0. df -ih / df -h on the linux guest
1. Increase your physical disk space from the hypervisor on the host machine.
2. Create a logical partition of the free space from the linux guest making sure that you write the partition table out.
$ cfdisk /dev/sdb
3. Drop back to the shell and do a partprobe to re-read the partition table so the kernel knows about the new logical partition. If new partition is not showing up, then you'll need to reboot (Debian & Ubuntu should be fine. But Fedora and CentOS has given me issue on this)
$ partprobe
4. Extend our Volume Group to include the new partition. Below we have sdb7 as the new logical partition created in step 2. Replace it for your own need.
$ vgextend <volume group name identified using vgdisplay> /dev/sdb7
5. Identify the number of free extents
$ vgdisplay (keep note of the number in "Free PE")
6. lvextend -l +<Free PE from step 5> /dev/<volume name from step 4>/<name of the partition e.g. root>
7. resize2fs /dev/<volume name from step 4>/<name of the partition e.g. root>
8. df -ih / df -h on the linux guest
Done!!!!!1 ;)
Reference: http://linuxconfig.org/Linux_lvm_-_Logical_Volume_Manager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment