Building a small Debian root filesystem with Multistrap

There are several ways to build a root filesystem for an embedded Linux system: Buildroot and Open Embedded are the usual solutions to do this. They allow to fine tune the contents of your filesystem. The drawback is, in both cases, that you need to build everything from sources and this can take from tens of minutes to several hours.

Sometimes you don’t need all this flexibility and you just want to have a ready-to-use root filesystem, to which you just add a few extra programs. In this case using a distribution is a good solution. So let’s see what we need:

  • A binary distribution
  • Available on several architectures
  • Ability to generate a “small” root filesystem
  • A large choice of packages

Oh, I think it is a pretty good description of Debian!

Emdebian is a project to adapt Debian to embedded devices. A good description from the Debian wiki is:

“In short, what EmDebian does is wrap around the regular Debian package building tools to provide a more fine grained control over package selection, size, dependencies and content to enable creation of very small and efficient Debian packages for use on naturally resource limited embedded targets.”

And so, pretty recently (2009), Emdebian released Multistrap which is similar to Debootstrap but more appropriate for embedded devices. It seems better by the way it builds a system:

It works in a completely different way by simply using apt and dpkg, rather than avoiding to use them, which is how Debootstrap works.

And also more appropriate by its goals:

It is focused on producing rootfs images for devices, as opposed to chroots for existing machines

Practical case: build a root filesystem for the USB A9263 board from Calao Systems (arm926ejs based board).

A drawback of Multistrap is its limitation to Debian, but in fact it is also usable on any distribution based on Debian. In our case, we ran it on an Ubuntu 10.04 system.

First, let’s install Multistrap:

$sudo apt-get install multistrap dpkg-dev

Multistrap needs a config file. For our needs we just use the example one given by Embedian. Let’s name it multistrap.conf:


# space separated package list

Grip is the name of the lightweight Debian distro built by Emdebian.

Now we can run Multistrap:

$ multistrap -a armel -d $PWD/RFS -f multistrap.conf
em_multistrap 0.0.8 using multistrap.conf
Using foreign architecture: armel
em_multistrap building armel multistrap on 'amd64'
INF: Setting ./lib64 -> ./lib symbolic link.
Getting package lists: apt-get  -o Apt::Architecture=armel -o Apt::Get::AllowUnauthenticated=true -o Apt::Get::Download-Only=true -o Apt::Install-Recommends=false -o Dir=/home/mike/celf/multistrap/RFS/ -o Dir::Etc=/home/mike/celf/multistrap/RFS/etc/apt/ -o Dir::Etc::SourceList=/home/mike/celf/multistrap/RFS/etc/apt/sources.list.d/multistrap.sources.list -o Dir::State=/home/mike/celf/multistrap/RFS/var/lib/apt/ -o Dir::State::Status=/home/mike/celf/multistrap/RFS/var/lib/dpkg/status -o Dir::Cache=/home/mike/celf/multistrap/RFS/var/cache/apt/ update
Get:1 lenny Release.gpg [197B]
Ign lenny/main Translation-en_US
Get:2 lenny Release [21.4kB]
Ign lenny Release
Ign lenny/main Packages
Ign lenny/main Sources
Ign lenny/main Packages
Ign lenny/main Sources
Get:3 lenny/main Packages [293kB]
Get:4 lenny/main Sources [351kB]
Fetched 665kB in 0s (6,280kB/s)                     
Reading package lists... Done
W: GPG error: lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B5B7720097BB3B58
W: Duplicate sources.list entry lenny/main Packages (/home/mike/celf/multistrap/RFS/var/lib/apt/lists/www.emdebian.org_grip_dists_lenny_main_binary-armel_Packages)
Use of uninitialized value within %packages in join or string at /usr/sbin/em_multistrap line 294.
Use of uninitialized value within %keyrings in join or string at /usr/sbin/em_multistrap line 296.
apt-get -y  -o Apt::Architecture=armel -o Apt::Get::AllowUnauthenticated=true -o Apt::Get::Download-Only=true -o Apt::Install-Recommends=false -o Dir=/home/mike/celf/multistrap/RFS/ -o Dir::Etc=/home/mike/celf/multistrap/RFS/etc/apt/ -o Dir::Etc::SourceList=/home/mike/celf/multistrap/RFS/etc/apt/sources.list.d/multistrap.sources.list -o Dir::State=/home/mike/celf/multistrap/RFS/var/lib/apt/ -o Dir::State::Status=/home/mike/celf/multistrap/RFS/var/lib/dpkg/status -o Dir::Cache=/home/mike/celf/multistrap/RFS/var/cache/apt/ install balloon3-config base-files base-passwd bash bsdutils coreutils debianutils diff dpkg e2fslibs e2fsprogs findutils gcc-4.3-base grep grip-config gzip hostname initscripts libacl1 libattr1 libblkid1 libc6 libcap1 libcomerr2 libdevmapper1.02.1 libgcc1 liblocale-gettext-perl libncurses5 libpam-modules libpam-runtime libpam0g libselinux1 libsepol1 libslang2 libss2 libstdc++6 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libuuid1 libvolume-id0 login lsb-base makedev mawk mktemp mount ncurses-base ncurses-bin passwd perl-base procps sed sysv-rc sysvinit sysvinit-utils tar tzdata util-linux zlib1g
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  apt debconf debconf-i18n debian-archive-keyring dhcp3-client dhcp3-common gnupg gpgv ifupdown libbz2-1.0 libdb4.6 libncursesw5 libnewt0.52 libpopt0
  libreadline5 libssl0.9.8 libusb-0.1-4 lzma module-init-tools nano net-tools netbase ntpdate readline-common udev wget whiptail
