Why is my disk space reading so differently with du and lsblk?

0
17
Asked By CuriousCat42 On

I'm having a frustrating issue with my setup on a Raspberry Pi 4. My Nextcloud and Paperless services went down due to a 503 error, and when I checked the disk space, I found my SD card is nearly full. The `lsblk -f` command shows the following: mmcblk0 has 91% used, while `du -hx --max-depth 1 / | sort -rh` reports only 7.5G used on the root directory. I've deleted some data, yet I seem to be missing about 40G. I've already checked for files that are still open after deletion, but I'm stuck on how to further investigate where this extra space is being consumed. Any tips on what could be causing this discrepancy?

3 Answers

Answered By TechSavvyDave On

It's quite common to have files that are deleted but still open by a process. As long as the inode is held, those blocks will still occupy space. You might want to check for any processes that have these files open using `lsof`. You can run:

lsof -nP | grep '(deleted)'

This should help you identify if there's anything lingering around that you can address.

Answered By FileWhisperer On

Have you considered the possibility of sparse files? They can sometimes cause discrepancies in reported usage because they only consume space for the actual data written, not the entire allocated size. You could check this by using commands that reveal the actual disk usage of such files.

Answered By DiskHacker88 On

You might want to check if you accidentally mounted your SD card over a directory with existing data. If you mounted it over a directory that had files, that data is hidden but still using up the space on your SD card. Try checking the mount points or unmounting and then looking at the directories to see if there's hidden data consuming space.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.