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
  • 234,489
  • 66
  • 447
  • 667
  • 1
    `fdisk` shows the size of partitions, `df` shows the size of filesystems – Jaromanda X Mar 19 '23 at 21:46
  • Does this answer your question? [What's the difference between fdisk -l and df -h?](https://unix.stackexchange.com/questions/96262/whats-the-difference-between-fdisk-l-and-df-h) – Eduardo Trápani Mar 19 '23 at 23:31
  • It might, but none of the answers are useful. – Thomas Dickey Mar 20 '23 at 00:30
  • the fact that fdisk tells you `/dev/sda2` is 27G and df tells you `/dev/sda2` is 474M - suggests your sda2 partition is 27G in size, but the filesystem created on it is only 474M – Jaromanda X Mar 20 '23 at 06:20
  • @JaromandaX Is there a way to extend the filesystem? – Vavřinec Kubíček Mar 20 '23 at 08:21
  • @VavřinecKubíček: That depends on the filesystem, also whether the filesystem has to be off-line on can be online. We don't have any indication of what filesystem is used, so it's hard to say if that is an option in this case. – Henrik supports the community Mar 20 '23 at 08:30
  • the fact that it's a so called "live" system may be an issue. usually such systems are for evaluation and/or trouble shooting, so, aren't made to be expanded, but YMMV – Jaromanda X Mar 20 '23 at 09:08

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
  • 234,489
  • 66
  • 447
  • 667
Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268