You are not logged in.
From what I've read, the third column in the /proc/partitions file is the number of physical disk blocks in the partition listed on that line. https://www.centos.org/docs/5/html/5.1/ … tions.html
This seems to be a completely different number from the "blocks" listed by the df command or statvfs system function (lengthy examination below*). I am wondering if this is because /proc/partitions is in fact measuring something different than df, or if there's some kind of bug which is causing the wrong number of blocks to be listed in the /proc/partitions file. I'm pretty sure I'm just misunderstanding the number in the file, so if someone could explain what the "#blocks" column means in /proc/partitions and how that differs from the blocks counted by df I'd be grateful!
I apologize if all of this is just meaningless babble.
*For example, looking at the number of blocks in my /tmp partition (/dev/sda2 on my machine), I get this from /proc/partitions:
[nfm@gauss DiskSpaceDisplayer]$ cat /proc/partitions
major minor #blocks name
8 16 117220824 sdb
8 17 1024 sdb1
8 18 117218759 sdb2
8 0 488386584 sda
8 1 2097152 sda1
8 2 2097152 sda2
8 3 484191239 sda3
11 0 1048575 sr0
However, this is the output of df:
[nfm@gauss ~]$ df "/tmp"
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 1998672 3120 1874312 1% /tmp
I'm looking at the difference between the "2097152" listed in one place and "1998672" listed in the other.
If I use the statvfs system function, like so:
struct statvfs buf;
statvfs("/tmp", &buf);
std::cout << data << " " << buf.f_blocks << std::endl;
then I get output of 499668, which matches the df output if I use 4096-byte blocks:
[nfm@gauss ~]$ df -B 4K "/tmp"
Filesystem 4K-blocks Used Available Use% Mounted on
/dev/sda2 499668 780 468578 1% /tmp
So the results from df and statvfs seem to agree, but they are both different from /proc/partitions; further, there doesn't seem to be a block size I can pass to df that would give me the same size in blocks for "/tmp" as the number in /proc/partitions so my conclusion is they are either measuring something different or there is a bug with /proc/partitions.
Thanks!
Last edited by tanstaafl (2015-11-30 01:43:13)
Offline
One is measuring the partition size, the other is measuring the filesystem. Filesystems reserve some partition space. It looks like your filesystem size is 5% less than the partition size. This is a common value I've heard for the space reserved by ext3/ext4.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
One is measuring the partition size, the other is measuring the filesystem. Filesystems reserve some partition space. It looks like your filesystem size is 5% less than the partition size. This is a common value I've heard for the space reserved by ext3/ext4.
Ah, that makes sense. Thanks!
Offline