How to create a simple disk image formatted to ext3

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

Tagged with: , , , , , , ,
Posted in Technology
1 Comment » for How to create a simple disk image formatted to ext3
  1. Kris says:

    Thanks a lot for this mini-tutorial! This is such a simple task, but I couldn’t grab the right commands to get the job done. I needed to do this to make an ext3 image containing the contents of the latest XO software. They only provide jffs2 images. I’m going to turn into a vmdk virtual disk so I can run virtual XOs in VMware. Oh, I think I also need to replace the kernel with something that doesn’t only run on the AMD ISA. Anyway, thanks again!

Leave a Reply