"to dd or not to dd" - that is the question...
You want to create a file to use as a virtual hard disk for a virtual machine.
-or-
You want to create a file to use as a virtual hard disk for loopmounting.
This How-To uses standard GNU/Linux commands, therefore it is not specific to openSUSE.
To find out how much is free you can use from command prompt:
linux:/ > 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:
linux:/ > dd if=/dev/zero of=myimage.img bs=1000 count=0 seek=$[1000*1000*10]
This trick will work on ext3 and reiserfs, but will NOT work on FAT32 partitions as they have maximum file size limit of 4 GiB.
Additionally, because this file is null from within, some programs will fail working with it, for example: mkswap and swapon. For absolute majority of utilities it will work.
Let's explain: dd is often used to copy blocks of data and is part of "CoreUtils" that comes preinstalled with every Linux system.
As input, we use binary "zero"s and as output we use "myimage.img".
"bs" means block size - how big each block of data we want to move.
"seek" means over how much blocks we will jump. The more we'll jump, the less we'll work :)
"count" means how many blocks needs to be written.
Because our file is nil (vacuum) from within, we write zero blocks. If we don't specify "count", "dd" will make system calls recursively until your hard disk is full.
Using big blocksizes with count=1 is the fastest way to fill file with zero's.
Using big blocksizes with count=0 is the fastest way to create "nil" file.
Nil, or Vacuum files is a concept that does not exist under FAT. So for newbie users, I will try to explain:
Basically this concept says: you don't have to waste hard disk space for "nil" files, unless you write something to them. Their size is only visible under certain condiftions. It's like a growable file, if you can imagine this. So they have 2 advantages: they don't use space unless used, and they are very fast.
Some rumors say, that contrary to popular belief "dd" does not stand for "disk dump" but for "convert and copy" instead. The abbreviation "cc" was already taken by the C compiler, so they decided to use "dd". -- by Dennis Conrad, Novell Consulting ANZ
For more information about the original how-to, look: http://en.opensuse.org/How-To_Create_10_GB_file_instantly_with_%22dd%22.