SDB:Create 10 GB file instantly with "dd"

Jump to: navigation, search
Make sure that you have enough free space on the partition

To find out how much is free you can use from command prompt:

df 

The output will look like this:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda2             40321836  28054876  12266960  70% /
tmpfs                   257892         0    257892   0% /dev/shm

This means that you have some 12 GB of unused space, so you can proceed with next command that will create 10 GB file:

dd if=/dev/zero of=myharddisk.img bs=1000 count=0 seek=$[1000*1000*10] 

Caveats:

This trick will work on ext3, ext4 & reiserfs - but will NOT work on FAT32 partitions as they have maximum file size of 4 GiB.

Also because this file is null from within - some programs will fail working with it - such as mkswapfs & mkswapon. For absolute majority of utilities it will work.

-By Alexey Eremenko "Technologov". 21.apr.2006. (updated 12.01.2008)