The following NEW packages will be installed:
  apt balloon3-config base-files base-passwd bash bsdutils coreutils debconf debconf-i18n debian-archive-keyring debianutils dhcp3-client dhcp3-common diff
  dpkg e2fslibs e2fsprogs findutils gcc-4.3-base gnupg gpgv grep grip-config gzip hostname ifupdown initscripts libacl1 libattr1 libblkid1 libbz2-1.0 libc6
  libcap1 libcomerr2 libdb4.6 libdevmapper1.02.1 libgcc1 liblocale-gettext-perl libncurses5 libncursesw5 libnewt0.52 libpam-modules libpam-runtime libpam0g
  libpopt0 libreadline5 libselinux1 libsepol1 libslang2 libss2 libssl0.9.8 libstdc++6 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl
  libusb-0.1-4 libuuid1 libvolume-id0 login lsb-base lzma makedev mawk mktemp module-init-tools mount nano ncurses-base ncurses-bin net-tools netbase
  ntpdate passwd perl-base procps readline-common sed sysv-rc sysvinit sysvinit-utils tar tzdata udev util-linux wget whiptail zlib1g
0 upgraded, 87 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.4MB of archives.
After this operation, 48.4MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libstdc++6 libbz2-1.0 readline-common libncurses5 libreadline5 libusb-0.1-4 zlib1g gpgv gnupg debian-archive-keyring apt debianutils dhcp3-common
  libattr1 libacl1 libselinux1 coreutils lzma dpkg perl-base liblocale-gettext-perl libtext-iconv-perl libtext-charwidth-perl libtext-wrapi18n-perl
  debconf-i18n debconf dhcp3-client sed ncurses-bin lsb-base module-init-tools libssl0.9.8 wget hostname net-tools ifupdown mawk libncursesw5 nano netbase
  libcap1 ntpdate libpam-runtime libpam0g libdb4.6 libpam-modules passwd libvolume-id0 udev libslang2 libnewt0.52 libpopt0 whiptail grip-config
  gcc-4.3-base libgcc1 libc6 base-passwd base-files bash diff libcomerr2 e2fslibs libuuid1 libblkid1 libss2 e2fsprogs findutils grep gzip login mktemp
  mount libsepol1 sysvinit-utils initscripts sysv-rc sysvinit tar tzdata util-linux balloon3-config bsdutils libdevmapper1.02.1 makedev ncurses-base procps
