NSLU2-Linux
view · edit · print · history

This page is an attempt to document the NSLU2 Linux boot sequence.

This is helpful in figuring out where various services start, and where the diversion script hooks are.

It's not elegant, but it has been helpful to me.

Boot Sequence.xls


Unslung 6.10 boot sequence

This is a list of the events that happen at boot for Unslung 6.10. It may not be accurate for previous versions.

Most of these scripts live in /etc/rc.d. Nearly all scripts can be diverted with a same-named script in /unslung.

  • /linuxrc is run from the initrd image. If the NSLU2 has been properly unslung, it will pivot to the appropriate root disk (usually /dev/sda1), which means that the correct root partition will be mounted at / and the initrd will move to /initrd. After pivoting, it will invoke /bin/init.
  • init checks /etc/inittab, which is used to start syslogd and klogd.
  • init calls /etc/rc (can be diverted by /unslung/rc), which in turn:
    • Mounts proc and usbdevfs filesystems.
    • Remounts the root filesystem read-write.
    • Configures the loopback interface and loads kernel modules for the Ethernet driver.
    • Calls /etc/rc.d/rc.sysinit (can be diverted by /unslung/rc.sysinit) to start other services, which in turn:
      • Calls /etc/rc.d/rc.functions to load check_status function, used to print status messages ("OK" or "FAILED") to console right after each service or auxiliar script is invoked.
      • Loads network settings from /etc/sysconfig/network.
      • Creates ramdisks for /dev and /var, if the system is running from internal flash.
      • Clean up /var/run and /var/lock, in case something was left behind from a previous crash.
      • Creates empty /var/log/wtmp and /var/run/utmp files, if they do not exist already.
      • Sets the machine hostname.
      • Calls /etc/rc.d/rc.modules to load kernel modules (can be diverted by /unslung/rc.modules), which in turn:
        • Loads modules for power and reset buttons, real time clock and NTFS file system (ufsd).
        • Loads any NLS code page modules found under /lib/modules/2.4.22-xfs/kernel/fs/nls/.
      • Calls /etc/rc.d/rc.locmods, which is not used (empty file).
      • Calls /etc/rc.d/rc.lan, which is not used (empty file).
      • Calls /etc/rd.c/rc.network to configure network (can be diverted by /unslung/rc.network), which in turn:
        • Calls /sbin/ifup to do actual network setup, that:
          • Loads /etc/sysconfig/network to configure network variables (global).
          • Loads /etc/sysconfig/network-scripts/ifcfg-ixp0 for network configuration variables (interface).
          • Creates new /etc/hosts file.
          • Configures the ixp0 interface, either using the DHCP client /sbin/udhcpc or using a static address, according to settings.
          • Adds a multicast route to 239.0.0.0/8.
      • Calls /etc/rc.d/rc.1 (can be diverted by /unslung/rc.1), note that Unslung does not have the actual concept of different run levels. This script, in turn:
        • Calls /etc/rc.d/rc.bootbin, which is simply a call to the /sbin/rc.bootbin Linksys binary, a program that uses /etc/CGI_ds.conf for handling configuration variables set by web setup GUI (/etc/rc.d/rc.bootbin can by diverted by /unslung/rc.bootbin)
        • Calls /etc/rc.d/rc.rstimezone to install local timezone file, get time from hwclock (can be diverted by /unslung/rc.rstimezone).
        • Calls /etc/rc.d/rc.reset_usrgrpshare to set up passwords, user and group information for Samba shares using a Linksys binary utility at /usr/sbin/reset_ugs (can be diverted by /unslung/rc.reset_usrgrpshare).
        • Calls /etc/rc.d/rc.thttpd to start http server for Setup GUI (can be diverted by /unslung/rc.thttpd).
        • Calls /etc/rc.d/rc.samba to start the Samba server (can be diverted by /unslung/rc.samba).
        • Calls /etc/rc.d/rc.xinetd to start the inetd server (can be diverted by /unslung/rc.xinetd).
        • Sets up a ramfs for /tmp, if the machine is running from the internal flash.
        • Calls /etc/rc.d/rc.quickset for USB setup and starting onetouch_detect (can be diverted by /unslung/rc.quickset).
        • Calls /etc/rc.d/rc.crond to start crond (can be diverted by /unslung/rc.crond).
        • Calls /etc/rc.d/rc.local to fix ownership of /share and other miscellaneous setup (can be diverted by /unslung/rc.local), that includes:
          • Calls /etc/rc.d/rc.quota to check for user quotas (can be diverted by /unslung/rc.quota).
        • Calls /etc/rc.d/rc.optware-start, which is a driver to run startup scripts for Optware packages, located at /opt/etc/init.d/S??*. Note that the individual .sh files are inlined (can be diverted by /unslung/rc.optware-start).
        • Calls /etc/rc.d/rc.bootdisk, which tries to locate and run scripts from a (Linksys) mounted FAT/NTFS partition if running from internal flash.

