Showing posts with label busybox root file system. Show all posts
Showing posts with label busybox root file system. Show all posts

Sunday, December 6, 2009

Busybox

1. Download the source and patches from the busybox website.

http://www.busybox.net/download.html

The version at the time of writing this is 1.14.1.

2. untar the sources to the directory where you will run the build.

3. patch the sources

patch -p0 <>.patch
e.g patch -p0 <>

4. config the busybox using your favourite config method. I prefer to use xconfig.

5. make your day :) -------- run make

6. once the make has run successful , you would want to install the busybox in a seperate directory which you can later ready to use as the rootfs.

make CONFIG_PREFIX=~/busybox/target install

where I am installing busybox in the /home/nemesis/busybox/target directory

7 cd to the install directory

cd ~/busybox/target

8.
There isn't a great deal there

ls -al would return

sbin, bin , usr and linuxrc (a symbolic link to /bin/busybox)



9. Create the dev, dev/pts, etc, etc/init.d, lib, mnt, opt, proc, root, sys, tmp, var, and var/log directories. Also create the device node for the initial console

mkdir dev etc lib mnt opt proc root sys tmp var debug
mkdir etc/init.d
mkdir var/log

sudo mknod dev/console c 5 1
sudo mknod dev/null c 1 3


10. Mount proc and /dev/pts at boot time
===========================

edit /etc/fstab for these filesystems



11. Shared library and library loader
==========================
We still need the
---------- shared libraries (from your toolchain)
---------- library loader (e.g ld-linux.so.3 in the listing below)


nemesis@nemesis-laptop:~/codesourcery/arm-2009q3/arm-none-linux-gnueabi/libc/lib$ ls
ld-2.10.1.so libdl-2.10.1.so libnss_dns.so.2 libresolv-2.10.1.so
ld-linux.so.3 libdl.so.2 libnss_files-2.10.1.so libresolv.so.2
libanl-2.10.1.so libgcc_s.so libnss_files.so.2 librt-2.10.1.so
libanl.so.1 libgcc_s.so.1 libnss_hesiod-2.10.1.so librt.so.1
libBrokenLocale-2.10.1.so libm-2.10.1.so libnss_hesiod.so.2 libSegFault.so
libBrokenLocale.so.1 libmemusage.so libnss_nis-2.10.1.so libthread_db-1.0.so
libc-2.10.1.so libm.so.6 libnss_nisplus-2.10.1.so libthread_db.so.1
libcidn-2.10.1.so libnsl-2.10.1.so libnss_nisplus.so.2 libutil-2.10.1.so
libcidn.so.1 libnsl.so.1 libnss_nis.so.2 libutil.so.1
libcrypt-2.10.1.so libnss_compat-2.10.1.so libpcprofile.so
libcrypt.so.1 libnss_compat.so.2 libpthread-2.10.1.so
libc.so.6 libnss_dns-2.10.1.so libpthread.so.0


--- that's an aweful lot. Copying them indiscriminately will cause our rootfs to be bloated (something we don't want). So just pick what you need. And And And ofcourse strip these libraries :)

nemesis@nemesis-laptop:~/busybox/target/lib$ ~/codesourcery/arm-2009q3/bin/arm-none-linux-gnueabi-strip *


Thats the minimal set for the rootfs


12. Kernel Modules
=================
Now it is time to get our dear modules.

--- go to the kernel build directory
--- issue the following command : make modules

after it has completed successfully , we need to install the modules in our rootfs. Elementary my dear watson!

make INSTALL_MOD_PATH=/path/to/rootfs modules_install

Once we are out of the debugging phase, we would like to strip the modules to slim down.

cd /path/to/rootfs/lib/modules
arm-none-linux-gnueabi-strip `find . –name “*.ko”`