Authentication warning overridden.
Get:1 lenny/main libstdc++6 4.3.2-1.1em1 [268kB]
Get:2 lenny/main libbz2-1.0 1.0.5-1em1 [37.2kB]
Get:3 lenny/main readline-common 5.2-3.1em1 [3,202B]
Get:4 lenny/main libncurses5 5.7+20081213-1em1 [165kB]
Get:5 lenny/main libreadline5 5.2-3.1em1 [108kB]
Get:6 lenny/main libusb-0.1-4 2:0.1.12-13em1 [13.7kB]
Get:7 lenny/main zlib1g 1: [48.1kB]
Get:8 lenny/main gpgv 1.4.9-3+lenny1em1 [139kB]
Get:9 lenny/main gnupg 1.4.9-3+lenny1em1 [533kB]
Get:10 lenny/main debian-archive-keyring 2010.08.28~lenny1em1 [17.9kB]
Get:11 lenny/main apt [514kB]
Get:12 lenny/main debianutils 2.30em1 [23.4kB]
Get:13 lenny/main dhcp3-common 3.1.1-6+lenny4em1 [157kB]
Get:14 lenny/main libattr1 1:2.4.43-2em1 [7,706B]
Get:15 lenny/main libacl1 2.2.47-2em1 [14.0kB]
Get:16 lenny/main libselinux1 2.0.65-5em1 [50.0kB]
Get:17 lenny/main coreutils 6.10-6em1 [1,162kB]
Get:18 lenny/main lzma 4.43-14em1 [51.0kB]
Get:19 lenny/main dpkg 1.14.29em1 [405kB]
Get:20 lenny/main perl-base 5.10.0-19lenny2em1 [905kB]
Get:21 lenny/main liblocale-gettext-perl 1.05-4em1 [11.0kB]
Get:22 lenny/main libtext-iconv-perl 1.7-1+b1em1 [11.2kB]
Get:23 lenny/main libtext-charwidth-perl 0.04-5+b1em1 [6,656B]
Get:24 lenny/main libtext-wrapi18n-perl 0.06-6em1 [4,444B]
Get:25 lenny/main debconf-i18n 1.5.24em1 [2,882B]
Get:26 lenny/main debconf 1.5.24em1 [110kB]
Get:27 lenny/main dhcp3-client 3.1.1-6+lenny4em1 [185kB]
Get:28 lenny/main sed 4.1.5-6em1 [23.8kB]
Get:29 lenny/main ncurses-bin 5.7+20081213-1em1 [70.8kB]
Get:30 lenny/main lsb-base 3.2-20em1 [5,888B]
Get:31 lenny/main module-init-tools 3.4-1em1 [44.5kB]
Get:32 lenny/main libssl0.9.8 0.9.8g-15+lenny8em1 [713kB]
Get:33 lenny/main wget 1.11.4-2+lenny2em1 [116kB]
Get:34 lenny/main hostname 2.95em1 [5,808B]
Get:35 lenny/main net-tools 1.60-22em1 [156kB]
Get:36 lenny/main ifupdown 0.6.8+nmu1em1 [18.9kB]
Get:37 lenny/main mawk 1.3.3-11.1em1 [51.2kB]
Get:38 lenny/main libncursesw5 5.7+20081213-1em1 [187kB]
Get:39 lenny/main nano 2.0.7-5em1 [83.6kB]
Get:40 lenny/main netbase 4.34em1 [11.6kB]
Get:41 lenny/main libcap1 1:1.10-14em1 [7,574B]
Get:42 lenny/main ntpdate 1:4.2.4p4+dfsg-8lenny3em1 [36.1kB]
Get:43 lenny/main libpam-runtime 1.0.1-5+lenny1em1 [7,786B]
Get:44 lenny/main libpam0g 1.0.1-5+lenny1em1 [41.0kB]
Get:45 lenny/main libdb4.6 4.6.21-11em1 [531kB]
Get:46 lenny/main libpam-modules 1.0.1-5+lenny1em1 [160kB]
Get:47 lenny/main passwd 1:4.1.1-6+lenny1em1 [267kB]
Get:48 lenny/main libvolume-id0 0.125-7+lenny3em1 [18.2kB]
Get:49 lenny/main udev 0.125-7+lenny3em1 [145kB]
Get:50 lenny/main libslang2 2.1.3-3em1 [266kB]
Get:51 lenny/main libnewt0.52 0.52.2-11.3+lenny1em1 [36.7kB]
Get:52 lenny/main libpopt0 1.14-4em1 [22.3kB]
Get:53 lenny/main whiptail 0.52.2-11.3+lenny1em1 [11.7kB]
Get:54 lenny/main grip-config 0.1.2em1 [11.5kB]
Get:55 lenny/main gcc-4.3-base 4.3.2-1.1em1 [5,496B]
Get:56 lenny/main libgcc1 1:4.3.2-1.1em1 [23.7kB]
Get:57 lenny/main libc6 2.7-18lenny4em1 [4,410kB]
Get:58 lenny/main base-passwd 3.5.20em1 [11.5kB]
Get:59 lenny/main base-files 5lenny7em1 [49.2kB]
Get:60 lenny/main bash 3.2-4em1 [364kB]
Get:61 lenny/main diff 2.8.1-12em1 [59.6kB]
Get:62 lenny/main libcomerr2 1.41.3-1em1 [6,366B]
Get:63 lenny/main e2fslibs 1.41.3-1em1 [91.3kB]
Get:64 lenny/main libuuid1 1.41.3-1em1 [10.8kB]
Get:65 lenny/main libblkid1 1.41.3-1em1 [21.6kB]
Get:66 lenny/main libss2 1.41.3-1em1 [10.9kB]
Get:67 lenny/main e2fsprogs 1.41.3-1em1 [234kB]
Get:68 lenny/main findutils 4.4.0-2em1 [160kB]
Get:69 lenny/main grep 2.5.3~dfsg-6em1 [128kB]
Get:70 lenny/main gzip 1.3.12-6+lenny1em1 [44.0kB]
Get:71 lenny/main login 1:4.1.1-6+lenny1em1 [50.6kB]
Get:72 lenny/main mktemp 1.5-9em1 [5,772B]
Get:73 lenny/main mount [69.3kB]
Get:74 lenny/main libsepol1 2.0.30-2em1 [96.4kB]
Get:75 lenny/main sysvinit-utils 2.86.ds1-61em1 [17.8kB]
Get:76 lenny/main initscripts 2.86.ds1-61em1 [33.6kB]
Get:77 lenny/main sysv-rc 2.86.ds1-61em1 [13.7kB]
Get:78 lenny/main sysvinit 2.86.ds1-61em1 [46.8kB]
Get:79 lenny/main tar 1.20-1+lenny1em1 [148kB]
Get:80 lenny/main tzdata 2010j-0lenny1em1 [749kB]
Get:81 lenny/main util-linux [293kB]
Get:82 lenny/main balloon3-config 0.6 [2,400B]
Get:83 lenny/main bsdutils 1: [17.0kB]
Get:84 lenny/main libdevmapper1.02.1 2:1.02.27-4em1 [44.1kB]
Get:85 lenny/main makedev 2.3.1-88em1 [15.8kB]
Get:86 lenny/main ncurses-base 5.7+20081213-1em1 [16.4kB]
Get:87 lenny/main procps 1:3.2.7-11em1 [160kB]
Fetched 15.4MB in 3s (4,819kB/s)
Download complete and in download only mode
I: Calculating obsolete packages
I: Extracting apt_0.7.20.2+lenny2em1_armel.deb...
 -> Processing conffiles for apt
