I have a virtual machine that recently had its disk image increased from 20GB to 50GB, and fdisk -l
verifies that the VM can see this new size. Now I need to resize my root LVM partition to fill the extra 30GB.
I've found several articles about resizing LVM, but the few that cover resizing the root partition all claim you need to boot from a LiveCD. Is there any way to do this without taking down the server? The server is critical, so I'd like to minimize downtime.
Edit: Output of fdisk -l
:
[root@fedora-host ~]# sudo fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00097c90
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 83886079 41430016 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 36.1 GB, 36104568832 bytes
255 heads, 63 sectors/track, 4389 cylinders, total 70516736 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table
Disk /dev/mapper/VolGroup-lv_swap: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 cylinders, total 12320768 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table
Edit: How do I resize the physical partition? fdisk can see the free space, but I don't know how to resize primary LVM partition to use it. I tried booting into a LiveCD and using parted'd resize
command, but all it gives me is the error "Unable to detect file system". I found this guide, which says I need to delete the partition and create a new one with the correct size, but that sounds very dangerous.
Final Edit: Parted's resize
command is oddly unable to resize LVM partitions. Go figure. Instead, I simply deleted the old partition and created a new one with the new range, as outlined in the link above, and that correctly resized the LVM partition. I then followed the advice below to resize the volumes and filesystems inside the LVM partition.
Best Answer
You can grow a logical volume online. You'd have to unmount it to shrink it (which requires a LiveCD / Rescue Mode.)
pvresize /dev/sda2
(assuming your LVM partition issda2
. Replace as required.)lvextend /dev/mapper/root -l+100%FREE
(or, whatever your root logical volume is called.)resize2fs /dev/mapper/root
(assuming ext2/3/4)