简体   繁体   中英

du linux command size greater than df

I am using Digi embedded linux module which is having 8MB flash and 16MB RAM.

My partition table is as below:

在此处输入图片说明

SO, I got 4.4MB for rootfs. And 2MB for UserFS.

When I run 'df -ah', I get following output.

在此处输入图片说明

However, when I run 'du -sh' on root, I have 4M in /lib and 3M in /usr. Both are under root. However, the root is only 4.4M.

I have checked for symbolic link and can confirm that the files are physically present on /lib and /usr.

在此处输入图片说明

I deleted some of the library files( netsnmp ) under /lib, which was close to 2M, but the available size on /dev/root only increased by ~390K(from 408K to 792K).

在此处输入图片说明

This suggests that the /lib/libnetsnmp* were stored somewhere else. I am not sure where those files were saved. Any ideas?

Also, please note that the rootfs image size is 4M. And this is shown correctly in df -ah command on /dev/root filesystem.

JFFS2 has transparent compression built in if I recall correctly. Executables compress pretty well.

if the file is in use. you can't delete it really. you can use lsof | grep deleted lsof | grep deleted to find them.

Probably it is due to the existence of hard-links in the root filesystem. Each hard-link will be shown as a normal file, but all hard-links will point to the same inode, so physically there is only one copy of the file in the hard-disk. You can see a good definition of soft-link and hard-link in this link .

EDIT: You can search for hard-links using this command (taken from this answer ):

find . -samefile /path/to/file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM