3
# df -h Filesystem Size Used Avail Use% Mounted on /dev/root 4.3G 1.9G 2.2G 47% / devtmpfs 980M 0 980M 0% /dev tmpfs 981M 0 981M 0% /dev/shm tmpfs 981M 33M 948M 4% /run tmpfs 981M 0 981M 0% /sys/fs/cgroup tmpfs 981M 0 981M 0% /tmp tmpfs 981M 16K 981M 1% /var/volatile 
# fdisk -l Disk /dev/mmcblk1: 7.3 GiB, 7818182656 bytes, 15269888 sectors 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: gpt Disk identifier: Device Start End Sectors Size Type /dev/mmcblk1p1 16384 24575 8192 4M unknown /dev/mmcblk1p2 24576 32767 8192 4M unknown /dev/mmcblk1p3 32768 69859 37092 18.1M unknown /dev/mmcblk1p4 81920 15269854 15187935 7.2G unknown 

The image is built with yocto.
I would expect /dev/root to have a size of 7.2GB but it shows only 4.3GB.
Could anyone explain the reasons why df -h shows less disk space for /dev/root than board actually has (compared to fdisk)?

1 Answer 1

4

Could anyone explain the reasons why df -h shows less disk space for /dev/root than board actually has (compared to fdisk)?

4.3G is the size of the filesystem mounted under /. 7.2G is the size of /dev/mmcblk1p4 which is a block device, a partition of /dev/mmcblk1(?).

Filesystems and block devices are different concepts (compare this answer of mine). A filesystem usually exists inside some block device. It may be smaller than the block device; such situation is totally possible and most likely the case here.

Note nothing in your question really indicates the filesystem mounted under / exists directly or indirectly inside /dev/mmcblk1p4. df associates it with /dev/root which may be a symlink to /dev/mmcblk1p4; it may be something else though.

There may be an additional layer (or even layers) between mmcblk1p4 and /dev/root, e.g. LVM.

Check ls -l /dev/root. If it shows you root -> mmcblk1p4 then yes, the filesystem mounted under / lives directly in /dev/mmcblk1p4 but its size is smaller. If /dev/root is something else then further investigation is required.

The rest of this answer assumes /dev/root is a symlink to /dev/mmcblk1p4.

There are tools to enlarge filesystems. First you need to know the filesystem type. Invoke mount and examine the relevant entry. It will look like this:

/dev/root on / type <type> … 

<type> will tell you the filesystem type. Next:

  1. Pick the right tool (resize2fs for ext2/ext3/ext4, btrfs filesystem resize for btrfs, …).
  2. Read the manual.
  3. Check if the tool supports enlarging a mounted filesystem. btrfs filesystem resize requires the filesystem to be mounted. resize2fs allows it to be mounted when enlarging. Tools specific to other types may require the filesystem to be unmounted; in this case you cannot resize what is mounted as /.
  4. Enlarge the filesystem. Some tools can automatically check the size of the underlying block device and make the filesystem take all available space, if asked to. Check the manual for the right syntax.

I cannot give you one exact command to enlarge because I don't know your exact setup. Anyway, my answer to the explicit question you asked ("why does df -h show less disk space?") is: because df deals with filesystems while fdisk deals with block devices; filesystems and block devices are different concepts.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.