1

I'm running an Ubuntu Server VPS (nothing serious on there, just something for me to mess around with), that I installed when it only had one virtual disk of 20 GB. I have since upgraded the size of that volume to 20 GB. I was using LVM and I though it'd be easy to increase the size of the main volume to encompass the entire virtual drive. I tried that using the lvextend command. It did extend it somewhat, but not to the amount I expected it to (in hindsight doing it in increments was probably stupid and unnecessary). Anyway, this is my current situation:

df -h shows:

Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              797M  936K  796M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   19G  3.1G   15G  18% /
tmpfs                              3.9G  4.0K  3.9G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda2                          976M  100M  810M  11% /boot
/dev/loop0                          67M   67M     0 100% /snap/lxd/13300
/dev/loop1                          92M   92M     0 100% /snap/core/8592
/dev/loop2                          55M   55M     0 100% /snap/lxd/12211
/dev/loop3                          90M   90M     0 100% /snap/core/8268
tmpfs                              797M     0  797M   0% /run/user/1000

parted -l shows:

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 20.4GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  20.4GB  20.4GB  ext4


Model: Virtio Block Device (virtblk)
Disk /dev/vda: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  1076MB  1074MB  ext4
 3      1076MB  21.5GB  20.4GB

The parted -l result shows that there is a 53.7 GB device recognized, but just below that it says that it has a size of approx. 20 GB, with the results of df -h coming to a total of roughly 33 GB (no idea how).

Is there a reasonable way to fix this, or should I just give up and re-install?

2 Answers 2

2

Here is my case (working in "sudo -i"). I have 200GiB of disk space on my VM but for an unknown and obscure reason the LVM is only 4GiB.

Here is my config :

root@server:/media# pvs
  PV         VG        Fmt  Attr PSize    PFree
  /dev/sda3  ubuntu-vg lvm2 a--  <199,00g <195,00g

root@mgc-com-1:/media# vgs
  VG        #PV #LV #SN Attr   VSize    VFree
  ubuntu-vg   1   1   0 wz--n- <199,00g <195,00g

root@mgc-com-1:/media# lvs
  LV        VG        Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 4,00g

root@mgc-com-1:/media# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1,9G     0  1,9G   0% /dev
tmpfs                              394M  1,1M  393M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3,9G  3,7G     0 100% /
tmpfs                              2,0G     0  2,0G   0% /dev/shm
tmpfs                              5,0M     0  5,0M   0% /run/lock
tmpfs                              2,0G     0  2,0G   0% /sys/fs/cgroup
/dev/sda2                          976M  197M  713M  22% /boot
/dev/loop0                          55M   55M     0 100% /snap/core18/1705
/dev/loop1                          55M   55M     0 100% /snap/core18/1754
/dev/loop4                          28M   28M     0 100% /snap/snapd/7264
/dev/loop5                          30M   30M     0 100% /snap/snapd/8140
/dev/loop6                          72M   72M     0 100% /snap/lxd/15753
tmpfs                              394M     0  394M   0% /run/user/1001
/dev/loop2                          72M   72M     0 100% /snap/lxd/15855
tmpfs                              394M     0  394M   0% /run/user/1000

root@mgc-com-1:/media# fdisk -l /dev/sda
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Disk model: iSCSI Storage
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: 2241A764-D647-41CE-BCE0-214F46D67BBD

Device       Start       End   Sectors  Size Type
/dev/sda1     2048      4095      2048    1M BIOS boot
/dev/sda2     4096   2101247   2097152    1G Linux filesystem
/dev/sda3  2101248 419428351 417327104  199G Linux filesystem

The following commands were working fine :

root@mgc-com-1:/media# lvextend /dev/ubuntu-vg/ubuntu-lv /dev/sda3 

Size of logical volume ubuntu-vg/ubuntu-lv changed from 4,00 GiB (1024 extents) to <199,00 GiB (50943 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized.

root@mgc-com-1:/media# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 25 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 52165632 (4k) blocks long.

Now with fdisk -l I get entire space used.

/dev/mapper/ubuntu--vg-ubuntu--lv 196G 3,8G 185G 2% /

Thanks @wiglaf-pimwick.

2
  • Thanks, this worked for me on ubuntu 20.04
    – Rob
    Dec 21, 2021 at 20:11
  • ok, so vote up please @Rob ;-)
    – Meloman
    Dec 23, 2021 at 21:20
1

Did you try

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

after the lvextend?

2
  • Yes, I did. Sadly, the output is: The filesystem is already 4974592 (4k) blocks long. Nothing to do!
    – Patriot
    Feb 12, 2020 at 10:06
  • working for me, I detailed my answer here under.
    – Meloman
    Jun 30, 2020 at 7:17

You must log in to answer this question.

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