Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-12-2006, 02:43 PM   #1
LQ Newbie
Registered: Jan 2006
Posts: 24

Rep: Reputation: 0
df command output, doesn't add up?

I do a df command on my mounted 256MB memory key and it reports in default 1K-blocks:

total: 245993
used: 3741
avail: 242253

well, if I add up avail and used, I get 1 more than the total.

Am I missing something here .. is it a matter of df rounding up counts of bytes ?

By the way, IS there a way to get it to report the numbers in bytes, I couldn't see to find an option for that in my version 4.5.8.
Old 07-12-2006, 03:05 PM   #2
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
To express it in bytes, use `df --block-size=1`.
Old 07-12-2006, 04:45 PM   #3
Senior Member
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
might try df -h. that will put it in human readable form.
Old 07-12-2006, 05:00 PM   #4
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,370

Rep: Reputation: 978Reputation: 978Reputation: 978Reputation: 978Reputation: 978Reputation: 978Reputation: 978Reputation: 978
You are supposed to get one extra because the drive starts at 0 and df starts at 1.
Old 07-13-2006, 07:09 AM   #5
LQ Newbie
Registered: Jan 2006
Posts: 24

Original Poster
Rep: Reputation: 0
Thanks for all the responses so far, going to play with the --block-size=1.

But I am confused by the post that says the counts are supposed to be off by 1. I don't get it. No matter where the drive starts and where df starts, what df reports for used space and avail space should add up to total space.
Old 07-13-2006, 07:16 AM   #6
LQ Newbie
Registered: Jan 2006
Posts: 24

Original Poster
Rep: Reputation: 0
it appears the counts being off is due to rounding off. When I run the df with --block-size=1, I get counts of:
total: 251896832
used: 3830272
avail: 248066560

and those add up ...

So I would *guess* the df code is rounding off when you get the data in bigger chunks .. maybe it needs to round up used and round down avail or something like that ...

thanks for all the help folks ...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Bash: add date to output line blizunt7 Programming 7 11-10-2004 03:45 AM
last -i command output praveenv Linux - Networking 2 08-18-2004 12:43 AM
last -i command output praveenv Linux - Networking 1 08-17-2004 06:09 AM
Bash script: add all numbers from command output wi-Z-art Programming 2 08-06-2003 09:16 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:41 AM.

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