Xen ARM with Virtualization Extensions/RootFilesystem
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.
Although these instructions are primarily concerned with creating a root filesystem for use as domain 0 they could also be adapted for use as a guest root filesystem.
- Commands to run as root on the host
- Commands to run as your regular user on the host
- Commands to run as root within the chroot
- Commands to run as the regular user in the chroot
- Your regular username on the host (which is propagated to the chroot)
Preparing the device and filesystem
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
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 Saucy Salamander release. We will use Saucy 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 saucy /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.
Tailoring the root filesystem
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
- Simply write the hostname to
- Add a getty to the serial device
- On Ubuntu with upstart to add a getty on
/etc/init/$DEVICEand edit to change all instances of
- TBD: Other distros/initsystems
- Set a root password
passwdwithin the chroot.
- Configure networking
- Set up
/etc/network/interfaces. See [Network Configuration Examples (Xen 4.1+)]
- Configure apt
deb http://ports.ubuntu.com/ saucy main
TBD: This section could use more details
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.