Building a Root File System using BusyBox

20 Dec

In this post we are going to build a root file system from scratch using Busybox and test it on QEMU.

Download the latest version of BusyBox (1.20.2 for the time being)

Extract the file and get into directory

$ cd busybox-1.20.2

Let’s use the default configuration and modify it according to our needs.

$ make ARCH=arm CROSS_COMPILE=arm-linux-  defconfig

$ make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig

Go to “BusyBox Settings –> Build Options” and enable the option “Build BusyBox as a static binary (no shared libs)

Under the same menu you go to “Open the menu “Installation  Options (make install behavior) –> (./_install) BusyBox installation prefix

This option means that the root file system will be installed inside _install directory. You can change it if you like. Let’s leave it as it is.

Start building our root file system.

$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install

If the compilation ends successfully the root file system will be in _install directory.

$ cd _install

It seems that some of the directories that we are accustomed to see in a normal Linux distro are missing. We will create them manually.

$ mkdir proc sys dev etc etc/init.d

$ cd ..

We will now create a bash script in order to mount some devices automatically after the boot.

$ touch etc/init.d/rcS

Modify its content as


mount -t proc none /proc

mount -t sysfs none /sys

/sbin/mdev -s

Now change the file’s mode as executable.

$ chmod +x etc/init.d/rcS

Then create an image of the root file system and compress it.

$ find . | cpio -o –format=newc > ../rootfs.img

$ cd ..

$ gzip –c rootfs.img > rootfs.img.gz

We had created a kernel image in the previous examples. You can copy the kernel image to BusyBox directory. We can try our fresh root file system on QEMU

$ qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append “root=/dev/ram rdinit=/sbin/init”

QEMU will boot the kernel and load the root file system. Just press “ENTER” to see shell prompt.



Posted by on December 20, 2012 in Linux


Tags: , , ,

8 responses to “Building a Root File System using BusyBox

  1. arungopal

    June 15, 2013 at 8:18 AM

    Good tutorial…how to do this for raspberry pi?Please give me some guidence for this…



  2. arungopal

    June 15, 2013 at 8:40 AM

    how to create root file system for the raspberry pi and how to cross compile he raspberry pi kernel and how to port kernel and root fie system for raspberry pi board.



  3. arungopal

    June 15, 2013 at 11:38 AM


    find . | cpio -o –format=newc > ../rootfs.img….
    when iam use this command it shows pwd is

    what is the error?Please tell me iam struct at this page.


    • emreboy

      June 15, 2013 at 1:23 PM

      Can you type the error msg? Try not to copy paste the command. Instead try typing it yourself. It might be due to some characters copied in a wrong way such as dash “-” or “|”. Before the keyword “format” there might be double dash. I.E: —

  4. arungopal

    June 17, 2013 at 6:17 AM

    gzip –c rootfs.img > rootfs.img.gz………
    when iam use this command it shows
    bash: rootfs.img.gz: Permission denied….iam use like this also but it shows same problem
    sudo bash: rootfs.img.gz: Permission denied…

    Please help me how to rectify this….




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: