LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   where is info on free disk space stored (/proc?) (https://www.linuxquestions.org/questions/linux-general-1/where-is-info-on-free-disk-space-stored-proc-272852/)

eigenyeugen 01-02-2005 04:53 AM

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

JunctaJuvant 01-02-2005 06:40 AM

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

ghaefb 01-22-2005 03:48 AM

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

elwoodthegreat 01-30-2005 09:45 AM

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.


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