I: Extracting balloon3-config_0.6_all.deb...
I: Extracting base-files_5lenny7em1_armel.deb...
 -> Processing conffiles for base-files
I: Extracting base-passwd_3.5.20em1_armel.deb...
I: Extracting bash_3.2-4em1_armel.deb...
 -> Processing conffiles for bash
I: Extracting bsdutils_1%3a2.13.1.1-1em1_armel.deb...
I: Extracting coreutils_6.10-6em1_armel.deb...
I: Extracting debconf-i18n_1.5.24em1_all.deb...
I: Extracting debconf_1.5.24em1_all.deb...
 -> Processing conffiles for debconf
I: Extracting debian-archive-keyring_2010.08.28~lenny1em1_all.deb...
I: Extracting debianutils_2.30em1_armel.deb...
I: Extracting dhcp3-client_3.1.1-6+lenny4em1_armel.deb...
 -> Processing conffiles for dhcp3-client
I: Extracting dhcp3-common_3.1.1-6+lenny4em1_armel.deb...
I: Extracting diff_2.8.1-12em1_armel.deb...
I: Extracting dpkg_1.14.29em1_armel.deb...
 -> Processing conffiles for dpkg
I: Extracting e2fslibs_1.41.3-1em1_armel.deb...
I: Extracting e2fsprogs_1.41.3-1em1_armel.deb...
 -> Processing conffiles for e2fsprogs
