02-13-2008
how to get the file system size
I have the next code, and the output is incosistent, what is the problem:
free blocks: 1201595
block size: 4096
total size(free blocks * block size): 626765824
1201595 * 4096 not is 626765824, what's the problem???
#include <sys/statvfs.h>
#include <stdio.h>
int main(){
struct statvfs buffer;
int status;
int free_blk;
int blk_size;
status = statvfs("/", &buffer);
printf("free blocks: %u\n",buffer.f_bavail);
printf("block size: %u\n",buffer.f_bsize);
free_blk = buffer.f_bavail;
blk_size = buffer.f_bsize;
printf("total size: %u\n",free_blk*blk_size);
return 0;
}
Thks
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How to find the free size currently FileSystem has, on the disk mounted?
I know 'df' lists all the mounted disks, but I am interested to know details
for the filesystem, in which currently I am working. (7 Replies)
Discussion started by: videsh77
7 Replies
2. UNIX for Advanced & Expert Users
Good morning folks!
I'm new here.. trying to find an answer on how to resize filesystem. Need to add some space to c0t0d0s5, /var... Is it possible at all?
JV (9 Replies)
Discussion started by: jvinn
9 Replies
3. AIX
Dear ALL
Today I faced one problem in the file system, during invoking the command #df -k , I saw /usr reached to 95% Used, could any one give advice ?
thanks & regarded (7 Replies)
Discussion started by: magasem
7 Replies
4. Solaris
Hi
Can anyone explain me how to increase the filesystem size. We can do it when the system is running? It needs an reboot? (8 Replies)
Discussion started by: rogerben
8 Replies
5. AIX
Hi all,
we are usig aix 4.3 and i need to increase the size of "/u01" file sytem which is mounted on logical volume "lv00", but "/u01" file system size is 9 GB and logical volume "lvoo" size 9 GB.how do i increase the size of /u01.do i increase the size of logical volume "lv00" and then... (2 Replies)
Discussion started by: younusdba
2 Replies
6. Solaris
Hi,
We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB?
I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies
7. Shell Programming and Scripting
When I do df -h, I see that one of my partitions is out of space.
Then when I do du -h, I get thousands of files. How do I only look at files over a specific size. I want directories over 500m to be returned only. (2 Replies)
Discussion started by: guessingo
2 Replies
8. Shell Programming and Scripting
Dears,
the output of this command
df -h | tr -s ' ' | cut -f5 -d' '
is
capacity
24%
0%
0%
0%
0%
1%
0%
24%
24%
0%
93%
1% (4 Replies)
Discussion started by: xxmasrawy
4 Replies
9. AIX
Hi,
I'd like to know how can I figure out my disk space area on AIX machine, for example to the situation of ( df -g ) which I have in my system :
the area used by (/opt/oracle) file system is (98%) now.
the free area on (/opt/oracle) is (0.75) now.
the total size in Gigabyte... (1 Reply)
Discussion started by: arm
1 Replies
10. HP-UX
Dear Friends,
I would like to increase the size of a file system from 10GB to 15GB.
System is runing on HP-UX 11.31.
Please help in the matter.
Regards,
Bhagawati Pandey (3 Replies)
Discussion started by: BPANDEY
3 Replies
LEARN ABOUT LINUX
e2freefrag
E2FREEFRAG(8) System Manager's Manual E2FREEFRAG(8)
NAME
e2freefrag - report free space fragmentation information
SYNOPSIS
e2freefrag [ -c chunk_kb ] [ -h ] filesys
DESCRIPTION
e2freefrag is used to report free space fragmentation on ext2/3/4 file systems. filesys is the filesystem device name (e.g. /dev/hdc1,
/dev/md0). The e2freefrag program will scan the block bitmap information to check how many free blocks are present as contiguous and
aligned free space. The percentage of contiguous free blocks of size and of alignment chunk_kb is reported. It also displays the mini-
mum/maximum/average free chunk size in the filesystem, along with a histogram of all free chunks. This information can be used to gauge
the level of free space fragmentation in the filesystem.
OPTIONS
-c chunk_kb
If a chunk size is specified, then e2freefrag will print how many free chunks of size chunk_kb are available in units of kilobytes
(Kb). The chunk size must be a power of two and be larger than filesystem block size.
-h Print the usage of the program.
EXAMPLE
# e2freefrag /dev/vgroot/lvhome
Device: /dev/vgroot/lvhome
Blocksize: 4096 bytes
Total blocks: 1504085
Free blocks: 292995 (19.5%)
Min. free extent: 4 KB
Max. free extent: 24008 KB
Avg. free extent: 252 KB
HISTOGRAM OF FREE EXTENT SIZES:
Extent Size Range : Free extents Free Blocks Percent
4K... 8K- : 704 704 0.2%
8K... 16K- : 810 1979 0.7%
16K... 32K- : 843 4467 1.5%
32K... 64K- : 579 6263 2.1%
64K... 128K- : 493 11067 3.8%
128K... 256K- : 394 18097 6.2%
256K... 512K- : 281 25477 8.7%
512K... 1024K- : 253 44914 15.3%
1M... 2M- : 143 51897 17.7%
2M... 4M- : 73 50683 17.3%
4M... 8M- : 37 52417 17.9%
8M... 16M- : 7 19028 6.5%
16M... 32M- : 1 6002 2.0%
AUTHOR
This version of e2freefrag was written by Rupesh Thakare, and modified by Andreas Dilger <adilger@sun.com>, and Kalpak Shah.
SEE ALSO
debugfs(8), dumpe2fs(8), e2fsck(8)
E2fsprogs version 1.41.14 December 2010 E2FREEFRAG(8)