#!/bin/sh #---------------------------------------------------------------------------- # /init - boot script # # Creation: 29.03.2007 The Eisfair Team # Last Update: $Id$ # # Copyright (c) 2000-2008 The Eisfair Team #---------------------------------------------------------------------------- parse_opt() { case "$1" in *\=*) echo ${1#*=} ;; esac } run_udev() { if $debugmessage then /sbin/udevadm trigger --verbose \ --subsystem-nomatch=backlight \ --subsystem-nomatch=video4linux $subsys_usb mkdir -p /var/log udevadm monitor 2>&1 >/var/log/udev & else /sbin/udevadm trigger \ --subsystem-nomatch=backlight \ --subsystem-nomatch=video4linux $subsys_usb fi /sbin/udevadm settle # wait 30 second's for udev for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 do [ -e /sys/block/sda ] && break [ -e "/sys/block/ida*" ] && break echo -n "." sleep 1 done echo "" } #---------------------------------------------------------------------------- # set default values #---------------------------------------------------------------------------- PATH=/bin:/sbin/:/usr/bin:/usr/sbin:/usr/local/bin:.; export PATH SHELL="/bin/sh"; export SHELL NORMAL=$(echo -en "\\033[00m") YELLOW=$(echo -en "\\033[33m") GREEN=$(echo -en "\\033[32m") installerMode=false useGermanKeys=false externalmodul="" raidlevel="" debugmessage=false framebuffer=false subsys_usb="" #---------------------------------------------------------------------------- # mount devices, e.g. /proc #---------------------------------------------------------------------------- # first mount: mount -t sysfs -o nodev,noexec,nosuid none /sys mount -t proc -o nodev,noexec,nosuid none /proc if ! mount -t devtmpfs -o mode=0755 none /dev then mount -t tmpfs -o mode=0755 none /dev mknod -m 0666 /dev/null c 1 3 mknod -m 0600 /dev/console c 5 1 mknod -m 0660 /dev/mem c 1 1 mknod -m 0660 /dev/port c 1 4 mknod -m 0600 /dev/kmsg c 1 11 mknod -m 0660 /dev/loop0 b 7 0 mknod -m 0600 /dev/tty c 5 0 mknod -m 0600 /dev/tty0 c 4 0 mknod -m 0600 /dev/tty1 c 4 1 mknod -m 0600 /dev/tty2 c 4 2 mknod -m 0660 /dev/md0 b 9 0 mknod -m 0660 /dev/md1 b 9 1 mknod -m 0660 /dev/md2 b 9 2 mknod -m 0660 /dev/md3 b 9 3 fi mkdir -p /dev/pts mount -t devpts -o noexec,nosuid,gid=5,mode=0620 none /dev/pts # Scan /proc/cmdline for any specified arguments if [ -e /proc/cmdline ] then for word in $(cat /proc/cmdline) do case $word in root\=*) # root root=`parse_opt "${word}"` ;; raid\=*) # raid raidlevel=`parse_opt "${word}"` ;; install) # start install installerMode=true rm -f /lib/udev/rules.d/*md-raid.rules rm -f /lib/udev/rules.d/*dmsetup.rules rm -f /lib/udev/rules.d/*lvm2.rules ;; rescue) # start rescue console installerMode=true debugmessage=true raidlevel="0" echo "" > /etc/rescue ;; kmapger) # load german keymap useGermanKeys=true ;; doload\=*) # insert aditional module without u/dev externalmodul=`parse_opt "${word}" | sed -e "s/,/ /g"` ;; debug) # activate debug output debugmessage=true ;; vga\=*) # start framebuffer graphic output framebuffer=true ;; console\=*) # show start message on console console=`parse_opt "${word}"` ;; nousb\=*) # dont start udev usb trigger subsys_usb="--subsystem-nomatch=usb --subsystem-nomatch=usb_host" esac done fi if ! $debugmessage then echo 0 > /proc/sys/kernel/printk fi # Create problematic directories echo "" > /proc/sys/kernel/hotplug #start udev /sbin/udevd --daemon --resolve-names=never # load modules if exists /sbin/modprobe -qb ext3 /sbin/modprobe -qb dm-mod /sbin/modprobe -qb loop if $framebuffer then /sbin/modprobe -qb fbcon /sbin/modprobe -qb vesafb fi if $installerMode then while [ 1 ] do /bin/ash done /dev/tty2 2>&1 & fi if [ -n "$externalmodul" ] then for module in $externalmodul do echo "load ${module}" /sbin/modprobe -qb ${module} done fi if $installerMode then if [ -z "$subsys_usb" ] then # Load USB modules for module in vfat sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage do modprobe -qb ${module} done fi fi exec >/dev/tty1 exec 2>/dev/tty1 # load german keymap if [ "$useGermanKeys" = "true" ] then loadkmap < /etc/kmap-gr.bin fi #---------------------------------------------------------------------------- # start udev, raid, lvm, usb #---------------------------------------------------------------------------- echo -n "Detecting hardware: " run_udev if [ -n "$raidlevel" ] then if [ "$raidlevel" = "0" ] then /sbin/modprobe -qb raid1 /sbin/modprobe -qb raid0 fi if [ "$raidlevel" = "1" ] then /sbin/modprobe -qb raid1 fi if [ "$raidlevel" = "5" ] then /sbin/modprobe -qb raid1 /sbin/modprobe -qb raid456 fi #/sbin/modprobe raid10 > /dev/null 2>&1 /sbin/mdadm --examine --scan > /etc/mdadm.conf /sbin/mdadm -As fi #---------------------------------------------------------------------------- # loading additional subsystem and filesystem driver #---------------------------------------------------------------------------- if $installerMode then medium="eisfair-installation-medium" mnt=/mnt mkdir -p /$mnt #blkid -t TYPE=label -o device i=0 while [ $i -le 10 ] do for x in /sys/block/*/device do x=${x%/device}; x=${x#/sys/block/} [ "$x" = "*" ] && continue # Compaq servers has /sys/block/ida!c0d0 x=${x#ida!} x=/dev/$x for x in ${x}* do [ -e $x ] || continue fs=`blkid -s TYPE $x | cut -d = -f 2 | sed 's/"//g'` [ $i -gt 2 ] && echo "Testing device $x, type $fs ..." if mount -t $fs -o ro $x $mnt 2>/dev/null then [ $i -gt 0 ] && echo "Successfully mounted $x ..." if [ -f $mnt/$medium ] then if ! /bin/zcat /mnt/inst.tar.gz | /bin/tar xf - then echo "*** ERROR: /mnt/inst.tar.gz not found or RAMSIZE to small ***" /bin/ash < /dev/tty1 > /dev/tty1 exit fi exec /bin/sh /linuxrc2 fi umount $mnt fi done done sleep 2s : $(( i++ )) done echo "No eisfair media found, giving up. Debug shell:" /bin/ash < /dev/tty1 > /dev/tty1 else case "$root" in UUID*) uuid_root=`parse_opt "$root"` echo -n "Mounting root by UUID ($uuid_root) " mount_dev="/dev/disk/by-uuid/$uuid_root" ;; *) echo -n "Mounting $root " mount_dev="$root" ;; esac # second start of udev if [ ! -e "$mount_dev" ] then run_udev # Wait max 60 second's and ignore udev queue i=0 while test ! -e "$mount_dev" do sleep 1; test $i -gt 59 && break echo -n "." : $(( i++ )) done echo "" else echo "..." fi if ! mount -n ${mount_dev} /mnt >/dev/null then echo "List of detected partitions:" sfdisk -l echo "Debug shell" /bin/ash < /dev/tty1 > /dev/tty1 fi # remove not used binaries killall udevd > /dev/null 2>&1 rm -f /sbin/udevadm rm -f /sbin/udevd rm -rf /lib rm -f /bin/bar rm -f /sbin/blkid rm -f /sbin/dmsetup rm -f /sbin/sfdisk rm -f /sbin/e2fsck rm -f /sbin/lvm rm -f /sbin/mdadm rm -f /sbin/modprobe # Move virtual filesystems over to the real filesystem mount -n -o move /sys /mnt/sys mount -n -o move /proc /mnt/proc mount -n -o move /dev /mnt/dev echo echo "${YELLOW}Welcome to eisfair!${NORMAL}" echo echo "${GREEN}Please stand by, while the system is booting ...${NORMAL}" if [ -n "$console" ] then echo echo "(Switch to console 7 (Alt-F7) to see the boot messages) " fi # new style of pivoting switch_root exec /sbin/switch_root /mnt /sbin/init fi