Building Ubuntu rootfs for ARM

Most embedded filesystems(rootfs) are build with debootstrap or Linaro. Let’s explore a third possibility with core-ubuntu filesystems.

Steps to perform on any Debian based distribution (preferably)

1) Create some directory of your choice and download the core rootfs from Ubuntu server

mkdir ~/ubuntu-rootfs && cd ubuntu-rootfs
wget http://cdimage.ubuntu.com/ubuntu-core/releases/14.04.1/release/ubuntu-core-14.04-core-armhf.tar.gz

2) Extract the downloaded image with ‘sudo’ to allow ‘mknod’ commands to work

sudo tar -xpf ubuntu-core-14.04-core-armhf.tar.gz

You may remove the ubuntu-core-14.04-core-armhf.tar.gz file now.
Change directory cd .. or cd -

3) Install qemu-user-static from your package manager

sudo cp /usr/bin/qemu-arm-static usr/bin/

4) Mount proc, sys, dev, dev/pts to new fileystem. We will use a simple bash script for mounting and un-mounting. Download ch-mount.sh to present directory.

sudo bash ch-mount.sh -m ubuntu-rootfs/

5) Once you are in chroot environment, edit /etc/apt/sources.list and un-comment all the repositories except the ones starting with deb-src. You may use vim.tiny text editor

6) To update repositories, copy your system’s(host machine’s) /etc/resolv.conf to ~/ubuntu-rootfs/etc/resolv.conf .Set proxies if required.

7) Now update the repositories

apt-get update

8) Now install minimal packages required for X server and some core utils

apt-get install language-pack-en-base sudo ssh net-tools ethtool wireless-tools lxde xfce4-power-manager xinit xorg network-manager iputils-ping rsyslog lightdm-gtk-greeter alsa-utils gnome-mplayer lightdm bash-completion lxtask htop python-gobject-2 python-gtk2 synaptic --no-install-recommends

9) Now add a user of your choice and include him in suitable groups

adduser student && addgroup student adm && addgroup student sudo && addgroup student audio

10) Add hostname to /etc/hostname

echo ‘netbook’ > /etc/hostname

10) Add host entry in /etc/hosts

127.0.0.1    localhost
127.0.1.1    netbook

11) Also on few ARM devices, if you are using source from Android kernel, then you may have to do the following too

groupadd -g 3003 android_inet && addgroup student android_inet

12) Make X used by ‘anyuser’

dpkg-reconfigure x11-common

13) To allow /etc/resolv.conf to update DNS automatically based on network connection (as we changed that file previously to make internet work)

dpkg-reconfigure resolvconf

(Select ‘Yes’ to the first dialog box, i.e allow dynamic updates)
14) Set ‘timezone’

dpkg-reconfigure tzdata

15) Create directories for ‘firmware’ and ‘modules’ in ‘/lib'(ofcourse inside chroot) and copy your hardware specific files from host

cp -r /opt/out/modules/3.4.5 ~/ubuntu-rootfs/lib/modules

16)Optional. To enable login at serial console, add following in /etc/init/ttyS0.conf file and run sudo start ttyS0

start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]
respawn
exec /sbin/getty -L 115200 ttyS0 vt102

That’s all, you may customize even further if required.

  • Ashish Pal

    /usr/bin/groups: cannot find name for group ID 3003
    /usr/bin/groups: cannot find name for group ID 9997
    /usr/bin/groups: cannot find name for group ID 50183
    root@localhost:/# groupadd – 3003 android_inet
    Cannot open audit interface – aborting.
    root@localhost:/#

  • Ashish, to which command you got this output? Also, which Ubuntu version you are using as host?
    The step 11 is optional though.

  • Ashish Pal

    Android GnuRoot. Ubuntu 15.10 rootfs for arm. When I start this rootfs in Gnuroot, I’m getting those errors.

  • Android GNURoot, I believe download it’s own custom rootfs, which is adequate in most cases. Providing a self made rootfs may not be compatible. From your previous comment I can see it is expecting few groups which are not created by our tutorial, a simple fix would be looking into GNURoot’s scripts which create the rootfs and creating those nodes in /etc/groups.
    I hope this answer your query.
    This tutorial is mainly for creating a working ARM rootfs inside x86 host machine using qemu.

  • Ashish Pal

    Please guide me using ubuntu 15.10 rootfs in Android terminal using proot.

  • Sorry, I haven’t used proot. It looks promising though.

  • Pingback: What Is Rootfs In Android | android Skill()

  • Pingback: What Is Rootfs Android | android Skill()

  • Pingback: URL()

  • Pingback: How To Customize Weberp | Information()

  • Pingback: How To Install Weberp On Ubuntu | Information()