File holes are the empty spaces in file, which, however, doesn’t take up any disk space and contains null bytes. Therefore, the file size is larger than its actual size on disk.
However, I don’t know how to create a file with file holes for experimenting with.
Use the
ddcommand with aseekparameter.That creates for you a file with a nice hole from byte 8192 to byte 28671.
Here’s an example, demonstrating that indeed the file has holes in it (the
ls -scommand tells you how many disk blocks are being used by a file):As you can see, the file with holes takes up fewer disk blocks, despite being the same size.
If you want a program that does it, here it is:
The above should work on any Unix. Someone else replied with a nice alternative method that is very Linux specific. I highlight it here because it’s a method distinct from the two I gave, and can be used to put holes in existing files.