We want a 48MB image, formatted to ext3
ns3:/tmp# dd if=/dev/zero of=./disk.img bs=1MiB count=48
48+0 records in
48+0 records out
50331648 bytes (50 MB) copied, 0.301372 s, 167 MB/s
ns3:/tmp# mkfs.ext3 ./disk.img
mke2fs 1.41.3 (12-Oct-2008)
./disk.img is not a block special device.
Proceed anyway? (y,n) y
ns3:/tmp# mkdir disk
ns3:/tmp# mount -oloop ./disk.img ./disk
ns3:/tmp# df -h ./disk
Filesystem Size Used Avail Use% Mounted on
/tmp/disk.img 47M 4.8M 40M 11% /tmp/disk
That’s it – now we can copy our content to ./disk before unmounting it, then use dd to write it to our target medium (such as a CF card or similar)
ns3:/tmp# umount ./disk
Tags: CF, df, disk image, ext3, loop, mkfs.ext3, mount, umount