df very different than du and ncdu

Post Reply
itcoil
Posts: 33
Joined: Tue Oct 18, 2016 3:04 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 1 time
Contact:

df very different than du and ncdu

Post by itcoil »

On my C2 with a 32GB eMMC 'df -h' says /dev/mmcblk0p2 is 91% full but I can't find what is using the space because du shows what I believe to be the accurate number which is only 19G used, not 25G as df says. Anything I use to look deeper at what is allocating that space (like ncdu or du) does not show that space as being allocated, so how can I fix the problem and get 'df -h' to show the correct amount of free space?

Here is 'df -h'

Code: Select all

Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  734M     0  734M   0% /dev
tmpfs          tmpfs     172M   11M  161M   7% /run
/dev/mmcblk0p2 ext4       29G   25G  2.7G  91% /
tmpfs          tmpfs     858M   79M  780M  10% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs          tmpfs     858M     0  858M   0% /sys/fs/cgroup
/dev/mmcblk0p1 vfat      128M   18M  110M  14% /media/boot
tmpfs          tmpfs     172M     0  172M   0% /run/user/1000
but 'du -h /' says:
19G /

I would like to reclaim the lost 6G.

mad_ady
Posts: 9352
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 599 times
Been thanked: 649 times
Contact:

Re: df very different than du and ncdu

Post by mad_ady »

Have you rebooted? Most likely the allocated space is part of a deleted file that is still open. Try lsof | grep delete before reboot.

itcoil
Posts: 33
Joined: Tue Oct 18, 2016 3:04 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: df very different than du and ncdu

Post by itcoil »

I just tried 'lsof | delete' and nothing was returned. Then I rebooted but I still have the same results as above. I have tried rebooting before.

mad_ady
Posts: 9352
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 599 times
Been thanked: 649 times
Contact:

Re: df very different than du and ncdu

Post by mad_ady »

Well, it could be lost space due to fragmentation caused by loads of very small files (<4k), but you'd need to have quite a lot of them to eat up 6G. Like 3 million 2kB files...

itcoil
Posts: 33
Joined: Tue Oct 18, 2016 3:04 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: df very different than du and ncdu

Post by itcoil »

Could it be related to the following? Sometimes I mount a directory on the C2 as an NFS drive, from another computer (a Pi), and I have moved many GB into the C2 directory and also deleted the GB when the C2 directory was mounted as an NFS drive. The way I deleted them was by dragging them to the trash in the GUI on the Pi and then emptying the trash. Is there any chance that the C2 still thinks they are in its memory? If so are there any steps I could take to clear up the confusion?

mad_ady
Posts: 9352
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 599 times
Been thanked: 649 times
Contact:

Re: df very different than du and ncdu

Post by mad_ady »

You should see deleted files (things that are in .Trash for instance) in du...
You can also try to run a fsck on the partition (offline) and see maybe there is lost space due to filesystem issues...
These users thanked the author mad_ady for the post (total 2):
odroid (Thu Apr 01, 2021 9:34 am) • itcoil (Fri Apr 02, 2021 1:01 am)

itcoil
Posts: 33
Joined: Tue Oct 18, 2016 3:04 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: df very different than du and ncdu

Post by itcoil »

Running fsck on the partition (offline) seems to have solved the issue. 'df -h' now shows all the open space that 'du' does.
Thank you for your help.
These users thanked the author itcoil for the post:
odroid (Thu Apr 01, 2021 9:34 am)

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 1 guest