Inittab

From RidgeRun Developer Wiki

The last part of the Linux boot process is to identify and start process 0, the init process. In systems using Busybox, there is a special syntax for the /etc/inittab file used by the Busybox init process.

Common embedded Busybox inittab file

The following is an simple inittab file

::sysinit:/etc/rcS
::restart:/sbin/init
ttyS0::askfirst:-/bin/sh
  • The /etc/rcS script uses /etc/rc.sysv to run the scripts in /etc/rc.d in alphabetical order.
  • /sbin/init get rerun if the init process ever exits.
  • /bin/sh starts a console on ther /dev/ttyS0 serial port.

Starting console without requiring user to press enter

If you want to avoid the messge

Please press Enter to activate this console.

You can change the serial console entry by replacing askfirst with respawn

ttyS0::respawn:-/bin/sh

Allow init.d scripts to be interruptable

When debugging the start up scripts located in /etc/init.d (really the symbolic links to these files that is located in /etc/rc.d), it is helpful to be able to control-C, cntl-C, interrupt, or send a TERM signal (all the same, just different vocabulary). You can enable the startup scripts to be interruptable by changing the /etc/rcS line to

::sysinit:-/etc/rcS

You need to enable a Busybox configuration item:

CONFIG_FEATURE_INIT_SCTTY=y
File System Configuration -> 
   Select target's file system software ->  
      busybox ->  
        Busybox configuration -> 
          Init Utilities -> 
            init ->
              Run commands with leading dash with controlling tty 

The Busybox help says that using cttyhack applet may work better. That is left as an exercise for the reader.

Start console on a different serial port

In some hardware designs, the traditional serial port used for the console is connected to another device. You can change the console to


ttyS1::askfirst:-/bin/sh

Or add more than one console line depending on your hardware design.