Busybox Init Script
Written by Webmaster   
Wednesday, 25 April 2007
Image
Busybox
I'm assuming that you either are using the default inittab or have one of your own.

One of the biggest hurdles people have with Busybox is the rcS startup script. I have to admit that when you jump out of a managed environment (aka distro) to Busybox, you are entering wild and wooly territory. You will find my implementation below the fold.
For simple initialization of Busybox I used the following rcS script (which needs to be located in /etc/init.d).
 
#!/bin/sh

#### used for rcS - for telnet sessions do this in .profile
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export LD_LIBRARY_PATH=/usr/local/lib
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/usr/local/lib

#### mount proc
/bin/mount -t proc none /proc

#### remount our root device
/bin/mount -o remount /dev/root /
 
#### remove any pid's that might be hanging around
rm -rf /var/run/* 

#### mount our devpts
/bin/mount -t devpts devpts /dev/pts

#### mount tempfs
/bin/mount -n -t tmpfs tmpfs /dev/shm

#### busybox says to do this, but I'm not sure if it need to
chown root.root /bin/busybox
chmod 4755 /bin/busybox

#### optional loggers - good for development,
#### bad for release in the wild
#syslogd
#klogd
 
#### mount our sysfs
/bin/mount -t sysfs /sysfs /sys
#miniudev

#### create our loop back device
ifconfig lo 127.0.0.1 netmask 255.0.0.0

#### make sure our hotplug support is started
/etc/init.d/hotplug start

#### start up inetd
inetd
portmap

#### for brand new systems, we need to do an
#### ldconfig - this gets done once (ideally)
if [ -f /etc/ld.so.cache ]; then
  echo "do nothing" > /dev/nul;
else
  ldconfig
fi

#### start up telnet. Inetd doesn't seem to work right.
telnetd &

#### Or you can use dropbear which is larger,
#### but works out of the box
#dropbear &

You might notice that there is a program commented out called miniudev. It is a program that someone hacked up to find devices. I have found that it works, but in my case is not needed (usually if you know what you are doing, you don't need it). The other option is to create more devices than you need.
Last Updated ( Friday, 27 April 2007 )