1

I have a Ubuntu Server 20.04 running in a virtual machine. It started complaining that there was no enough space on "/" to run software update, so I followed this wonderful advice: Ubuntu Server 18.04 LVM out of space with improper default partitioning and raised the "/" size from 110 GiB to 173 GiB. Now, I am able to complete the update.

Still, by looking at $df -h output, it seems that I could get some more space freed up from other parts, but I am not sure how and if it is possible. I will appreciate any help!

Filesystem  Size    Used    Avail   Use%    Mounted_on
udev    3.9G    0   3.9G    0   /dev
tmpfs   796M    2.0M    794M    0.01    /run
/dev/mapper/ubuntu--vg-ubuntu--lv   170G    104G    59G     0.64    /
tmpfs   3.9G    16K     3.9G    0.01    /dev/shm
tmpfs   5.0M    0   5.0M    0   /run/lock
tmpfs   3.9G    0   3.9G    0   /sys/fs/cgroup
/dev/sda2   974M    215M    692M    0.24    /boot
/dev/mapper/ubuntu--vg-lv--1    49G     7.5G    39G     0.17    /var
/dev/loop0  9.0M    9.0M    0   1   /snap/canonical-livepatch/132
/dev/loop2  115M    115M    0   1   /snap/core/13886
/dev/loop1  9.0M    9.0M    0   1   /snap/canonical-livepatch/146
/dev/loop5  56M     56M     0   1   /snap/core18/2620
/dev/loop7  64M     64M     0   1   /snap/core20/1634
/dev/loop6  64M     64M     0   1   /snap/core20/1695
/dev/loop9  68M     68M     0   1   /snap/lxd/22753
/dev/loop10     48M     48M     0   1   /snap/snapd/17336
tmpfs   796M    32K     796M    0.01    /run/user/1000
tmpfs   796M    4.0K    796M    0.01    /run/user/130
tmpfs   796M    40K     796M    0.01    /run/user/128
/dev/loop12     50M     50M     0   1   /snap/snapd/17576
/dev/loop11     115M    115M    0   1   /snap/core/14056
/dev/loop3  56M     56M     0   1   /snap/core18/2632
/dev/loop4  92M     92M     0   1   /snap/lxd/23991
mcnubb
  • 11

1 Answers1

0

A quick win would be to set the reserved percentage for root of the drives to 0%.

sudo tune2fs /dev/sda -m 0

This will free up diskspace that is reserved for root at all times.

Or add diskspace to the VM or with hardware and expand the logical volume:

Use the set of lvm commands for that after creating the new partition.

First create the physical volume (pvcreate) Extend volume group (vgextend) Extend the logical volume (lvextend)

resize the filesystem.

As root:

fdisk /dev/sda (follow steps to create /dev/sda4 partition)
pvcreate /dev/sda4
vgextend ubuntu-vg /dev/sda4
lvextend -L+4.9G /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
Serve Laurijssen
  • 1,208
  • 2
  • 8
  • 13
  • Thank you. I went with your suggestions and got to this step: "lvextend -L+4.9G /dev/mapper/ubuntu--vg-ubuntu--lv". Somehow, it gave me a long list like this:

    1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B, 2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F, 3 Intel Fast Flash D3BFE2DE-3DAF-11DF-BA40-E3A556D89593, 4 BIOS boot 21686148-6449-6E6F-744E-656564454649, etc.

    Do I need a space between -L+ and 4.9G? And is 4.9 all I need/can have? This is not too big. :)

    – mcnubb Nov 24 '22 at 17:17
  • The 5GB is just an example. You can add whatever size you have available. Read up on lvm to see what you can do with it and what the options mean – Serve Laurijssen Nov 25 '22 at 05:38
  • I see. So, since the only other place that seems to have enough (free) room is:

    /dev/mapper/ubuntu--vg-lv--1 49G 7.5G 39G 0.17 /var

    can I run, say "lvextend -L+30G /dev/mapper/ubuntu--vg-ubuntu--lv" and would it negatively affect anything?

    – mcnubb Nov 25 '22 at 19:04
  • And I am reading up on lvm, as you suggest, but there is a learning curve involved, so I apologize for dumb questions! – mcnubb Nov 25 '22 at 19:24
  • you will have to add the spavce somewhere by adding a harddrive for instance – Serve Laurijssen Nov 28 '22 at 15:00