I cannot access ubuntu system on my pc, the error message: "the system is running in low graphics mode" and I tried some commands I searched from internet.
I found out a problems seems there is no available disk space. I used "df" and "du" commands to check, the results are as follow:
du -j --max-depth=1
23G ./home
3.3G ./usr
......
28Gand
df -Th
filesystem Type size used available use% mounted on
/dev/sda5 ext4 68G 68G 0 100% /how would I clean up the system for more disk space?
18 Answers
You most probably know that you can remove a file that still in use by some application and for this application it remains available. It because file descriptor in /proc/ filesystem is held open.
So if there are such open descriptors to files already removed, space occupied by them considered as used by df (and df is right), but they can not be taken into account by du due to there are no longer filenames associated with them.
You can find all unlinked but held open files with:
# lsof | grep '(deleted)' 5 How can i delete the links? – Vikas Hardia Aug 22 '14 at 5:46
You must find the the process which holds the file handle. Use the command of Dmitry Alexandrov, there you see the process and pid. In our case and "old" varnish log file was the space killer.
# lsof | grep '(deleted)'
[...]
varnishlo 13978 varnishlog 3w REG 252,1 318448027646 5926973 /var/log/varnish/varnish.log.1 (deleted)
apache2 16801 www-data 2w REG 252,1 64550 13110120 /var/log/apache2/error.log.1 (deleted)
[...]
# service varnishlog stop
[or if there is no service script]
# kill -11 13978 (the second number of the lsof command is the pid)
[or may be]
# kill -9 13978Don't forget to start the service or process again if it is a demon or some other service on your computer. If you can, just reboot the computer ;)
0Ok, lets check the man pages:
df - report file system disk space usage
and
du - estimate file space usage
Those two tools were meant for different propose. While df is to show the file system usage, du is to report the file space usage. du works from files while df works at filesystem level, reporting what the kernel says it has available. Continue reading the du manpage support this:
Summarize disk usage of each FILE, recursively for directories.
it says du works with files.
dfdisplays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.
here says that df do not care about the files but the filesystem itself.
dfSummarize free disk space
It displays the amount of disk space available .
duSummarize disk usage.
It displays the amount of disk space used.
2Simply said:
You ran du without root permissions. So it is not able to check the available space in /proc, /mnt, etc, folders.
df showed the total used & free space respectively.
So when you check the Linux root file system, take the du report as final.
nothing that much confusing : Here is look :=
1) du == Disk Usage
How much disk space is being used by these files?
2) df == Disk Free
How much free disk space do we have?
Also for the system is running in low graphics mode 'here'
I did sudo du -hxa / | egrep '^[[:digit:]]{1,1}G[[:space:]]*'
It exactly accounted for the big discrepancy of 21GB that I was seeing!
The file in question was /swap file if 21GB!!
In my case lsof did not help. I was able to track this down because I had mounted disk images using losetup as loop devices. Even after unmounting these devices and deleting the corresponding images there were processes that maintained some sort of indirect reference to the disk images.
So in short, sudo ps -ef|grep loop then sudo losetup -d /dev/loopX. This is not a direct answer to why du and df disagree but it has come up often enough for me that I was able to finally figure out the reason why which was different from any answer I could find.