My interest in the Raspberry Pi has led me to setting up an ARM based virtual machine in QEMU. A bit of searching turned up instructions on setting up QEMU on MS Windows 7, which, in turn linked to instructions on doing the same thing on Debian which I follow here.
First, install the QEMU packages using your favorite package manager (I use Aptitude in its curses mode). I am running Wheezy, which is the current Testing archive on a Core Duo laptop, so QEMU is relatively new and the hardware up to the task. Once installed create a hard disk image (make sure you have enough disk space!):
qemu-img create -f raw hda.img 4G
This creates a bare hard disk image file of 4 Gigabytes.
Next, as instructed in the Debian blog post above, download the initrd.gz and vmlinuz-2.6.32-5-versatile files into the same directory as the hard disk image created above. These files are from the current Stable (Squeeze) archive and provide a network installation environment so a network connection from the host computer is needed.
With the files in place it is time to boot the armel image and start the Debian net install. As I am not particularly interested in having a dedicated IP address for this virtual machine, I did not go to the bother of setting the TAP network interface and just let QEMU provide a private address to the VM and provide network access via the host machine:
qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile \ -hda hda.img -initrd initrd.gz -append "root=/dev/ram" -m 256
The VM will have 256 Megabytes of RAM which emulates the Raspbery Pi well. QEMU is capable of booting using the kernel file which reads the initrd file. No CD image needed! Cool, huh?
Answer all the questions, set up the image in the partition format you prefer (I chose everything on one partition and did not create another partition for swap), and the net installer will start downloading and installing packages. Once that is complete the installer prompts to restart the system which it will do provided the QEMU is never closed!
The Debian tutorial provides commands to mount the hda.img as a loopback device in order to get the initrd image copied to the host directory where the kernel and hda.img are stored. However, I received an error stating that a file system type needed to be specified. It seemed that ‘-t ext3’ didn’t work so I fell back to grabbing a copy of initrd.img-2.6.32-5-versatile pointed to by the Win7 tutorial.
With the correct initrd in place I was ready to boot the new Debian Squeeze armel VM:
qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile \ -initrd initrd.img-2.6.32-5-versatile -hda hda.img \ -m 256 -append "root=/dev/sda1"
Success! The Debian armel system looks nice and familiar.
I added the above command as a Bash shell alias for ease of future invocation (I keep my aliases in ~/.bash_aliases and source that file from ~/.bashrc):
alias debarm='qemu-system-arm -M versatilepb \ -kernel vmlinuz-2.6.32-5-versatile \ -initrd initrd.img-2.6.32-5-versatile \ -hda hda.img -m 256 -append "root=/dev/sda1" &'
Now, on to see how compiling Hamlib goes…