◄  ▲  ► |
# Create empty loopback filesystem - 4MB - depending on how you count itI use the "dd" command to create a new disk image. If you haven't used dd before, you're missing out. By specifying the "if" (input file) and "of" (output file", you can copy disks to files and vice-versa. In other words, it's a disk backup and restore tool! That Knoppix boot CD could come in handy some day.
echo "Creating 4MB empty file for the loopback file system"
dd if=/dev/zero of=fs bs=1k count=4000 > /dev/null
# Create an ext2 file system in the loopback file with 2000 i-nodes (more than needed)
echo "Making new EXT2 file system in the 'fs' loopback file"
mke2fs -q -F -m 0 -N 2000 fs
Here I use dd to copy 4 megabytes of zeros into a file called "fs".
After I have my big empty file, I use "mke2fs" to create a Linux filesystem in the fs file. With that done, it's officially a disk image of an empty 4MB drive.