In a nutshell, i have a VM that ran out of space. I increased the size of the VM's harddrive to be 4 times bigger but the OS partition is still only using 1x the space. I need to change the LVM partition to take up the extra 4x space but I don't know how to extend the LVM partition.
(NOTE: To make the screenshots given below I had to boot from a live-cd for gnome-partition-manager (aka gparted). Very unfortunately gparted is only able to "detect LVM" and can't do any LVM operations.)
Here is what "gparted" shows. Please notice that the "resize" option is not available:
The Problem:
I can't find good directions<1> on how to grow the LVM partition via GUI or command-line! How do you grow a LVM partition that was created by the default Fedora install?
If you are giving command line directions. Please explain what each line of commands does.
Answer
I thought I used to do this with system-config-lvm GUI tool in CentOS, but it's not working for me today. So I had to go old school. As always, this might destroy your data, so MAKE A BACKUP!! Thanks to experts across the internet for providing these hints. Unfortunately my notes do not include attribution details. Note I performed all of these changes while the system was live.
- Enlarge the disk using fdisk
fdisk -l
(to see the partition layout, typically we're dealing with /dev/sda2)fdisk /dev/sda
d
(delete a partition)2
(if the part we want to grow is /dev/sda2; note this does not delete any data on disk)n
(create a new partition)p
(primary partition)2
(default starting block, typically 14 since swap is first)
(default ending block, full size of the partition)- make sure partition type is 8e for Linux LVM
t
8e
w
(write changes to disk)
- reboot to get new partition table
pvresize /dev/sda2
pvscan
should show new larger sizelvextend -l +100%FREE /dev/vg_centos6/lv_root
(-L +10G to add 10GB is another option)resize2fs /dev/vg_centos6/lv_root
df
should show new free space
No comments:
Post a Comment