The idea is to be able to easily manage a Qemu image outside of Qemu, natively on Linux. This can help you to alter the files on the Qemu image easily on Linux and then test the modified Qemu image on a Qemu virtual machine.
You can download an empty, formatted with Ext3 Qemu raw image at the following URL address:
- empty-ext3-2GB.img.tgz (download size is 2 MBytes)
There is nothing special about how you can achieve this yourself:
- Create an empty Qemu image file.
- Run an installation CD of Debian (or any other Linux) under Qemu and use the empty image as an available hard disk.
- Partition and format the Qemu hard disk (resp. the Qemu image file) using the Linux installer.
- Interrupt the Linux installer, stop Qemu, mount the Qemu image on Linux and clean it up.
You can achieve the above using the following commands:
# make sure to update the .iso URL if needed
$ wget http://cdimage.debian.org/debian-cd/5.0.3/i386/iso-cd/debian-503-i386-netinst.iso
$ qemu-img create hd0.img 2G
$ qemu -hda hd0.img -cdrom debian-503-i386-netinst.iso -boot d
# continue with the installation to the point where you can set up the partitions
# set up a primary partition using the entire disk space, do not set up a swap partition; save changes to disk and continue
# interrupt the installation (for example from the second console by executing "halt"), stop the virtual machine, we will not need it any further
$ sudo mkdir -p /mnt/diskimage
$ sudo mount -o loop,offset=32256 hd0.img /mnt/diskimage
$ sudo rm -r /mnt/diskimage/*
$ sudo mkdir -m 0700 '/mnt/diskimage/lost+found'
$ sudo umount /mnt/diskimage
Now we have an empty Qemu image which we can mount in both Linux and Qemu.
Here is an example on how to mount this image in Qemu:
qemu -usb -usbdevice disk:hd0.img
Do not use the image simultaneously as Linux mount and Qemu hard disk.