Xen ARM with Virtualization Extensions/RootFilesystem
Introduction
This page describes how to create a root filesystem suitable for use with a Xen on ARM system from a non-ARM host system.
These instructions are intended as a counterpart to the Cross Compilation instructions since it is assumed that if you are compiling native then you already have a suitable root file system available.
Preparing the device and filesystem
Filesystem image
If you are using a software emulator (such as the Fast or Foundation models) then you will mostly likely want to create a root filesystem as a image file. Start by creating an empty file, e.g. to create a 512MB image:
$ dd if=/dev/zero bs=1M count=512 of=rootfs.img
Note: Some versions of the fast model restrict MMC file systems images to 512MB
Once the image has been created you can create an ext3 filesystem in it with:
$ /sbin/mkfs.ext3 rootfs.img mke2fs 1.42.5 (29-Jul-2012) rootfs.img is not a block special device. Proceed anyway? (y,n) y ...
And finally mount it using a loop back device:
# mount -o loop rootfs.img /mnt
Physical device
If you are working with a physical system then it is likely that you want a root filesystem on a physical device, such as an MMC card. This will usually involve putting the card into some sort of adapter (many monitors have these built in) and attaching to your host system. Once the device is attached to your host system you need to identify its name in your system, e.g. by looking at the output of dmesg
. It will usually be called sd<X> where <X> is b, c etc.
WARNING: The root filesystem of your host is likely to also be a sd<X> device. Be *very* careful!
Once you have identified the correct device (here we assume it is sdz, substitute as required) you can create an ext3 filesystem with:
# mkfs.ext3 /dev/sdz
And finally mount it:
# mount /dev/sdz /mnt
Populating the root filesystem
Having created and mounted the root filesystem we next need to populate it with a distro. This distro should match the one which you use for compiling, for example if you have followed the Cross Compilation instructions then this will be the Ubuntu Raring release. We will use Raring in the examples here. Note that the 32 bit arm architecture in Debian and Ubuntu is called armhf.
To populate the root filesystem we will use the debootstrap
tool provided by Debian and Ubuntu. Since we are creating an ARM root filesystem from a non-ARM host we will also be performing a two stage debootstrap using the qemu-user-static emulator to perform the second stage. If your host is an ARM system then it is possible to run debootstrap in a single pass however this is out of scope here.
First install the necessary host tools and perform the first pass:
# apt-get install debootstrap qemu-user-static binfmt-support # debootstrap --foreign --arch armhf raring /mnt http://ports.ubuntu.com/
Then copy the qemu static binary to the chroot and run the second pass:
# cp /usr/bin/qemu-arm-static /mnt/usr/bin/ # sudo chroot /mnt (chroot)# ./debootstrap/debootstrap --second-stage (chroot)# exit
If you want to create an arm64 filesystem then replace armhf with arm64 in the above. However arm64 support in Ubuntu is much newer so YMMV.
Tailoring the root filesystem
The debootstrap
creates a rather basic initial root filesystem which requires some tailoring before it can be used to boot a real system.
- Configure /etc/hostname
- Add a getty to the serial device
- Configure networking
TBD: This section could use more details
Installing Xen
If you have followed the Cross Compilation instructions then your build tree will include a dist/install
subdirectory which contains the binaries to be copied into your root filesystem. Simply copy these across:
# rsync -avp dist/install/ /mnt/
Using the root filesystem and incremental updates
The root filesystem is now complete, unmount it with:
# umount /mnt
Now you can use rootfs.img with your emulator or transfer your MMC card to your physical system.
To incrementally update your Xen binaries simply remount the device on your host system and copy new binaries across or use rsync
to update them across the network.