|Deletions are marked like this.||Additions are marked like this.|
|Line 5:||Line 5:|
|Simplest and recommended way, use /sudorootstock to create the rootfs.||Simplest and recommended way, just run rootstock to create your rootfs.|
|Line 9:||Line 9:|
|If you're running Ubuntu 9.10 (karmic) or later, you may install the rootstock package; it will pull the appropriate dependencies.
TODO provide backports of rootstock.
|If you're running Ubuntu 9.10 (karmic) or later, you just need to install the rootstock package and it will pull the appropriate dependencies.|
This page describes building an armel Debian/Ubuntu root filesystem. It's only from scratch in that you are not starting from installer images, and you don't need target hardware to build it; the code is not rebuilt though, pre-build .deb packages are downloaded and installed instead.
Simplest and recommended way, just run rootstock to create your rootfs.
Rootstock will automate the creation of a rootfs tarball and exposes some config options to tweak the contents/setup.
If you're running Ubuntu 9.10 (karmic) or later, you just need to install the rootstock package and it will pull the appropriate dependencies.
If you install rootstock manually or if you are running it from a bzr checkout, you will also need:
qemu (see Installation/QemuEmulator )
a recent debootstrap: debootstrap_1.0.10ubuntu3_all.deb or newer
To create an armel rootfs tarball of, for instance, xubuntu-desktop:
sudo rootstock \ --fqdn myhostname \ --login ubuntu \ --password temppwd \ --imagesize 2G \ --seed xubuntu-desktop
Here's another example for ubuntu-desktop:
sudo rootstock \ --fqdn ubuntu \ --login ubuntu \ --password ubuntu \ --imagesize 3G \ --seed ubuntu-desktop
Some typical flags when developing headless (connecting over the network):
Note that you should edit /etc/network/interfaces and set up your network device on first login for this.
If you want a really light desktop (lxde), use:
The options --fqdn (or -f), --login (or -l) and --password (-p) are required for the initial setup. Calling the script with --help shows you all the additional options that can be used to change the setup of the created rootfs.
Change the password on the first login! The above examples use too simple passwords and will expose the password to other users of the machine where rootstock is run.
Building a root filesystem image instead of a tarball
In case you just need a root filesystem for use with qemu and you don't want a rootfs tarball, e.g. for usage with qemu, pass --notarball to rootstock:
sudo rootstock --fqdn qemu-test \ --login qemu \ --password qemupwd \ --notarball
You can also create a root filesystem from a tarball as follows:
Create the blank image file using dd; this example creates a 1GB image; use seek=3072 for 3GB or seek=2048 for 2GB etc.:
dd if=/dev/zero of=ubuntu-arm.img bs=1MB count=0 seek=1024
Create linux filesystem on the newly created image:
mkfs.ext4 -F ubuntu-arm.img
(You might want to pass some extra flags to mkfs to tweak the reserved blocks, labels, or other filesystem options.)
Loop mount the new image:
sudo mount -o loop ubuntu-arm.img /mnt
Extract the rootfs tarball inside the mounted dir and umount:
sudo tar -C /mnt -zxf armel-rootfs-200904151837.tgz sudo umount /mnt
Now you are set and ready to use the ubuntu-arm.img, see "Using a qemu image" below for the right command
Using a qemu image with full emulation
If you created your qemu image and want to start a fully emulated work environment (to compile packages or build applications), grab the kernel from:
and start qemu with the following command (indeed, you need to adjust the rootfs img name to whatever your image is called)
qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel ./vmlinuz -hda arm-rootfs.img -m 256 -append "root=/dev/sda mem=256M devtmpfs.mount=0 rw"
In the booted image you can then log in with the user and password you defined during image creation.
To be able to copy files from or to the host system it is helpful to install openssh-server on the host and use the scp command inside qemu.
Connect your emulated machine to a real network
When no option is specified QEMU uses a non privileged user mode network stack that gives the emulated machine access to the world. But you probably want to make your emulated machine accessible from the outside. It is possible by using the tap mode and bridging the tap interface with the network interface of the host machine.
The first thing to do is to active a bridge on your host machine. For that you have to modify the /etc/network/interfaces file as follow:
auto eth0 iface eth0 inet dhcp
auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_maxwait 0
Then you need to install the bridge-utils package and restart your network interface:
# apt-get install bridge-utils # ifdown eth0 # ifup br0
Create a script call /etc/qemu-ifup that will be executed upon the start of QEMU:
echo "Executing /etc/qemu-ifup" echo "Bringing up $1 for bridged mode..." sudo /sbin/ifconfig $1 0.0.0.0 promisc up echo "Adding $1 to br0..." sudo /usr/sbin/brctl addif br0 $1 sleep 2
As you probably don't want to execute QEMU as root, you need to create a qemu user group and authorize the brctl and ifconfig commands for users of the qemu via sudo. You need to add the following lines to /etc/sudoers (edit the file using visudo):
... Cmnd_Alias QEMU = /usr/sbin/brctl, /sbin/ifconfig %qemu ALL=NOPASSWD: QEMU
Tap networking requires that the tun module is loaded:
$ sudo modprobe tun
To load it automatically on boot, edit /etc/modules and add a line that says "tun" so that the file looks like this:
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. lp tun
Finally you can start your emulated machine using the following command
$ qemu-system-arm -M versatilepb -kernel ./vmlinuz-2.6.28-versatile -hda arm-rootfs.img -m 256 -append "root=/dev/sda mem=256M ro" -net nic,macaddr=00:16:3e:00:00:01 -net tap
You don't need to give a MAC address if you are emulating only one machine, as QEMU will use a default one. However if you have more than one emulated machine (don't forget QEMU can also emulate other architectures than ARM), you will have to specify a unique MAC address for each machine. I advise you to select an address from the range 00:16:3e:xx:xx:xx, which has been assigned to Xen.
Using qemu user mode emulation (with chroot)
If you don't want to use qemu with full emulation, you can still use qemu, but with user mode emulation together with chroot, to create the emulated work environment (to compile packages or build applications).
First extract the rootfs tarball:
mkdir /tmp/rootfs sudo tar -C /tmp/rootfs -zxf armel-rootfs-200904151837.tgz
Copy qemu-arm-static to the rootfs, in order to be able to use qemu:
sudo cp $(which qemu-arm-static) /tmp/rootfs/usr/bin/
Mount the /proc filesystem:
sudo mount -t proc proc /tmp/rootfs/proc
Set up resolv.conf:
sudo cp /etc/resolv.conf /tmp/rootfs/etc/resolv.conf
And finally get inside the emulated environment, with chroot:
sudo chroot /tmp/rootfs /bin/bash
Now you can easily install packages with apt-get and build the application you need/want.
Download a pre-built image
There is a pre-built image of karmic avaliable. It was built following steps above. It contains some stuff to compile and run software, such as gcc, g++, X libraries, FLTK, sqlite3, but there is no WM. You can add software using apt-get, if you want. You can use this image with Qemu or chroot. There is a little script inside the tarball to start Qemu without typing the entire command.
wget -c http://w3.impa.br/~gabrield/data/click.php?id=4 tar jxfv ubuntu-arm-development-rootfs.tar.bz2 chmod +x run.sh ./run.sh
The user to login is ubuntu and password temppwd.
Bugs and Problems
If you run into any problems, please contact "ogra" in #ubuntu-arm on irc.freenode.net or send a mail to firstname.lastname@example.org
If you run into an error please keep the log of your failed build
A known issue is that language-pack handling is not implemented yet, please install the packages for your language manually post install.