0

I need help to resize my LV: /dev/mapper/ubuntu--vg-ubuntu--lv

The ubuntu installation is a VM, and the disk has been expanded from 8 GB to 11 GB. How do I resize / expand the /dev/mapper/ubuntu--vg-ubuntu--lv volume?

sudo pvdisplay:

  --- Physical volume ---
  PV Name               /dev/vda3
  VG Name               ubuntu-vg
  PV Size               8.46 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              2166
  Free PE               503
  Allocated PE          1663
  PV UUID               fhw3L2-RTCL-wu3w-WovP-6pGF-iQjv-tujWKE

sudo vgdisplay:

--- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               8.46 GiB
  PE Size               4.00 MiB
  Total PE              2166
  Alloc PE / Size       1663 / <6.50 GiB
  Free  PE / Size       503 / 1.96 GiB
  VG UUID               ZTcc3J-A3jZ-olN4-rFGR-h40F-wqFD-c3hmCn

sudo lvdisplay:

  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                Q31Qia-F92v-te0V-P1fH-4SXv-3uB8-4889p0
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2021-10-02 09:59:32 +0200
  LV Status              available
  # open                 1
  LV Size                <6.50 GiB
  Current LE             1663
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

More info added:

GPT PMBR size mismatch (20971519 != 23068671) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/vda: 11 GiB, 11811160064 bytes, 23068672 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
Disklabel type: gpt
Disk identifier: 07C77B10-B73C-442D-9F03-A422017A6AE9

Device       Start      End  Sectors  Size Type
/dev/vda1     2048  1050623  1048576  512M EFI System
/dev/vda2  1050624  3147775  2097152    1G Linux filesystem
/dev/vda3  3147776 20899839 17752064  8.5G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 6.51 GiB, 6975127552 bytes, 13623296 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

When I try sudo lvextend -l 100%VG ubuntu-vg/ubuntu-lv I get:

/etc/lvm/archive/.lvm_outlineserver_26853_1055914493: write error failed: No space left on device

And when I try sudo fdisk -l /dev/mapper/ubuntu--vg-ubuntu--lv:

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 6.51 GiB, 6975127552 bytes, 13623296 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

and last when I try sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv I get:

resize2fs 1.45.5 (07-Jan-2020) The filesystem is already 1702912 (4k) blocks long. Nothing to do!

2
  • 1
    Could you please add the output of sudo pvdisplay, sudo vgdisplay and sudo lvdisplay to your question?
    – ridgy
    Nov 9, 2021 at 16:17
  • Of course, no problem. I just updated the question with pvdisplay, vgdisplay and lvdisplay
    – julianb
    Nov 10, 2021 at 11:32

1 Answer 1

0

I'm not really sure what you have done so far. The partition /dev/vda3 has been increased to 8.5 GB (which means 10GB of the disk are used), but the end of partition vda3 (20899839) is less than the end of the "physical" disk (23068672), see the output of fdisk -l. Maybe GPT PMBR size mismatch (20971519 != 23068671) gives some hint.

Anyway, parts of the LVM structures (pv and vg) are already reflecting the new size. What is missing is the size of the logical volume and the size of the filesystem. As you can see from pvdisplayand vgdisplay, there are 503 extents = 1.96 GiB still free.

So, first increase the size of the logical volume to that of the volume group:

sudo lvextend -l 100%VG ubuntu-vg/ubuntu-lv

fdisk -l /dev/mapper/ubuntu--vg-ubuntu--lv should then give you the new size of ~ 8.5 GB.

Now, increase the size of the filesystem to that of the logical volume (I suppose ext4 here for '/'; if it is a different filesystem, you will have to use a different command!):

sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

This is possible for a mounted filesystem, when the kernel supports it, which all recent kernels should do.

For more information, see man lvextend and man resize2fs. Or Please help me work out what is happening with the available space on my VM's LVM2 partition

3
  • Thank you, but I can't get this to work for some reason. I added more info to my question above after running the commands you specified.
    – julianb
    Nov 11, 2021 at 6:54
  • This worked, but I needed to delete some files first, so I could write the changes..
    – julianb
    Nov 11, 2021 at 18:10
  • You are right. Your root filesystem was 100% full, so writing LVM information was not possible. Sorry, I did not take that into account ....
    – ridgy
    Nov 11, 2021 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.