(UseTheBootMechanism)


Disabled scripts

  • The call to /etc/rc.d/rc.syslogd at /etc/rc.d/rc.sysinit is commented, syslogd and klog are started from inittab.
  • A call to /usr/sbin/TelnetPassword, a binary utility from Linksys that apparently checks /etc/passwd for an account named ourtelnetrescuer (probable leftover from Linksys development) is commented out in /etc/rc.d/rc.1.
  • A call to /usr/sbin/download, a binary utility from Linksys (watch for firmware updates?) is commented in /etc/rc.d/rc.1.

Linksys and Unslung halt sequence

  • /etc/rc.d/rc.halt is called by the GUI or halt command to kill servers for shutdown. Can be diverted by /unslung/rc.halt
    • Calls /sbin/halt-test to kill servers and unmount disks

Linksys and Unslung reboot sequence

  • /etc/rc.d/rc.reboot is called by the GUI or reboot command to kill servers and unmount disks for reboot. Can be diverted by /unslung/rc.reboot

The Linksys specific utilities - description


/bin

No programs here seem to access /etc/CGI_ds.conf


/etc

/etc/rc.d/rc.bootbin

(binary)

Started from: /etc/rc.d/rc.1

Suspected behaviour:

  • Mount attached USB storage devices (like HDD, flashdrive), both conf and data partitions and swap on /dev/sda3
  • Create CGI_ds.conf from flash (SysConf)
  • Starts the DHCP client and gets an IP address
  • For static addresses, does equivalent of /sbin/ifup
  • Does swapon /dev/sda3 and swapon /dev/sdb3 if the swap partitions are available.
  • Starts uPnP daemons
  • Wipes /etc/fstab and /etc/mtab if it feels like it
  • Manipulates inetd.conf (probably with regards to the telnetd entry)

/sbin

/sbin/download

(binary)

Started from: /etc/rc.d/rc.1

Suspected behaviour:

  • Daemon listening on the network interface and will accept commands to flash the slug.

/sbin/halt-test

(shell script)

Started from: /etc/rc.d/rc.halt

Behaviour:

  • Kills Samba, waits a bit, then hangs up all other processes, umount drives, beeps and halts.

/usr/bin

No programs here seem to access /etc/CGI_ds.conf

/usr/bin/Set_Led

(binary)

Started from:

  • /usr/sbin/CheckDiskFull
  • /usr/sbin/QuickSet
  • /usr/sbin/USB_Detect
  • /usr/sbin/download
  • /sbin/halt-test
  • /bin/busybox (!)

Suspected behaviour:

  • Blinks front panel LEDs and beeps in accordance with argument

/usr/sbin

/usr/sbin/USB_Detect

(binary)

Started from: /etc/rc.d/rc.quickset

Suspected behaviour:

  • Checks /proc/hd_conn and /proc/hd2_conn for drives connected to the two USB ports and handles mounting of them.
  • Accesses /etc/CGI_ds.conf

/usr/sbin/upnpd

(binary)

Started from: /etc/rd.d/rc.bootbit

Suspected behaviour:

  • Announces the slug services on the network in accordance with the upnp standard.
  • Accesses /etc/CGI_ds.conf (Linksys modified code)

/usr/sbin/WatchDog

(shell script)

Started from: crond via /etc/crontab

Behaviour:

  • Makes sure Samba daemons, smbd and nmbd are running (if not, it starts them)
  • Makes sure the web interface is running.
  • Trims the /var/log/messages file if exceeding 20kB

