Skip to main content
1 of 2
Stephen Kitt
  • 481.5k
  • 60
  • 1.2k
  • 1.4k

stat’s “Blocks” field shows the allocated blocks, which will be smaller than the apparent size with sparse files:

$ truncate -s 1g test.1g
$ stat test.1g
  File: test.1g
  Size: 1073741824  Blocks: 0          IO Block: 4096   regular file
…

du and ls can also be used:

$ ls -s test.1g
0 test.1g
$ du test.1g
0   test.1g

If you’re not seeing this kind of results, then your file isn’t really sparse.

Stephen Kitt
  • 481.5k
  • 60
  • 1.2k
  • 1.4k