I: Extracting findutils_4.4.0-2em1_armel.deb...
I: Extracting gcc-4.3-base_4.3.2-1.1em1_armel.deb...
I: Extracting gnupg_1.4.9-3+lenny1em1_armel.deb...
I: Extracting gpgv_1.4.9-3+lenny1em1_armel.deb...
I: Extracting grep_2.5.3~dfsg-6em1_armel.deb...
I: Extracting grip-config_0.1.2em1_all.deb...
I: Extracting gzip_1.3.12-6+lenny1em1_armel.deb...
I: Extracting hostname_2.95em1_armel.deb...
I: Extracting ifupdown_0.6.8+nmu1em1_armel.deb...
 -> Processing conffiles for ifupdown
I: Extracting initscripts_2.86.ds1-61em1_armel.deb...
 -> Processing conffiles for initscripts
I: Extracting libacl1_2.2.47-2em1_armel.deb...
I: Extracting libattr1_1%3a2.4.43-2em1_armel.deb...
I: Extracting libblkid1_1.41.3-1em1_armel.deb...
I: Extracting libbz2-1.0_1.0.5-1em1_armel.deb...
I: Extracting libc6_2.7-18lenny4em1_armel.deb...
 -> Processing conffiles for libc6
I: Extracting libcap1_1%3a1.10-14em1_armel.deb...
I: Extracting libcomerr2_1.41.3-1em1_armel.deb...
I: Extracting libdb4.6_4.6.21-11em1_armel.deb...
I: Extracting libdevmapper1.02.1_2%3a1.02.27-4em1_armel.deb...
I: Extracting libgcc1_1%3a4.3.2-1.1em1_armel.deb...
I: Extracting liblocale-gettext-perl_1.05-4em1_armel.deb...
I: Extracting libncurses5_5.7+20081213-1em1_armel.deb...
I: Extracting libncursesw5_5.7+20081213-1em1_armel.deb...
I: Extracting libnewt0.52_0.52.2-11.3+lenny1em1_armel.deb...
I: Extracting libpam-modules_1.0.1-5+lenny1em1_armel.deb...
 -> Processing conffiles for libpam-modules
I: Extracting libpam-runtime_1.0.1-5+lenny1em1_all.deb...
 -> Processing conffiles for libpam-runtime
I: Extracting libpam0g_1.0.1-5+lenny1em1_armel.deb...
I: Extracting libpopt0_1.14-4em1_armel.deb...
I: Extracting libreadline5_5.2-3.1em1_armel.deb...
I: Extracting libselinux1_2.0.65-5em1_armel.deb...
I: Extracting libsepol1_2.0.30-2em1_armel.deb...
I: Extracting libslang2_2.1.3-3em1_armel.deb...
I: Extracting libss2_1.41.3-1em1_armel.deb...
I: Extracting libssl0.9.8_0.9.8g-15+lenny8em1_armel.deb...
I: Extracting libstdc++6_4.3.2-1.1em1_armel.deb...
I: Extracting libtext-charwidth-perl_0.04-5+b1em1_armel.deb...
I: Extracting libtext-iconv-perl_1.7-1+b1em1_armel.deb...
I: Extracting libtext-wrapi18n-perl_0.06-6em1_all.deb...
I: Extracting libusb-0.1-4_2%3a0.1.12-13em1_armel.deb...
I: Extracting libuuid1_1.41.3-1em1_armel.deb...
I: Extracting libvolume-id0_0.125-7+lenny3em1_armel.deb...
I: Extracting login_1%3a4.1.1-6+lenny1em1_armel.deb...
 -> Processing conffiles for login
I: Extracting lsb-base_3.2-20em1_all.deb...
I: Extracting lzma_4.43-14em1_armel.deb...
I: Extracting makedev_2.3.1-88em1_all.deb...
I: Extracting mawk_1.3.3-11.1em1_armel.deb...
I: Extracting mktemp_1.5-9em1_armel.deb...
I: Extracting module-init-tools_3.4-1em1_armel.deb...
 -> Processing conffiles for module-init-tools
I: Extracting mount_2.13.1.1-1em1_armel.deb...
I: Extracting nano_2.0.7-5em1_armel.deb...
 -> Processing conffiles for nano
I: Extracting ncurses-base_5.7+20081213-1em1_all.deb...
 -> Processing conffiles for ncurses-base
