For a very large file with delayed-allocation, some sectors may have been allocated and some may not. Delayed allocation is supported by ext4/xfs/etc..

For example, create an empty file and set to very large size using fallocate(). Now the file's size could be GBs, but using du you will get a zero disk usage. After some random writes, I want to get whether a specific sector/page of this file has been allocated.

Some related system calls such as mincore/fincore work on vm status of page cache. However they don't serve on-disk allocation information. I wonder is there any method to do that. Thanks.

1 Answer 1


You can get the on-disk mapping of a file with the FIEMAP ioctl. There is also the FIBMAP ioctl, which does a similar thing, requires root, and isn't well-documented.

Without writing C, you can use filefrag -v or hdparm --fibmap to get at the data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .