Ubuntu – Understanding free space / volumes on Ubuntu

disk-usagelvmpartitioning

I am new to Ubuntu. I am running 18.04 in a VM on ESXi 6.5, where I am running Docker containers. One of the apps I am running in docker is causing me some issues, one of which could be related to free disk space issues. The VM is configured for 30GB, thin provision.

Fdisk shows the disk at total 30GB as expected, but when I run df -h I am not seeing /dev/sda3 listed at all, only 2. Could someone kindly explain why this is the case?

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 62912511 60811264 29G Linux filesystem

Filesystem Size Used Avail Use% Mounted on
udev 464M 0 464M 0% /dev
tmpfs 99M 1.2M 98M 2% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 3.9G 3.4G 306M 92% /
tmpfs 493M 0 493M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 493M 0 493M 0% /sys/fs/cgroup
/dev/loop0 87M 87M 0 100% /snap/core/4917
/dev/loop1 98M 98M 0 100% /snap/docker/321
/dev/sda2 976M 142M 768M 16% /boot
/dev/loop2 88M 88M 0 100% /snap/core/5742
tmpfs 99M 0 99M 0% /run/user/1000

sudo parted -l shows the partitions correctly.

Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
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  32.2GB  31.1GB

as does lsblk.

NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0 86.9M  1 loop /snap/core/4917
loop1                       7:1    0 97.5M  1 loop /snap/docker/321
loop2                       7:2    0 87.9M  1 loop /snap/core/5742
sda                         8:0    0   30G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0   29G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    4G  0 lvm  /
sr0                        11:0    1 1024M  0 rom

Why does df not show the partition size?

Best Answer

According to your lsblk output, /dev/sda3 does not directly contain a filesystem but an LVM physical volume. It contains a logical volume called ubuntu--vg-ubuntu--lv which is shown by both lsblk and df and has the size of 3.9GB (or 4GB in dependence on rounding). The rest of the physical volume (i.e. partition) seems to be unused. When you call sudo pvs, the rest should be shown as free space (the PFree column).

You can extend your ubuntu--vg-ubuntu--lv volume (together with the filesystem in it) to fill the free space using the command

sudo lvextend -rl +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

or create another logical volume there.

Related Question