CentOS 7 guest on XS6.5 - Growing Hard Disk



  • In my effort to keep the size of my VMs at bay, I typically size the virtual disks to a reasonable size I feel will serve the role the VM will play. There are times where my estimate is off and I need to grow the disk. Not a big deal, I've done it many times without issue.

    This came up with a CentOS 7 VM last night. No biggie, I've done this many times. The process I use is exactly as follows:

    • Shut down the VM.
    • Extend the disk. In this case I grew the disk from 20 GB to 100 GB
    • Start the VM.
    • Run "fdisk /dev/xvda"
    • In my case there are only two partitions. /dev/xvda1 which is /boot and /dev/xvda2 which is /. So I delete /dev/xvda2
    • Recreate /dev/xvda2 making sure to utilize all available space on the disk.
    • Reboot the VM.
    • Run "pvresize /dev/xvda2".
    • Run "lvextend -l 100%FREE -r /dev/mapper/centos-root".

    When I've done this in the past, it has gone flawlessly. The physical volume expands to the added space and the logical volume then expands to the added space.

    However, this time around, it didn't exactly do that.

    The physical volume expanded completely, but the logical volume did not. I'm not sure why.

    Output of pvdisplay:

    alt text

    Output of lvdisplay:

    alt text

    If my math is correct, 2 GiB plus 67.51 GiB does not come close to the size of the physical volume (99.51 GiB).

    What am I missing?



  • It looks like you forgot to extend the VG before resizing the LV.



  • This post is deleted!


  • @momurda From what I understand, vgextend is for adding additional volumes to the group. I simply grew the size of the existing volume. When doing this, I haven't ever had to touch anything related to the VG. Besides, if that was the case, wouldn't the LV not grow at all? It most certainly grew from it's original ~18 GiB (don't know what it was in GiB exactly, but it was 18 GB for sure) to the current 67.51 GiB



  • What is the output of lsblk fdisk -l and vgdisplay



  • @momurda

    lsblk output:

    0_1504126610325_Selection_124.png

    fdisk -l output:

    0_1504126617241_Selection_125.png

    vgdisplay output:

    0_1504126626307_Selection_126.png



  • I would try this
    lvextend -l +100%FREE /dev/mapper/centos-root
    Your vg still has 30GB unallocated. Not sure why



  • @momurda Huh.

    lvextend -l +100%FREE -r /dev/mapper/centos-root

    Seems to have done it.

    I swear I ran the command multiple times. I suspect I was missing the "+" on "+100%FREE". I wonder what the difference is?



  • @anthonyh said in CentOS 7 guest on XS6.5 - Growing Hard Disk:

    @momurda Huh.

    lvextend -l +100%FREE -r /dev/mapper/centos-root

    Seems to have done it.

    I swear I ran the command multiple times. I suspect I was missing the "+" on "+100%FREE". I wonder what the difference is?

    When creating an logical volume, you tell it how much space to use. While when making a change to the logical volume you need to tell it how much to add or remove. Thus the + or - when using lvchange, but not needed with lvcreate.


Log in to reply