Skip to main content
Some setups hide sparseness.
Source Link
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, or its sparseness is hidden by a layer of indirection (some network file systems or FUSE file systems for example).

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.

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, or its sparseness is hidden by a layer of indirection (some network file systems or FUSE file systems for example).

Source Link
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.