1

Basically title. I'm running MX Linux from a 32GB live USB. When I run fdisk -l, I see the following:

[...]
Disk /dev/sda: 29.88 GiB, 32080200192 bytes, 62656641 sectors
Disk model: Flash Drive     
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: dos
Disk identifier: 0x0067f9ad

Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 6033541 6031494 2.9G c W95 FAT32 (LBA) /dev/sda2 6033542 62656618 56623077 27G 83 Linux

[...]

However, with df -lh, my sda2 is suddenly much smaller:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       2.9G  2.9G   53M  99% /live/boot-dev
/dev/loop0      1.8G  1.8G     0 100% /live/linux
/dev/loop1      474M  417M   29M  94% /live/persist-root
/dev/sda2       474M  417M   29M  94% /
/dev/loop2      201M  164M   23M  88% /home
[...]

Why does this happen and how can I fix it?

terdon
  • 242,166

1 Answers1

4

fdisk shows the total number of disk blocks, while df shows the available space on the file system which is set up on that device. A file system has overhead, i.e., part of the disk is set aside to improve performance — which you would never see. Some of that is reserved for the root user, and some (depending on the filesystem) may be counted separately for the inode resources.

Both fdisk and df look at sizes, but the former looks at partitions (actual disk blocks), while the latter looks at filesystems (which are constructed in a partition). The mount program would show what type of filesystem is in use. Some are limited (but that 474M is rather small). It could have been created by a script which specifies the size (see mkfs manual),

mkfs [options] [-t type] [fs-options] device [size]

or copied (using dd) from a master image on the media.

Further reading:

terdon
  • 242,166
Thomas Dickey
  • 76,765