3

I would like to know exactly what du and df mean.

The following is an example of the output of the df command.

Filesystem      Size  Used Avail Use% Mounted on
ubi0:rootfs     435M  424M   12M  98% /
devtmpfs         88M  4.0K   88M   1% /dev
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           248M  8.4M  240M   4% /run
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs           248M     0  248M   0% /tmp
tmpfs           248M   72K  248M   1% /var/volatile

And here's the output of du (run in the / directory)

 $ du -sh home
    255M    home
 $ du -sh usr
    264M    usr

I thought that ubi0:rootfs included /home and /usr, but the sum of them, 519M, is larger than the ubi0:rootfs size, 435M.

The result of the free command is as follows.

              total        used        free      shared  buff/cache   available
Mem:           495M         55M         50M        8.4M        389M        420M
Swap:            0B          0B          0B

At first I thought the difference is due to ramdisk, but the free command shows RAM is not used so much.

What is the exact difference between du and df (or is the /usr dir special)?

marked as duplicate by Kusalananda, Romeo Ninov, EightBitTony, terdon Dec 15 '17 at 11:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What filesystem? – muru Dec 15 '17 at 7:46
  • The fs is ubifs installed on NAND. – user8257918 Dec 15 '17 at 8:34
  • In that case, you should check ubifs docs to see if classic tools like df and du can even produce meaningful values for it. This is not the case for some modern filesystems, like btrfs, for example. Otherwise you'd be trying to make sense out of garbage output. – muru Dec 15 '17 at 8:37
  • 1
    Directory "/home" can contain hardlinks to files in "/usr"? – LXA Dec 15 '17 at 8:40
  • What do you get with du -shc home usr (that is one du invocation for both)? What du implementation is it? – Stéphane Chazelas Dec 15 '17 at 11:22

Browse other questions tagged or ask your own question.