How To: Running Fedora-ARM under QEMU
QEMU is a well-known emulator that supports ARM platforms, and can be used to run the Fedora-ARM distribution. This provides a convenient platform to try out the distribution as well as to development and customization.
The howto describes a process to get the Fedora-ARM distribution running under QEMU. Although we have tested this on Fedora 7 and Fedora 8 with QEMU 0.9.0, most of the process should work on any other Linux system as well. We assumes that you can run commands as root (or using sudo) whenever necessary.
The QEMU system is set up to get its root file system from a local loopback block device or over NFS from the host system (requires networking between the host system and the QEMU guest). The host's networking can then be configured to get its IP address using DHCP.
If you are running Fedora 7/8, you can just install qemu using yum.
yum install qemu
You can skip this section if you are going to use a local loopback device for your root file system. However that may prevent you from using yum to install new packages on your Fedora-ARM guest.
Networking is setup between the host system and the QEMU guest to allow the guest to get its IP address using DHCP.
The networking setup uses host TAP devices to connect to QEMU. In recent kernels, this requires CAP_NET_ADMIN capability. The host system needs to have TUN/TAP networking enabled (CONFIG_TUN=m or CONFIG_TUN=y). You can verify this using:
grep CONFIG_TUN= /boot/config-`uname -r`
Also make sure that /dev/net/tun exists. If not, you can make it as follows:
mknod /dev/net/tun c 10 200
Now, we need to set up a network bridge interface. Install some utilities to configure a ethernet bridge:
# yum install bridge-utils
/usr/sbin/brctl addbr br0 /sbin/ifconfig eth0 0.0.0.0 promisc up /usr/sbin/brctl addif br0 eth0 /sbin/dhclient br0 /sbin/iptables -F FORWARD
Also, create a script qemu-ifup as follows. This will be needed when we boot into QEMU.
#!/bin/sh /sbin/ifconfig $1 0.0.0.0 promisc up /usr/sbin/brctl addif br0 $1
Setup Kernel Image
You can either simply use a pre-built kernel image or build your own from source.
Pre-built Kernel Image
You can get one of the following pre-built kernel images for ARM:
Build Kernel Image From Source
You will need to have an ARM cross-compiler. If you do not have one, download one from CodeSourcery's web-site, install it and ensure that is it in your path.
export arch=ARM export CROSS_COMPILE=arm-none-linux-gnueabi-
You can also use the Fedora cross toolchain that we provide.
Download Linux kernel (I have tested it with 2.6.21 and 2.6.22) and build it for ARM Versatile board. But, first you will have to customize the defconfig for it to work correctly.
cp arch/arm/configs/versatile_defconfig .config make menuconfig Enable DHCP Support (CONFIG_IP_PNP_DHCP). It is under Networking -> Networking Support -> Networking Options -> TCP/IP Networking -> IP: Kernel Level autoconfiguration. Enable Universal Tun/Tap Driver Support (CONFIG_TUN). It is under Device Drivers -> Network Device Support -> Network Device Support. Enable ARM EABI Support (CONFIG_AEABI). It is under Kernel Features. Enable tmpfs support (CONFIG_TMPFS). It is under File Systems -> Pseudo File Systems. If you will be booting from a file system image (not NFS), then the following steps should also be taken: Enable PCI support (CONFIG_PCI). It is under Bus Support. Enable SCSI Device Support. It is under Device Drivers -> SCSI Device Support. Enable SCSI Disk Support. It is under Device Drivers -> SCSI Device Support. Enable SYM53C8XX Version 2 SCSI Support. It is under Device Drivers -> SCSI Device Support -> SCSI low-level drivers Build the kernel. make
Setup Root File System
Download the root file system tarball . It is approximately 93MB in size.
Root File System On Loopback Device
Create a loopback device -- 4GB is a reasonable size.
dd if=/dev/zero of=rootfs-f8-dev bs=1024k count=4096
Create a file system.
mkfs.ext3 rootfs-f8-dev -L arm
Prepare the root file-system. This assumes that the loopback device is mounted under /mnt/ARM_FS.
mount rootfs-f8-dev /mnt/ARM_FS -o loop tar -xjf rootfs-f8.tar.bz2 -C /mnt/ARM_FS mv /mnt/ARM_FS/rootfs-f8/* /mnt/ARM_FS rm -rf /mnt/ARM_FS/rootfs-f8 umount rootfs-f8-dev
Root File System Over NFS
This assumes that the root file system is in /mnt/ARM_FS. We need to export it through NFS. Add the following in your /etc/exports.
Now, restart the NFS service.
/sbin/service nfs restart
Boot into QEMU
Now you are ready to boot into QEMU. Replace <host-ip> with the IP address of the host machine.
qemu-system-arm -M versatilepb -kernel zImage-versatile -append root="/dev/nfs nfsroot=<host-ip>:/mnt/ARM_FS rw ip=dhcp" \ -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=./qemu-ifup