/usr/sbin/CGI_chk_save_pass

/usr/sbin/CheckBackup

/usr/sbin/CheckDiskFull

(binary)

Started from: crond via /etc/crontab

Behaviour:

/usr/sbin/CheckPowerButton

(binary)

Started from: /etc/rc.d/rc.local

Suspected behaviour:

  • Daemon that waits for the user to press the power button, then shuts down

/usr/sbin/CheckResetButton

(binary)

Started from: /etc/rc.d/rc.local

Suspected behaviour:

  • Daemon that waits for the user to press the reset button, then resets the slug.
  • Accesses /etc/CGI_ds.conf

/usr/sbin/DO_Reboot

(shell script)

Started from: /home/httpd/html/Managment/maintmode.cgi (web interface) Behaviour:

  • Logs reboot event, waits two seconds and reboots using /etc/rc.d/rc.reboot

/usr/sbin/DO_ScanDisk

(binary)

/usr/sbin/DO_Shutdown

(shell script)

Started from: ?

Behaviour:

  • Logs reboot event, waits two seconds and shuts down using /etc/rc.d/rc.halt

/usr/sbin/QuickSet

(binary)

Suspected behaviour:

  • Accesses /etc/CGI_ds.conf

/usr/sbin/SetConf

(binary)

Started from:

Behaviour:

  • Sets variables in /etc/CGI_ds.conf and files with similar structure
  • Accesses /etc/CGI_ds.conf

/usr/sbin/Set_TimeZone

(binary)

Started from: /etc/rc.d/rc.rstimezome

Suspected behaviour:

  • Reads time zone from config file and sets it in the system
  • Accesses /etc/CGI_ds.conf

References:

 * Extract the GUI timezone from the .conf file
 * Copy the corresponding /usr/zoneinfo file over /usr/local/localtime

/usr/sbin/TelnetPassword

(binary)

Started from: /etc/rc.d/rc.local

Behaviour:

  • Generates the ourtelnetrescueuser password based on the MAC address of the NSLU2.

/usr/sbin/backup

/usr/sbin/do_umount

(binary)

Started from: /etc/rc.d/rc.local

Behaviour:

  • Listens for a drive unmount command by the Linksys Windows unmount utility.

/usr/sbin/drive_backup

(binary)

/usr/sbin/drivertodrivercp

(binary)

/usr/sbin/find_ds

(binary)

/usr/sbin/hwclock

(binary)

Behaviour:

  • Read and write the hardware RTC in the Xicor chip. Sets the internal kernel clock to the RTC value at boot up.

Reference: This is a standard linux utility. See

/usr/sbin/reset_ugs

(binary)

Behaviour:

  • Deletes and recreates all smb.conf, usrgrp.info and share.info files

Started from:

  • /etc/rc.d/rc.reset_usrgrpshare at start-up

Suspected behaviour:

  • Accesses /etc/CGI_ds.conf

/usr/sbin/set_log

(binary)

Behaviour:

  • Logs status and error messages to /var/log/server.log and optionally sends these messages to the configured admin email address.
  • Message text seems to be pulled from /etc/cgi_msg and perhaps /etc/sys_msg

Syntax:

  • set_log <type> <0|1> <msg number> where 0 means send email and 1 is log only. <type> and <msg number> are indexes into /etc/cgi_msg file

Reference:

  • man set_log

/usr/sbin/set_status

(binary)

Started from: Various

Behaviour:

  • Set LED and buzzer states.

/usr/sbin/smbpassword

(binary)

Started from:

Suspected behaviour:

  • Accesses /etc/CGI_ds.conf

/usr/libexec

No programs here seem to access /etc/CGI_ds.conf

/usr/libexec/bigram

(binary)

/usr/libexec/code

(binary)

/usr/libexec/frcode

(binary)

/usr/libexec/rmt

(binary)

Started from: ?

Behaviour:

  • Remote backup utility
view · edit · print · history · Last edited by dbh.
Based on work by dbh, fcarolo, ShadowJK, vermonohue, pedxing, Thomas Kubernus, Nathan, tman, ka6sox, tlhackque, bobtm, Gerald L Clark, and perlguru.
Originally by tlhackque.
Page last modified on March 01, 2009, at 03:51 AM