LinuxQuestions.org
Visit Jeremy's Blog.
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 01-02-2005, 04:53 AM   #1
eigenyeugen
LQ Newbie
 
Registered: Jan 2005
Location: UK
Distribution: Debian
Posts: 11

Rep: Reputation: 0
where is info on free disk space stored (/proc?)


I'd like to know where on a linux system, information about the amount of free disk space is stored. Ultimately I'd like to parse this for use in a program.

I know I can see this info by just typing df, but I'd now love to find out how that program finds out about the free disk space.

For a while, I thought this info might be stored in /proc/partitions:
Code:
~>cat /proc/partitions
major minor  #blocks  name     rio rmerge rsect ruse wio wmerge wsect wuse running use aveq

   3     0   39082680 ide/host0/bus0/target0/lun0/disc 8947 18132 216204 54330 1395 830 17944 1240 -1 1221250 41762912
   3     1   10241406 ide/host0/bus0/target0/lun0/part1 7 0 49 30 0 0 0 0 0 30 30
   3     2          1 ide/host0/bus0/target0/lun0/part2 0 0 0 0 0 0 0 0 0 0 0
   3     5     514048 ide/host0/bus0/target0/lun0/part5 1 0 8 10 0 0 0 0 0 10 10
as I have no idea what the rio, rmerge and all following feilds mean. But then I disovered that on some systems these aren't there:
Code:
~>cat /proc/partitions
major minor  #blocks  name

   8     0  120627360 sda
   8     1  120624021 sda1
   8    16  120627360 sdb
So obviously the information must be stored somewhere else.

Anyone know the answer?
Any replies most appreciated,
--Matt
 
Old 01-02-2005, 06:40 AM   #2
JunctaJuvant
Member
 
Registered: May 2003
Location: Wageningen, the Netherlands
Distribution: OS X & Linux Mint
Posts: 488

Rep: Reputation: 31
While I'm not a C programmer, I thought it would be interesting to have a look at "df.c" and "stat.c". I am not entirely certain, but it would appear that the information is accessed through fuctions like "statfs" or "statvfs" (see man statfs for example). So I think the information comes from the kernel (like proc?), and not from some file.
I'd like to know more about this myself, so any corrections/additional info would be appreciated.
Thanks in advance.

JJ
 
Old 01-22-2005, 03:48 AM   #3
ghaefb
Member
 
Registered: Aug 2004
Location: Slovenia
Distribution: Fedora Core
Posts: 37

Rep: Reputation: 15
anyone ???
I'd really like to know too. Where the free disk space info is stored...

I can't find it in /proc or /sys..
 
Old 01-30-2005, 09:45 AM   #4
elwoodthegreat
LQ Newbie
 
Registered: Mar 2004
Location: DePauw University
Distribution: If its working, Gentoo...
Posts: 2

Rep: Reputation: 0
Try using:

Code:
stat -f /mnt/hda1
Replace hda1 with the name of your mounted filesystem or just use / if you want to look at the root filesystem. This command will give output like this with sizes in bytes:

Code:
  File: "/mnt/hda1"
    ID: 0        Namelen: 255     Type: reiserfs
Blocks: Total: 3840353    Free: 1482104    Available: 1482104    Size: 4096
Inodes: Total: 0          Free: 0
If you are wanting to parse the output of this, I'd suggest looking at the help and man pages for stat as you can format the output of stat for easy parsing.
 
  


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
No free space on disk, but there is? Recirqie SUSE / openSUSE 4 02-22-2013 01:17 PM
How t get it known free disk space? ukrainet Linux - General 3 05-06-2008 10:52 PM
Free up disk space TheShemeta Slackware 5 11-26-2003 04:50 PM
free disk space? Alf829 Linux - Newbie 3 08-01-2003 11:26 AM
How to see free disk space bripage Linux - General 3 04-29-2002 08:38 PM

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

All times are GMT -5. The time now is 10:39 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
Open Source Consulting | Domain Registration