LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-10-2006, 07:41 PM   #1
matsamuel
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Rep: Reputation: 0
Question Result from 'df' does not add up


So I'm trying out this 'df' command in Linux and the numbers don't quite add up although I'm sure there's a reasonable explanation for this. So the 'df' command reports filesystem disk space usage.

Here's an example of the command that I try:

df -h /tmp

And here is the result:

Filesystem Size Used Avail Use% Mounted on
/dev/sda7 9.7G 33M 9.1G 1% /tmp

So I would have thought that Used + Avail = Size but that does not apply above as it just doesn't add up.

I've tried this with other directories as well, not just /tmp, and the numbers are inconsistent for the other ones I've tried as well.

I'm just hoping some one may be able to explain why the result does not add up? What am I missing here? Any help would be greatly appreciated. Thanks!

Cheers,
Matt
 
Old 12-10-2006, 08:25 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
There are two usual reasons for this:

1. Confusing between Megabytes and Mebibytes, Gigabytes and Gibibtes etc. So many programs get it wrong, it's hardly surprising people make small errors in the calculation. Can you show your working so we can check it.

2. Linux doesn't actually delete files until the last link to a file is "unlinked" (the system call which deleted files). Each file has a link count. When the file exists in a directory listing, that counts as one link. If you make a hard link with the ln command from another file name, the link count is incremented. Also, when a program opens a file, the link count is incremented. The file is only deleted when all links (including those from running program who have the file open) have been unlinked.

This means that if programs have files open, but the file has been removed from a directory listing, the space will not be freed up until the last program with the file open has closed the file handle.

You can check for this using the lsof command. As root (or with sudo if it is configured for your user) run this command:
Code:
lsof |fgrep -e DEL -e '(deleted)'

Last edited by matthewg42; 12-10-2006 at 08:25 PM. Reason: the never ending typo
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
df gets different result from du? liyuefu Linux - General 4 10-01-2005 10:45 AM
seems to be working but no result ZairSadiqov Linux - Networking 1 01-20-2005 06:53 PM
disk not showing up in 'df' command jjordan Mandriva 8 09-25-2004 09:29 PM
What programming call is like 'df' ? netstv Programming 3 08-23-2004 06:05 PM
Multiple /dev/hda1 's listed after a 'df' command (up to 50-60) hmschouten Linux - General 4 04-02-2004 03:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration