I have a virtual server under VMware, where I got 10 more GB harddisk from the sysadm.
Inside Linux (running Ubuntu 11.04 server), things are set up with LVM. In [c]fdisk, I do find these extra 10 gigs - they are present directly after the primary LVM partition.
I understand that I could make a new LVM partition out of this extra space, and then add this to the volume group, and then to the logical volume, and then resize the filesystem.
However, is it possible to assimilate these extra gigs into the existing LVM partition? So that the LVM's view of the physical volume increased instead of adding another physical volume into the volume group (preferably automatically percolating up to the volume group)?
I just built a test virtual machine with a 15GB disk and LVM on /dev/sda2. Then I grew the disk to 20GB and made LVM see the extra 5GB without adding another physical volume.
Here are the steps I followed:
I had to use gfdisk to make the whole thing work. No luck with the "standard" fdisk.
Switch to "sectors" as the unit (this is critical!!!) and print the partition table:
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): p
Disk /dev/sda: 21 GB, 21089617920 bytes
255 heads, 63 sectors/track, 2564 cylinders, total 41190660 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 257008 83 Linux
Warning: Partition 1 does not end on cylinder boundary.
/dev/sda2 501758 29798632 14643247 8e Linux LVM
Warning: Partition 2 does not end on cylinder boundary.
Command (m for help):
Write down the "start" sector of the "Linux LVM" partition (/dev/vda2). Delete the partition and recreate it using the same "start" sector (501758) and the same partition type (8e):
Command (m for help): d
Partition number (1-2): 2
Command (m for help): n
Partition type
e extended
p primary partition (1-4)
p
First sector (default 63s): 501758
Last sector or +size or +sizeMB or +sizeKB (default 41190659s):
Command (m for help): p
Disk /dev/sda: 21 GB, 21089617920 bytes
255 heads, 63 sectors/track, 2564 cylinders, total 41190660 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 257008 83 Linux
Warning: Partition 1 does not end on cylinder boundary.
/dev/sda2 501758 41190659 20338290 83 Linux
Command (m for help): t
Partition number (1-2): 2
Hex code (type L to list codes): 8e
Changed type of partition 2 to 8e (Linux LVM)
Command (m for help):
WARNING: please note that I didn't accept the default start sector for the partition, I entered it manually so that it matches the original value! I did accept the default value for the "last sector" though, because I want this partition to be as large as the disk.
Verify that you did everything correctly with "p" and write the new partition table to disk:
Command (m for help): w
Reboot the virtual machine. Now log-in the virtual machine and run:
root@git:~# pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
Done! Now run vgdisplay and you will see the extra 5GB available as free extents.
CAVEATS: