ls -l f.txt
-rwxrwxr-x 1 abc abc 1161 Sep 1 02:02 f.txt
stat f.txt
File: `f.txt'
Size: 1161 Blocks: 34 IO Block: 524288 regular file
Device: 38h/56d Inode: 6448956669 Links: 1
Access: (0775/-rwxrwxr-x) Uid: ( 1024/ carle) Gid: ( 100/ users)
Access: 2017-09-09 02:02:36.000000000 -0700
Modify: 2017-09-09 02:02:36.000000000 -0700
Change: 2017-09-11 20:42:00.709807459 -0700
du -h f.txt
17K wiki.txt
- Why is f.txt occupying 17K (17408 bytes) on disk ?
- What is IO Block size ? Why is it 524288 bytes long and is not equal to filesystem block size (assuming file system block size is 17K) ?
Whats going on here ?
I assume you are referring to the difference of the size reported by
ls -l f.txt
and the blocks occupied. Normally these numbers are pretty close to each other. As Sorcha already mentioned the file occupies 34 blocks and each block reported here normally has 512 bytes. You can verify that withstat -c "%B" f.txt
. If you do the math you will get 17408 bytes.Normally the Linux filesystems has a block size of 4096 bytes, so anything below 512 bytes would nevertheless allocate 4096 bytes or 8*512 bytes on disk, which is the smallest allocatable size in the filesystem.
In your case it seems the blocksize of the filesystem is 17kbytes. For further clarification you would have to check the filesystem on the NFS server where the files are stored.
What you see here is, taken from
man stat
, the optimal I/O transfer size hint and in case of NFS, this refers to the rsize/wsize mount option of NFS instead of the filesystem block size which normally is 4096 bytes. Runstat f.txt
on the NFS server, which holds the filesystem on disk, to see the difference.Because the block size of the partition is 17408 bytes. So, yours files will be splitted in part of this size and the file which have a size smaller than 17k will occupe 1 block so 17k.
Because the block size of your hard drive is 512 bytes. And if you do 34x512 you will have 17408 bytes the size on your file system.
And the IO block is the index of your block not his size