LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-12-2006, 03:43 PM   #1
jrfk2
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, 04:05 PM   #2
uselpa
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, 05:45 PM   #3
jstephens84
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, 06:00 PM   #4
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora
Posts: 1,923

Rep: Reputation: 278Reputation: 278Reputation: 278
You are supposed to get one extra because the drive starts at 0 and df starts at 1.
 
Old 07-13-2006, 08:09 AM   #5
jrfk2
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, 08:16 AM   #6
jrfk2
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 ...
 
  


Reply


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 05:35 PM
Bash: add date to output line blizunt7 Programming 7 11-10-2004 04:45 AM
last -i command output praveenv Linux - Networking 2 08-18-2004 01:43 AM
last -i command output praveenv Linux - Networking 1 08-17-2004 07:09 AM
Bash script: add all numbers from command output wi-Z-art Programming 2 08-06-2003 10:16 AM


All times are GMT -5. The time now is 05:43 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration