Disk space numbers don't add up - LVM question from an intermediate user

My HP Omen laptop has the following specs:

256GB NVME SSD drive (But only 238 GB available)
1TB Mechanical SATA drive

Its a dual boot. The laptop came with Windows 10 Home OEM installed and I installed Fedora 29 (later upgraded to Fedora 30) .

I used Logical Volume Mananagement for my Fedora.

For faster performance, I installed the Fedora OS in a volume group created out of my NVME drive.
For my personal data, I created a VG named fedora_homevg out of my mechanical SATA partition (/dev/sda3) as shown below. /home/sysadmin/Ddrive is where I keep my files (Movies, Pictures, music files, documents, …etc)

[root@localhost ~]# pvs
  PV             VG            Fmt  Attr PSize   PFree
  /dev/nvme0n1p7 fedora_rootvg lvm2 a--  102.00g 4.00m
  /dev/sda3      fedora_homevg lvm2 a--  668.00g 4.00m

As shown in the df output, I allocated nearly 650GB for the logical volume /dev/mapper/fedora_homevg-home.
df output shows 595GB has been used. So, the available free space should be 54 GB (649GB - 595GB).
But the df output shows only 22GB available for /dev/mapper/fedora_homevg-home. Any idea why this discrepancy ?

Info for diagnosis:

[sysadmin@localhost ~]$ uname -a
Linux localhost.localdomain 5.0.17-300.fc30.x86_64 #1 SMP Mon May 20 15:36:26 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[sysadmin@localhost ~]$ 
[sysadmin@localhost ~]$ 
[sysadmin@localhost ~]$ cat /etc/fedora-release 
Fedora release 30 (Thirty)

[root@localhost ~]# df -PTh
Filesystem                     Type      Size  Used Avail Use% Mounted on
devtmpfs                       devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs                          tmpfs     7.8G  136M  7.7G   2% /dev/shm
tmpfs                          tmpfs     7.8G  2.1M  7.8G   1% /run
tmpfs                          tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/fedora_rootvg-root ext4      100G   19G   77G  20% /
/dev/nvme0n1p6                 ext4      976M  223M  687M  25% /boot
/dev/nvme0n1p5                 vfat      511M   18M  494M   4% /boot/efi
/dev/mapper/fedora_homevg-tmp  ext4      7.9G   37M  7.4G   1% /tmp
/dev/mapper/fedora_homevg-home ext4      649G  595G   22G  97% /home
tmpfs                          tmpfs     1.6G   24K  1.6G   1% /run/user/42
tmpfs                          tmpfs     1.6G   72K  1.6G   1% /run/user/1000
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# lsblk
sda                      8:0    0 931.5G  0 disk 
├─sda1                   8:1    0 248.9G  0 part 
├─sda2                   8:2    0  12.7G  0 part 
└─sda3                   8:3    0   668G  0 part 
  ├─fedora_homevg-home 253:1    0   660G  0 lvm  /home
  └─fedora_homevg-tmp  253:2    0     8G  0 lvm  /tmp
nvme0n1                259:0    0 238.5G  0 disk 
├─nvme0n1p1            259:1    0   260M  0 part 
├─nvme0n1p2            259:2    0    16M  0 part 
├─nvme0n1p3            259:3    0 132.2G  0 part 
├─nvme0n1p4            259:4    0   980M  0 part 
├─nvme0n1p5            259:5    0   512M  0 part /boot/efi
├─nvme0n1p6            259:6    0     1G  0 part /boot
└─nvme0n1p7            259:7    0   102G  0 part 
  └─fedora_rootvg-root 253:0    0   102G  0 lvm  /
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# pvs
  PV             VG            Fmt  Attr PSize   PFree
  /dev/nvme0n1p7 fedora_rootvg lvm2 a--  102.00g 4.00m
  /dev/sda3      fedora_homevg lvm2 a--  668.00g 4.00m
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# vgs
  VG            #PV #LV #SN Attr   VSize   VFree
  fedora_homevg   1   2   0 wz--n- 668.00g 4.00m
  fedora_rootvg   1   1   0 wz--n- 102.00g 4.00m
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# lvs
  LV   VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home fedora_homevg -wi-ao---- 660.00g                                                    
  tmp  fedora_homevg -wi-ao----   8.00g                                                    
  root fedora_rootvg -wi-ao---- 102.00g                                                    
[root@localhost ~]# 
[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          15915        3238        8729         189        3947       12163
Swap:             0           0           0 

Trash is empty

Although not relevant, I am posting Windows 10 disk info as well.

Chances are it’s confusion due to mixed use of IEC and SI units. Some utilities use SI, others use IEC, by default. It doesn’t matter which one you use as long as it’s consistent.

I’m biased toward IEC because 512 bytes and 4096 bytes are the most common minimum amounts for (logical) sectors and pages. Really only storage venders report product totals in SI because it makes drives appear bigger than they are.

1 Like

@chrismurphy, although difference in units are a common cause for confusion and a good thing to keep in mind, I believe it’s not the culprit here.

The discrepancy @msullivan talks about is in the report of df -h:

[root@localhost ~]# df -PTh
Filesystem                     Type      Size  Used Avail Use% Mounted on
/dev/mapper/fedora_homevg-home ext4      649G  595G   22G  97% /home

– and we can count on df to report all the sizes it shows us in the same units.

I’m 90% sure the lost 32G are the reserved space on ext4 partition. From man tune2fs:

-m reserved-blocks-percentage

Set the percentage of the filesystem which may only be allocated by privileged
processes. Reserving some number of filesystem blocks for use by privileged
processes is done to avoid filesystem fragmentation, and to allow system daemons,
such as syslogd(8), to continue to function correctly after non-privileged processes
are prevented from writing to the filesystem. Normally, the default percentage
of reserved blocks is 5%.

I think some better explanation can be found of why some space needs to be reserved, I don’t have the links handy – although the quote gives us some clue. Also you would find a great deal of discussion online about do we need this at all, and can we use smaller amount, and how to reduce the amount reserved.

I myself usually leave it as is – the default 5 percent – at least when I’m not hard pressed for space, – though we’re using a free OS, so everyone can decide for himself – and face the consequences for himself, if any should arise )) Although the risks of shrinking reserved space for /home should be much lower then doing the same for root partition.

@msullivan, I digress from the exact question you ask – but i believe the topics I mention are often the next question asked when talking about reserved space on ext partitions. Back to your question.

To do a quick check: 5% of 649G is 32,45G, and

32,45G (reserved) + 22G (free) + 595G (used) ==  649,45G

To do a finer math you can use

sudo tune2fs -l /dev/mapper/fedora_homevg-home | grep -i "reserved"

to get a reserved blocks count, and

sudo tune2fs -l /dev/mapper/fedora_homevg-home | grep -i "block size"

to get a block size (in bytes, I believe), then do the conversion to gigabytes yourself.

You can also get the “Block count” for filesystem size, and “Free blocks” for free space from tune2fs -l as well for even finer check.