DSL Boot Process

From DSL Wiki

This page in other languages: EspaƱol


When booting from a Live CD DSL's boot process is as follows:

Contents

isolinux/syslinux

The DSL Live CD is available in both isolinux and syslinux versions. These are both Linux boot loaders which can be run from a CD. They prompt the user for cheat codes, load the DSL kernel and initial ramdisk into memory and then boot the DSL kernel.

If using the syslinux version, simply edit /cdrom/syslinux.cfg to change your default boot params, default selection timeout (the value is in 1/10ths of a second), and boot menu text.

Linuxrc

Once the kernel has loaded the initial ramdisk is mounted as the root filesystem and the script /linuxrc is run. /linuxrc does the following

  • Searches for the compressed /KNOPPIX/KNOPPIX image on all available drives/partitions. Once found the partition containing this image is mounted at /cdrom. The relevent section is:
# Now that the right SCSI driver is (hopefully) loaded, try to find CDROM
DEVICES="/dev/hd?"
test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
# New: Also try parallel port CD-Roms [for Mike].
DEVICES="$DEVICES /dev/pcd?"
# New: also check HD partitions for a KNOPPIX/KNOPPIX image
test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
for i in $DEVICES
do
echo -n "${CRE}${BLUE}Looking for CDROM in: ${MAGENTA}$i${NORMAL}   "
if mountit $i /cdrom "-o ro" >/dev/null 2>&1
then
if test -f /cdrom/$KNOPPIX_DIR/$KNOPPIX_NAME
then
echo -n "${CRE} ${GREEN}Accessing DSL image at ${MAGENTA}$i${GREEN}...${NORMAL}"
FOUND_KNOPPIX="$i"
break
fi
umount /cdrom
fi
done
  • Loads the cloop kernel module and mounts the compressed KNOPPIX filesystem at /KNOPPIX:
mount_knoppix()
{
  if test -n "$FOUND_KNOPPIX" -a -f $1/$KNOPPIX_DIR/$KNOPPIX_NAME; then
    # DEBUG
    # echo "6" > /proc/sys/kernel/printk
    $INSMOD -f /modules/cloop.o file=$1/$KNOPPIX_DIR/$KNOPPIX_NAME
    mountit /dev/cloop /KNOPPIX "-o ro" || FOUND_KNOPPIX=""
  fi
}
mount_knoppix /cdrom
  • At this point /bin,/boot,/opt,/lib,/usr directories are symlinks to the corresponding directories inside /KNOPPIX. A similar symlink for /sbin is setup and a number of files are copied from /KNOPPIX to the root filesystem. A ramdisk is mounted over /ramdisk and /var,/home are symlinked to this.
  • Since all the necessary directories (/bin,/boot,/opt,/lib,/usr,/sbin,/home,/var,/etc,/tmp) are populated the real init process /etc/init is now called.

Init process

The init process runs through all the scripts in /etc/rcS.d and /etc/rc5.d (runlevel 5 is the default run level).

knoppix-autoconfig

/etc/init.d/knoppix-autoconfig is the first script run by the init process. The regional settings are configured (timezone, keyboard mapping etc). It tries to autodetect the available hardware and load the appropriate modules and to setup the network using DHCP. Finally it scans the available partitions to create a suitable fstab.

dsl-config

/etc/init.d/dsl-config controls DSL specific configuration. It creates a symlink from /opt to the ramdisk to allow /opt to be written to, sets up /home/dsl using /etc/skel as a template, loads DSL extensions and finally restores a backup file (if it exists). It also checks for a number of cheatcodes.

bootlocal.sh

/opt/bootlocal.sh is run after dsl-config. Since this resides on in a writable part of the filesystem (since /opt is symlinked to /ramdisk/opt) it is possible to include this script when making a backup of your settings. Therefore it can be used to add you own custom startup commands.

Logging in

The /etc/inittab specifies that the root user should be automatically logged in

1:12345:respawn:/bin/bash -login >/dev/tty1 2>&1 </dev/tty1

If the runlevel is equal to 5 (the default runlevel) it then switches to the 'dsl' user as specified in /.bash_profile:

#!/bin/bash
RUNLEVEL=`runlevel|cut -f2 -d' '`
if [ $RUNLEVEL -eq 5 ]
then
   export HOME=/home/dsl
   cd $HOME
   while [ 1 ]; do
      su - dsl
   done
fi

The X Windows System is started as specified in /home/dsl/.bash_profile (this file originally resides in /etc/skel and is copied to /home/dsl/ by dsl-config).

#!/bin/bash
export IRCNICK=DSL
SSH=`env | grep SSH_CONNECTION`
if [ -z "$SSH" ]; then startx; fi

Finally the programs specified in /home/dsl/.xinitrc are loaded (again this file originally resides in /etc/skel). The default is to load fluxbox and the DSL help file.

# put X windows programs that you want started here.
# Be sure to add at the end of each command the &
if egrep -qv noicons /proc/cmdline 2>/dev/null; then
  enhance &>/dev/null &
fi
dillo /usr/share/doc/dsl/getting_started.html &>/dev/null &
fluxbox