4

I have attempted to expand the volume of an Ubuntu 18.04 server running on vmware. LVM is in use. I shut it down, expanded the virtual disk in vmware, and powered it up. I then used cfdisk to resize the 40GB /dev/sda3 to the max of 199GB. That went fine.

Output of cfdisk after reboot:    
/dev/sda1 = 1M
/dev/sda2 = 1G
/dev/sda3 = 199G

I then ran df -h

Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              798M  1.1M  797M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   39G  4.0G   33G  11% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/8268
/dev/loop1                          92M   92M     0 100% /snap/core/8592
/dev/sda2                          976M  145M  765M  16% /boot
tmpfs                              798M     0  798M   0% /run/user/1000

I know I need to expand /dev/mapper/ubuntu--vg-ubuntu--lv so I tried

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.44.1 (24-Mar-2018)
The filesystem is already 10222592 (4k) blocks long.  Nothing to do!

Output of 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               <39.00 GiB
  PE Size               4.00 MiB
  Total PE              9983
  Alloc PE / Size       9983 / <39.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               TXiMWd-sKCj-2nJc-yEZY-ZudW-DMOh-G2qc6d

Output of pvdisplay

--- Physical volume ---
  PV Name               /dev/sda3
  VG Name               ubuntu-vg
  PV Size               <39.00 GiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              9983
  Free PE               0
  Allocated PE          9983
  PV UUID               rmuSVO-uUCF-iKiA-0v8Q-IScl-zvHd-jfAzMn

I also tried

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv                                                                                                                  
New size (9983 extents) matches existing size (9983 extents).

So my issue is that in cfdisk, it says /sda3 is 199G. However I can't figure out how to extend

/dev/mapper/ubuntu--vg-ubuntu--lv   39G  4.0G   33G  11% /

to fill the remaining ~160GB space on /sda3.

I would greatly appreciate any guidance. I was following the "faster method" here: Increase partition size on which Ubuntu is installed?

And now I seem to be stuck.

I should add that I also tried this, but it doesn't seem to like it on a mounted filesystem.

vgextend ubuntu-vg /dev/sda3
Can't open /dev/sda3 exclusively.  Mounted filesystem?
0

1 Answer 1

7

I got it! :)

I had to run pvresize command. As soon as I ran

pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
root@xxxxx:~# pvdisplay                                                                                                                                                       
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               ubuntu-vg
  PV Size               <199.00 GiB / not usable 16.50 KiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              50943
  Free PE               40960
  Allocated PE          9983
  PV UUID               rmuSVO-uUCF-iKiA-0v8Q-IScl-zvHd-jfAzMn

root@xxxxx:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv                                                                                                                  
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <39.00 GiB (9983 extents) to <199.00 GiB (50943 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

All was looking good but df -h still showed:

Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              798M  1.1M  797M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   39G  4.0G   33G  11% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/8268
/dev/loop1                          92M   92M     0 100% /snap/core/8592
/dev/sda2                          976M  145M  765M  16% /boot
tmpfs                              798M     0  798M   0% /run/user/1000

So I then ran

root@xxxxxx:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 25
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 52165632 (4k) blocks long.

and finally!

root@xxxxx:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              798M  1.1M  797M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  196G  4.0G  184G   3% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/8268
/dev/loop1                          92M   92M     0 100% /snap/core/8592
/dev/sda2                          976M  145M  765M  16% /boot
tmpfs                              798M     0  798M   0% /run/user/1000

Hopefully this helps someone else.

2
  • Spot on! I have had exactly the same problem for almost a year now, this really helped me! Hat off!
    – Hauns TM
    Apr 20, 2021 at 13:22
  • Thank you for this. I was stuck in the same spot and this worked for me. I'm on Proxmox instead of VMWare for anyone else in the same spot after walking through these steps: pve.proxmox.com/wiki/Resize_disks May 2, 2022 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .