Create a sparse file

Post Type: 
Tutorial

To create a sparse file do
dd if=/dev/zero of=sparse-file bs=1 count=1 seek=1M

Will create a file of one megabyte in size, but with only one byte 
actually stored on disk.


Comments

Overlooked

Sparse files are hugely overlooked. They are a great way of keeping things together. I was talking to one of the guys working on the new Pandora handheld console and he was trying to get the others to adopt sparse files as the recommended way of distributing all the games.
When the file is created you can do:
mkfs.ext3 sparse-file
mkdir /mnt/tmp
mount /mnt/tmp sparse-file
instant virtual drive :)