4 ms·
I always thought it was funny to make a large imaginary file like this: dd if=/dev/null of=huge.img bs=1024 count=1 seek=5242880000 5TB file and instant c
by xxa1e 6y ago
I always thought it was funny to make a large imaginary file like this:
dd if=/dev/null of=huge.img bs=1024 count=1 seek=5242880000
5TB file and instant creation. Doesn't actually take any space.
- pronoiac 6y agoYes, they're called sparse files. Most but not all file systems support them.
- jagger27 6y agotruncate -s 100T hugefile.img Another way to do this.
- segfaultbuserr 6y agoLinux also has another one. fallocate --length 1TB.img "truncate" is in GNU coreutils, "fallocate" is in util-linux.
- cmurf 6y agoThey are not the same thing. Check them with 'ls -lsh' and you'll see the sparse file from truncate uses no sectors. Whereas the fallocated file is fully preallocated. If you have 100G free, truncate -S 1T will succeed, fallocate -l 1T will not.
- segfaultbuserr 6y agoAh, yes. I stand corrected. I've mixed up the concept of preallocating an uninitialized file and a true sparse file.