I: Extracting ncurses-bin_5.7+20081213-1em1_armel.deb...
I: Extracting net-tools_1.60-22em1_armel.deb...
I: Extracting netbase_4.34em1_all.deb...
 -> Processing conffiles for netbase
I: Extracting ntpdate_1%3a4.2.4p4+dfsg-8lenny3em1_armel.deb...
 -> Processing conffiles for ntpdate
I: Extracting passwd_1%3a4.1.1-6+lenny1em1_armel.deb...
 -> Processing conffiles for passwd
I: Extracting perl-base_5.10.0-19lenny2em1_armel.deb...
I: Extracting procps_1%3a3.2.7-11em1_armel.deb...
 -> Processing conffiles for procps
I: Extracting readline-common_5.2-3.1em1_all.deb...
I: Extracting sed_4.1.5-6em1_armel.deb...
I: Extracting sysv-rc_2.86.ds1-61em1_all.deb...
I: Extracting sysvinit-utils_2.86.ds1-61em1_armel.deb...
I: Extracting sysvinit_2.86.ds1-61em1_armel.deb...
I: Extracting tar_1.20-1+lenny1em1_armel.deb...
 -> Processing conffiles for tar
I: Extracting tzdata_2010j-0lenny1em1_all.deb...
I: Extracting udev_0.125-7+lenny3em1_armel.deb...
 -> Processing conffiles for udev
I: Extracting util-linux_2.13.1.1-1em1_armel.deb...
 -> Processing conffiles for util-linux
I: Extracting wget_1.11.4-2+lenny2em1_armel.deb...
 -> Processing conffiles for wget
I: Extracting whiptail_0.52.2-11.3+lenny1em1_armel.deb...
I: Extracting zlib1g_1%3a1.2.3.3.dfsg-12em1_armel.deb...
I: Unpacking complete.
Get:1 lenny Release.gpg [197B]
Ign lenny/main Translation-en_US
Get:2 lenny Release [21.4kB]
Ign lenny Release
Ign lenny/main Packages
Ign lenny/main Sources
Ign lenny/main Packages
Ign lenny/main Sources
Hit lenny/main Packages
Hit lenny/main Sources
Fetched 198B in 0s (2,020B/s)
Reading package lists... Done
W: GPG error: lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B5B7720097BB3B58

Multistrap system installed successfully in /home/mike/celf/multistrap/RFS/.

Let’s explain the parameters:

  • armel is the architecture, for our example: arm in little endian
  • -d $PWD/RFS is the output directory containing the root filesystem. Be careful to pass an absolute path.
  • -f multistrap.conf is the name of the configuration file

If you look at RFS/dev, you will see that there are no device files in it. This will be a problem at boot time, unless you build a kernel with the below options:


Thanks to these parameters, the kernel will automatically mount a tmpfs filesystem on /dev, and will populate it with devices present on the system.

Now we have a root filesystem, but we still need to run the package configuration scripts to make it usable. The packages were installed, but their configuration scripts couldn’t be executed, because they can only run on the target architecture.

The easiest way to do this is to use NFS. On the host side, you need to export the root filesystem directory through NFS. On the target side you have to select /bin/sh for the init process. A typical kernel command could be:

console=ttyS0,115200 root=/dev/nfs nfsroot= rw ip= init=/bin/sh

Then boot your board. You should reach a command line.

First mount /proc:

mount -t proc nodev /proc

Then configure your packages using this command line:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin  dpkg --configure -a 

You will get a few questions about localization for tzdata, then the packages will be configured.

Finally go back to your host to change the RFS/etc/inittab file by uncommenting the below line and modifying it according to your serial console configuration (usually 115200). For example, replace

#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100


T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100

As we built this root filesystem as a normal user we may have problems with some setuid programs, which need to be owned by the root user. So let’s change the ownership of some directories:

sudo chown root:root -R RFS/bin RFS/usr/bin RFS/sbin RFS/usr/sbin

The last trick is to delete the root password by modifying RFS/etc/passwd, by replacing




You can now reboot your system without the init=/bin/sh kernel parameter. We now have a ready to use embedded Linux root filesystem with the power of Debian.

Other things to fix and do:

  • Configure the /etc/resolv.conf file to be able to connect to the Internet.
  • Configure the gateway in the ip= kernel parameter (ip=client-ip:server-ip:gw-ip:netmask:hostname:device:autoconf). For example:
    bootargs=console=ttyS0,115200n8 root=/dev/nfs ip= nfsroot=
  • Install other packages such as mtd-utils and vim
  • Install kernel modules (either manually or through a kernel package)
  • Add a new user
  • Create a minimum /etc/fstab file

You now have a Debian system for which it is very easy to add new software, and which can be configured in a very familiar way. That’s great to make product prototypes, small, low-power and secure servers for home or office use, and in some cases, even real products.

Author: Gregory Clement

Gregory is an embedded Linux, kernel and realtime engineer at Bootlin, which he joined in 2010. Since 2002, he has acquired vast on the field experience in porting and operating embedded Linux, in particular for industrial and transportation customers.

11 thoughts on “Building a small Debian root filesystem with Multistrap”

  1. Interesting article!
    I’ll keep this solution in mind when I would need to quickly build a rootfs for testing

  2. Great article but if you try to print it the text for the sample run (in grey boxes)
    doesn’t print correctly?

  3. followed the process up to the lines…

    Then boot your board. You should reach a command line. <= got it
    First mount /proc:
    mount -t proc nodev /proc

    sh-3.2# mount -t proc nodev /proc
    warning: can't open /etc/fstab: No such file or directory

    What am I missing?

  4. Opps… Noob post mistake
    mount -t proc nodev /proc
    …. actually worked first time and after second boot cycle gave no warning …

  5. Hi all,

    I wanted to try this (as many others, probably) and I guess I’m missing something.
    { booting over nfs with DHCP}

    Posting some (‘stripped’) log’s …

    sh-3.2# mount -t proc nodev /proc
    warning: can’t open /etc/fstab: No such file or directory

    after a second power cycle

    sh-3.2# mount -t proc nodev /proc
    seems to work.

    sh-3.2# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin dpkg
    –configure -a
    dpkg: unable to set ownership of triggers state directory `/var/lib/dpkg/trigger
    s/’: Operation not permitted

    after a third power cycle the dpkg –configure -a does not complain about ownership..

    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin dpkg
    –configure -a

    now I’m getting some warnings .. but I don’t think this will harm.

    Finally go back to your host to change the RFS/etc/inittab.. But this file is misssing…!!!

    Any hints/tips …

    Regards, Noel

  6. Noel,
    I don’t know if you still need help… but here are some general ideas..

    I’d say that the best way to skip many problems is to create your nfs rootfs with root as the owner. Meaning you should use sudo or su when you run multistrap.
    sudo multistrap -a armel -d $PWD/RFS -f multistrap.conf

    I had many issues with sid and ownership until I did this. Also I use sudo when editing files on my host nfs machine to maintain root ownership.

    Also, I keep a list of all the files I have updated including networking, initab, fstab, passwords, and usernames. I then just run a script to load all these setup files into a new rootfs.

    Another tip is to not power cycle the board the first few times until you are confident it is configured correctly. I got better results if I used “shutdown -r now” during my first several cycles. Its not critical or totally necessary but the process seems to be smoother and more predictable.

    Good Luck,

  7. Hi!

    I’m having problems building my filesystem with multistrap.

    If I enter “mount -t proc nodev /proc” root privileges are required.

    sh-3.2# mount -t proc nodev /proc
    mount: only root can do that

    Any ideas?

  8. I’m facing some problems with multistrap: lenny seems no to be available on the server:

    Ign lenny Release.gpg
    Ign lenny/main Translation-en_US
    Ign lenny Release
    Ign lenny/main Packages
    Ign lenny/main Sources
    Ign lenny/main Packages
    Ign lenny/main Sources
    Err lenny/main Packages
    404 Not Found
    Err lenny/main Sources
    404 Not Found
    W: Failed to fetch 404 Not Found

    W: Failed to fetch 404 Not Found

    E: Some index files failed to download, they have been ignored, or old ones used instead.

    so I changed the suite to squeeze but I get exactly the same output. It seems that the option for suite has no meaning/action in the config file. Any ideas?
    (I’m running Ubuntu 10.04 on an amd64 arch, multistrap 2.0.4) thanks for any response!

    1. Thomas,
      I was also facing the same problem and fixed it by modifiying multibootstrp.conf file.

      # space separated package list

Leave a Reply to Rooney Cancel reply

Your email address will not be published. Required fields are marked *