Building custom root file system (RFS) for Beagle Bone Black using Busy Box

In the previous post from Abhilash, the partitions were created in the memory card using g-parted software. Ready-built RFS(root file system) is extracted into the second partition. In this post lets go through on how to build custom root file system (RFS) for Beagle bone black. By using Busy Box and other compiler tools.

Download the tarball of the latest Busy Box source code to host(local) computer.
extract the downloaded file to the current directory.
$ tar -xvf busybox-1.24.1.tar.bz2


Configure and Cross compile the Busy Box for armhf architecture.

Navigate to the extracted file and run commands to configure the busy box.

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
(assuming that cross-compiler tool-chain has already been configured and installed for arm architecture. which is explained in detail here)
In  the graphical screen which appear on your terminal, navigate to Busy box Settings -> Build Options and check the option Build Busy box as a static binary (no shared libs) . save the configuration and cross compile the source code.
 Compile the Busy box for armhf architecture and install it into RFS path in memory card.

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- CONFIG_PREFIX=/path/to/RFS install

Create Basic Directories Structure and Files

we can see necessary files and directories installed in the RFS partition of the memory card.
Now some directories, entry nodes and some initial files needed for linux system to up and running; (bin, sbin, usr and linuxrc).


Create directory /dev with files console,null and zero inside /dev.
$ mkdir dev
$ mknod dev/console c 5 1
$ mknod dev/null c 1 3
$ mknod dev/zero c 1 5

/lib /usr/lib.

Create kernel and user space library directories.
Copy all the cross compile tool chain libraries from host system to the /lib and /usr/lib directories in rfs partition.
$ mkdir lib usr/lib
$ rsync -a /opt/arm-linux-gnueabihf/lib/ ./lib/
$ rsync -a /opt/arm-linux-gnueabihf/lib/ ./usr/lib/

/proc /sys /root.

Create /proc, /sys, /root directories for the kernel to mount its virtual filesystem and entry nodes.

$ mkdir proc sys root


Create /etc directory and create inittab, fstab, hostname and passwd files inside /etc.

$ mkdir etc
$ vi /etc/inittab
null::sysinit:/bin/mount -a
null::sysinit:/bin/hostname -F /etc/hostname
null::respawn:/bin/cttyhack /bin/login root
$ vi /etc/fstab
proc  /proc proc  defaults  0 0
sysfs /sys  sysfs defaults  0 0

$ vi /etc/hostname

$ vi /etc/passwd


we have successfully completed custom minimal root file system (RFS) for Beagle bone black.

Leave a Reply

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