QEMU is well-known as a free replacement for VMware, allowing users to run a PC within a PC. What isn't so well known about QEMU is that, in addition to emulating x86 architectures, it can emulate AMD64, Sparc, MIPS, PPC and ARM CPUs.
In the case of the ARM architecture, QEMU provides a convenient, if slow, environment in which development can be done for embedded systems.
This article describes the process involved in building a Debian/ARM server running under QEMU. It assumes that Debian is also being used as the host server.
Since QEMU's arm emulator has no ability to emulate either IDE or SCSI disks, it will be necessary to install the server on an NFS exported partition.
We're going to use the same server that is being used as the host server for running QEMU as the NFS server for the guest server's root filesystem; an emulated system is slow enough as it is, we don't need to make things worse by having a real ethernet network in between the guest OS and its filesystem (as opposed to a virtual ethernet, in this case).
Share the new directory out via NFS, by adding the following entry to
/etc/exports:
/nfs/share/arm 10.1.6.0/24(rw,no_root_squash,sync)
Then export the filesystem:
host# exportfs -a
Download a kernel for arm-linux; there's one provided in the arm-test files on the
qemu website (and a copy
here.
Place the arm-linux zimage in
/usr/local/etc/images/zImage.arm, and then create the following script as
/usr/local/bin/start-qemu-arm:
#!/bin/sh
console="ttyAMA0" # serial console
nfsserver="10.1.6.1" # address of NFS server
nfsdir="/nfs/share/arm" # exported share where debian/arm is installed
address="10.1.6.50" # address for guest server
gateway="10.1.6.1" # default gateway
netmask="255.255.255.0" # subnet mask
hostname="arm.home" # hostname for guest server
device="eth0" # interface that guest server will use
mem=256 # memory for guest server in Mb
tap="/var/run/vde/tap0.ctl" # vde tap socket
kernel="/usr/local/etc/images/zImage.arm" # arm kernel
nfsopts="rsize=8192,wsize=8192,hard,intr,tcp,nolock" # nfs options
consoleopt="console=$console"
nfsrootopt="nfsroot=$nfsserver:$nfsdir,$nfsopts"
ipopt="ip=$address::$gateway:$netmask:$hostname:$device"
init=""
if [ "x$1" == "xsingle" ]
then
init="init=/bin/bash"
fi
vdeq qemu-system-arm -sock $tap -m $mem \
-kernel $kernel -nographic \
-append "$consoleopt root=/dev/nfs $nfsrootopt $ipopt $init"
Adjust the parameters at the top of the script to suit your requirements.
If you found this article helpful, consider making a donation to offset the costs of running this server, to one of these addresses:
Dogecoin: DBu2vJEKBE8QzZgp7nuSHXhAeyUn9vXpCS
Bitcoin: 16oaJfmt8ARXibVuKBmAtU833BLDVoPY7r
Litecoin: LerLMqzbtXyjMG2vKt8Hg6Wq1RjSmC9MZj