39

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 
...... 
28G

and

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?

1
  • 1
    The question in the title and at the end of the question body is pretty different. Some answers are related to one question, some to the other. You should clarify your actual needs and possibly accept an answer, too.
    – Melebius
    Apr 18, 2018 at 7:38

9 Answers 9

66

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
  • 11
    This just saved me. Had no idea why my disk was full, but du said it was empty. An open file handle for a 8GB file
    – Cheyne
    May 14, 2014 at 20:28
  • 6
    How can i delete the links? Aug 22, 2014 at 5:46
  • 2
    Sometimes you need to execute this as root to see deleted files held open by processes of other users.
    – Envek
    Jul 25, 2016 at 17:33
  • 1
    The root cause of this for me ended up being an incorrect log file spec in one of my /etc/logrotate.d files. The bad entry was missing a postrotate routine, which caused my daemon process to not let go of its rotated / deleted files. Dec 22, 2016 at 16:39
  • 1
    how could I remove those unlinked but open files?
    – zx1986
    Jul 26, 2018 at 9:40
22

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 13978

Don'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 ;)

0
14

Ok, 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.

df displays 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.

1
  • du usage can be modified with the -x character, to tell it to only count files on the given file system.
    – macetw
    Jun 10, 2019 at 15:12
1
df

Summarize free disk space

It displays the amount of disk space available .

du

Summarize disk usage.

It displays the amount of disk space used.

2
  • yes, but in the result of "df -Th", it showed 68G used. today morning when i try to access ubuntu system, it still gives "the system is running in low-graphics mode" message, but when i check the memory usage, the "df" and "du" commands shows a reasonable result. But what;s the problem with the "low-graphics mode"? Apr 12, 2013 at 9:41
  • Take a look at This.
    – Mitch
    Apr 12, 2013 at 11:10
1

Simply 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.

0

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'

0

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!!

0

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.

0

Adding my situation in case it helps someone. In my case, du reported 6G used and df reported 23G used -- a 17G difference!

But my problem was, I had a folder on the primary disk at /mnt/data with 17G of files in it, and then a SSD mounted at /mnt/data -- the result was the SSD mount essentially hid the data on the primary disk.

So check if it's possible you have other disks mounted on a non-empty directory on the disk in question. (ref: https://askubuntu.com/a/29657)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .