8b42b785fc842fe59a14b6dc6fe69fb95e6671e1
[grml-live.git] / rewrite / linuxrc
1 #!/static/sh
2 # Filename: /linuxrc
3 # Purpose:  minirt for kernel 2.6 running on grml live-cd
4 # Authors:  (c) Klaus Knopper <knoppix@knopper.net>, (c) Michael Prokop <mika@grml.org>
5 # Latest change: Mon Apr 09 12:47:28 CEST 2007
6 #######################################################################################
7
8 # hardcoded configurable options
9 # Default maximum size of dynamic ramdisk in kilobytes
10 RAMSIZE=1000000
11 # End of options
12
13 # Don't allow interrupt signals
14 trap "" 1 2 3 15
15
16 # Misc functions
17 INSMOD="/static/insmod"
18 # [ -x /modules/insmod ] && INSMOD="/modules/insmod"
19
20 RMMOD="/static/rmmod"
21 # [ -x /modules/rmmod ] && RMMOD="/modules/rmmod"
22
23 # Builin filesystems
24 # BUILTIN_FS="iso9660 ext2 vfat"
25 BUILTIN_FS="iso9660 ext2 ext3 reiserfs vfat xfs jfs reiser4"
26
27 mountit(){
28 # Usage: mountit src dst "options"
29 for fs in $BUILTIN_FS; do
30  if test -b $1; then
31   options="$3"
32   case "$fs" in vfat)
33    # We REALLY need this for Knoppix on DOS-filesystems
34    shortname="shortname=winnt"
35    [ -n "$options" ] && options="$options,$shortname" || options="-o $shortname"
36   ;;
37   esac
38   mount -t $fs $options $1 $2 >/dev/null 2>&1 && return 0
39  fi
40 done
41 return 1
42 }
43
44 FOUND_SCSI=""
45 FOUND_GRML=""
46 INTERACTIVE=""
47
48 # Clean input/output
49 exec >/dev/console </dev/console 2>&1
50
51 # Mount /proc and /dev/pts
52 mount -t proc /proc /proc
53
54 # Disable kernel messages while probing modules in autodetect mode
55 echo "0" > /proc/sys/kernel/printk
56
57 mount -t devpts /dev/pts /dev/pts
58 # Kernel 2.6
59 mount -t sysfs /sys /sys >/dev/null 2>&1
60
61 # Read boot command line with builtin cat command (shell read function fails in Kernel 2.4.19-rc1)
62 CMDLINE="$(cat /proc/cmdline)"
63
64 # Simple shell grep
65 stringinfile(){
66   case "$(cat $2)" in *$1*) return 0;; esac
67   return 1
68 }
69
70 # same for strings
71 stringinstring(){
72   case "$2" in *$1*) return 0;; esac
73   return 1
74 }
75
76 # Reread boot command line; echo last parameter's argument or return false.
77 getbootparam(){
78   stringinstring " $1=" "$CMDLINE" || return 1
79   result="${CMDLINE##*$1=}"
80   result="${result%%[   ]*}"
81   echo "$result"
82   return 0
83 }
84
85 # Check boot commandline for specified option
86 checkbootparam(){
87   stringinstring " $1" "$CMDLINE"
88   return "$?"
89 }
90
91 if checkbootparam "nocolor" ; then
92   echo "Disabling colors in bootsequence as requested on commandline."
93   # Reset fb color mode
94   RESET="\e]R"
95   # ANSI COLORS
96   # Erase to end of line
97   CRE="\r\e[K"
98   # Clear and reset Screen
99   CLEAR="\ec"
100 else
101   # Reset fb color mode
102   RESET="\e]R"
103   # ANSI COLORS
104   # Erase to end of line
105   CRE="\r\e[K"
106   # Clear and reset Screen
107   CLEAR="\ec"
108   # Normal color
109   NORMAL="\e[0;39m"
110   # RED: Failure or error message
111   RED="\e[1;31m"
112   # GREEN: Success message
113   GREEN="\e[1;32m"
114   # YELLOW: Descriptions
115   YELLOW="\e[1;33m"
116   # BLUE: System mesages
117   BLUE="\e[1;34m"
118   # MAGENTA: Found devices or drivers
119   MAGENTA="\e[1;35m"
120   # CYAN: Questions
121   CYAN="\e[1;36m"
122   # BOLD WHITE: Hint
123   WHITE="\e[1;37m"
124 fi
125
126 # don't output anything if running with bootsplash feature
127 if checkbootparam "splash" ; then
128   echo ""
129   echo "${WHITE}Welcome to"
130   echo ""
131   echo "${RED}   ____ ____  __  __ _     "
132   echo "${RED}  / ___|  _ \|  \/  | |    "
133   echo "${RED} | |  _| |_) | |\/| | |    "
134   echo "${RED} | |_| |  _ <| |  | | |___ "
135   echo "${RED}  \____|_| \_\_|  |_|_____|"
136   echo ""
137   echo "${WHITE}grml.org - Linux for users of texttools and sysadmins."
138   echo "${NORMAL}"
139   exec >/dev/null </dev/null 2>&1
140 fi
141
142 # helper functions {{{
143 #log_success_msg () {
144 #  echo " * $@"
145 #}
146
147 log_failure_msg () {
148   echo " ${RED}*${NORMAL} $@"
149 }
150
151 #log_warning_msg () {
152 # echo " ${BLUE}*${NORMAL} $@"
153 #}
154
155 # int log_begin_message (char *message)
156 log_begin_msg () {
157   echo -n " ${GREEN}*${NORMAL} $@"
158 }
159
160 log_warn_msg () {
161   echo -n " ${YELLOW}*${NORMAL} $@"
162 }
163
164 # int log_end_message (int exitstatus)
165 SUCCESS=" ${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}"
166 FAILED=" ${NORMAL}[${RED}fail${NORMAL}]"
167 # }}}
168
169 # Clear screen with colormode reset
170 # echo "$CLEAR$RESET"
171 # echo "$CLEAR"
172 # Just go to the top of the screen
173 # echo -n "\e[H\e[J"
174 DISTRI="$(getbootparam 'distri' 2>/dev/null)"
175 if [ -n "$DISTRI" ] ; then
176 SPLASH="
177 ${RED} $DISTRI
178
179 ${WHITE}based on grml.org.
180
181 ${NORMAL}"
182 else
183 SPLASH="
184 ${RED}   ____ ____  __  __ _
185 ${RED}  / ___|  _ \|  \/  | |
186 ${RED} | |  _| |_) | |\/| | |
187 ${RED} | |_| |  _ <| |  | | |___
188 ${RED}  \____|_| \_\_|  |_|_____|
189
190 ${WHITE}grml.org - Linux for users of texttools and sysadmins.
191
192 ${NORMAL}"
193 fi
194
195 echo ""
196 echo "${WHITE}Welcome to"
197 echo "$SPLASH"
198
199 # We need the builtin commands and /static only starting at this point
200 PATH=/static
201 export PATH
202
203 umask 022
204
205 case "$CMDLINE" in *debuglinuxrc*) set -x; echo "linuxrc debugging activated"; DEBUG="yes"; ;; esac
206 case "$CMDLINE" in *BOOT_IMAGE=expert\ *) INTERACTIVE="yes"; :>/interactive; ;; esac
207 case "$CMDLINE" in *BOOT_IMAGE=vmware\ *) VMWARE="yes"; ;; esac
208 case "$CMDLINE" in *modules-disk*) INTERACTIVE="yes"; ;; esac
209 case "$CMDLINE" in *BOOT_IMAGE=debug\ *|*\ debug\ *) DEBUG="yes"; ;; esac
210 case "$CMDLINE" in *secure*) SECURE=",nosuid"; ;; esac
211 # Does the user want to skip scsi detection?
212 NOSCSI=""
213 NOUSB=""
214 NOFIREWIRE=""
215 case "$CMDLINE" in *noscsi*|*nobootscsi*) NOSCSI="yes"; ;; esac
216 case "$CMDLINE" in *nousb\ *|*nobootusb*) NOUSB="yes"; ;; esac
217 case "$CMDLINE" in *nofirewire*|*nobootfirewire*) NOFIREWIRE="yes"; ;; esac
218 NOCD=""
219 case "$CMDLINE" in *fromhd*) NOCD="yes"; ;; esac
220 case "$CMDLINE" in *fromdvd*) FROMDVD="yes"; ;; esac
221 case "$CMDLINE" in *idecd*|*atapicd*) IDECD="yes"; ;; esac
222 case "$CMDLINE" in *noideraid*) NOIDERAID="yes"; ;; esac
223 USB2="ehci-hcd.ko"
224 case "$CMDLINE" in *nousb2*) USB2="" NOUSB2="yes"; ;; esac
225 case "$CMDLINE" in *\ usb*) USB="yes"; ;; esac
226
227 GRML_DIR="GRML"
228 GRML_NAME="GRML"
229 case "$CMDLINE" in *grml_dir=*) GRML_DIR="$grml_dir"; ;; esac
230 case "$CMDLINE" in *grml_name=*) GRML_NAME="$grml_name"; ;; esac
231
232 # NFS
233 for i in $cmdline; do case "$i" in nfsdir=*|NFSDIR=*) eval $i;; esac; done
234 [ -n "$nfsdir" ] && NFS="$nfsdir"
235
236 if [ -n "$DEBUG" ]; then
237    log_begin_msg "Bootoption debug detected. Printing kernel command line:"
238    echo ""
239    cat /proc/cmdline
240 fi
241
242 # Run a shell if in debug mode
243 # echo "${BLUE}Dropping you to a busybox shell for debugging.${NORMAL}"
244 stage=1
245 rundebugshell(){
246  if [ -n "$DEBUG" ]; then
247   log_begin_msg "Starting intermediate shell stage $stage as requested by \"debug\" option."
248   echo ""
249   echo "   ${GREEN}-${NORMAL} Just exit the shell to continue boot process...${NORMAL}"
250   if [ -x /static/sh ]; then
251     /static/sh
252   else
253     /bin/bash
254   fi
255  fi
256 }
257 rundebugshell
258
259 # Mount module disk
260 mountmodules(){
261 TYPE="$1"; shift
262 echo -n "${CRE}Please insert ${TYPE} modules disk and hit Return."
263 read a
264 echo -n "${CRE}Mounting ${TYPE} modules disk... "
265 # We always mount over /modules/scsi (because it's there ;-)
266 if mountit /dev/fd0 /modules/scsi "-o ro"; then
267 echo "${GREEN}OK.${NORMAL}"
268 return 0
269 fi
270 echo "${RED}NOT FOUND.${NORMAL}"
271 return 1
272 }
273
274 # Unmount module disk
275 umountmodules(){
276 TYPE="$1"; shift
277 echo -n "${CRE}Unmounting ${TYPE} modules disk... "
278 umount /modules/scsi 2>/dev/null
279 echo "${GREEN}DONE.${NORMAL}"
280 }
281
282 # Ask user for modules
283 askmodules(){
284  TYPE="$1"; shift
285  echo "${TYPE} modules available:${WHITE}"
286  c=""
287  for m in "$@"; do
288   if test -f "/modules/scsi/$m"; then
289    test -z "$c"  && { echo -n " $m"; c="1"; } || { echo "               $m"; c=""; }
290   fi
291  done
292  [ -n "$c" ] && echo ""
293  echo "Load ${TYPE} Modules?"
294  echo "[Enter full filename(s) (space-separated), Return for autoprobe, n for none] "
295  echo -n "insmod module(s)> "
296  read MODULES
297  case "$MODULES" in n|N) MODULES=""; ;; y|"")  MODULES="$*"; ;; esac
298 }
299
300 # Try to load the given modules (full path or current directory)
301 loadmodules(){
302  TYPE="$1"; shift
303  test -n "$INTERACTIVE" && echo "6" > /proc/sys/kernel/printk
304  echo ""
305  for i in "$@"; do
306   echo -n "   Probing ${TYPE}... ${WHITE}$i${NORMAL}: "
307    if test -f /modules/scsi/$i.ko && $INSMOD /modules/scsi/$i.ko >/dev/null 2>&1 && echo "  $SUCCESS" || echo " failed " ; then
308      case "$TYPE" in scsi|SCSI) FOUND_SCSI="yes"; ;; esac
309    fi
310  done
311  test -n "$INTERACTIVE" && echo "0" > /proc/sys/kernel/printk
312  echo -n "${CRE}"
313 }
314
315 # Check for SCSI, use modules on bootfloppy first
316 # Trying to do kind of /proc/pci hardware detection
317 if checkbootparam oldscsi ; then
318   PROCPCI="`cat /proc/pci 2>/dev/null`"
319   case "$PROCPCI" in *[Aa][Ii][Cc]-*|*[Aa][Hh][Aa]-*) SCSI_PROBE="$SCSI_PROBE aic7xxx" ;; esac
320   case "$PROCPCI" in *[Bb][Uu][Ss][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE BusLogic" ;; esac
321   case "$PROCPCI" in *[Tt][Rr][Mm]-[Ss]1040*|*[Dd][Cc]395*|*[Dd][Cc]315*) SCSI_PROBE="$SCSI_PROBE dc395x" ;; esac
322   case "$PROCPCI" in *53[Cc]8*) SCSI_PROBE="$SCSI_PROBE sym53c8xx" ;; esac
323   case "$PROCPCI" in *53[Cc]9*) SCSI_PROBE="$SCSI_PROBE NCR53C9x" ;; esac
324   case "$PROCPCI" in *53[Cc]406*) SCSI_PROBE="$SCSI_PROBE NCR53c406a" ;; esac
325   case "$PROCPCI" in *[Ii][Nn][Ii][Tt][Ii][Oo]\ *|*[Ii][Nn][Ii]-[Aa]100[Uu]2[Ww]*) SCSI_PROBE="$SCSI_PROBE initio" ;; esac
326   case "$PROCPCI" in *[Mm][Pp][Tt]*[Ss][Cc][Ss][Ii]*) SCSI_PROBE="$SCSI_PROBE mptbase mptscsih" ;; esac
327   case "$PROCPCI" in *[Aa][Dd][Vv][Aa][Nn][Cc][Ee][Dd]\ [Ss][Yy][Ss]*) SCSI_PROBE="$SCSI_PROBE advansys" ;; esac
328   case "$PROCPCI" in *[Aa][Tt][Pp]8*|*[Aa][Ee][Cc]6*) SCSI_PROBE="$SCSI_PROBE atp870u" ;; esac
329   case "$PROCPCI" in *[Dd][Tt][Cc]*) SCSI_PROBE="$SCSI_PROBE dtc" ;; esac
330   case "$PROCPCI" in *[Ee][Aa][Tt][Aa]*) SCSI_PROBE="$SCSI_PROBE eata" ;; esac
331   case "$PROCPCI" in *[Ff]*[Dd][Oo][Mm][Aa][Ii][Nn]*) SCSI_PROBE="$SCSI_PROBE fdomain" ;; esac
332   case "$PROCPCI" in *[Gg][Dd][Tt]\ *) SCSI_PROBE="$SCSI_PROBE gdth" ;; esac
333   case "$PROCPCI" in *[Mm][Ee][Gg][Aa][Rr][Aa][Ii][Dd]*) SCSI_PROBE="$SCSI_PROBE megaraid_mm megaraid_mbox" ;; esac
334   case "$PROCPCI" in *[Qq][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE qlogicfas408 qlogicfas qlogicfc" ;; esac
335   case "$PROCPCI" in *53[Cc]974*) SCSI_PROBE="$SCSI_PROBE tmscsim" ;; esac
336   case "$PROCPCI" in *[Uu][Ll][Tt][Rr][Aa][Ss][Tt][Oo][Rr]*) SCSI_PROBE="$SCSI_PROBE ultrastor" ;; esac
337   case "$PROCPCI" in *3[Ww][Aa][Rr][Ee]*) SCSI_PROBE="$SCSI_PROBE 3w-xxxx" ;; esac
338 fi
339
340 # New sysfs based SCSI detection (thanks, Jörg Schirottke)
341 sysfsscsi(){
342 SYS=$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x 2>/dev/null; done|cut -f2 -d:)
343 while read id driver; do
344  for sysid in $SYS; do
345   case $sysid in $id)
346    if [ -z "$SCSI_PROBE" ]; then
347     SCSI_PROBE="$driver"
348    else
349     SCSI_PROBE="$SCSI_PROBE $driver"
350    fi
351    ;;
352   esac
353  done
354 done <<EOF
355 $(cat /modules/scsi/scsi-modules.txt)
356 EOF
357 }
358
359 if test -n "$INTERACTIVE"; then
360 # Let the user select interactively
361   askmodules SCSI $(cd /modules/scsi; echo *.ko)
362 else
363 # these are the autoprobe-safe modules
364   sysfsscsi
365   MODULES="$SCSI_PROBE"
366 fi
367
368 if test -z "$NOSCSI" ; then
369  log_begin_msg "Scanning for SCSI devices."
370  $INSMOD /modules/scsi/firmware_class.ko 1>/dev/null
371  test -n "$MODULES" && loadmodules SCSI $MODULES &&  echo -n "" || echo "           ${BLUE}[${NORMAL} none found ${BLUE}]${NORMAL} (try bootoption scsi=probe)"
372 else
373   log_warn_msg "Not scanning for SCSI devices as requested on commandline." && echo " $SUCCESS"
374 fi
375
376 if checkbootparam scsi ; then
377   MODULE="$(getbootparam 'scsi' 2>/dev/null)"
378   if test "$MODULE" = "probe" ; then
379     log_begin_msg "Bootoption scsi=probe found. Trying to autoprobe SCSI modules:"
380     echo ""
381     echo -n "   Trying to load scsi_debug: " ; $INSMOD /modules/scsi/scsi_debug.ko 1>/dev/null && echo "           $SUCCESS" || echo " [ failed ]"
382     for module in /modules/scsi/*.ko ; do
383       echo -n "   Probing ${WHITE}${module}${NORMAL}..."
384       $INSMOD ${module} >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
385     done
386   elif test "$MODULE" = "ask" ; then
387     askmodules SCSI $(cd /modules/scsi; echo *.ko)
388     test -z "$NOSCSI" && test -n "$MODULES" && loadmodules SCSI $MODULES
389   else
390     [ -n "$MODULE" ] || echo "   ${RED}Neither a specific module nor option probe nor option ask for SCSI module given. Skipping.${NORMAL}"
391     [ -n "$MODULE" ] && echo -n "   Trying to load module ${WHITE}${MODULE}${NORMAL}:" ; \
392       $INSMOD "/modules/scsi/${MODULE}.ko" 1>/dev/null && echo "  $SUCCESS" || echo " [ failed ]"
393   fi
394 fi
395 # End of SCSI check
396
397 if test -n "$VMWARE" ; then
398   log_begin_msg "Bootoption VMware detected. Trying to load SCSI modules:"
399   echo ""
400   for module in mptbase mptscsih mptspi BusLogic ; do
401     echo -n "   Trying to load ${WHITE}${module}${NORMAL}: "
402     $INSMOD /modules/scsi/${module}.ko >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
403   done
404 fi
405
406 # Check for USB, use modules on bootfloppy first
407 if test -z "$NOUSB"; then
408   log_begin_msg "Checking for USB."
409   if test -f /modules/div/usbcore.ko; then
410     $INSMOD /modules/div/usbcore.ko >/dev/null 2>&1
411     FOUNDUSB=""
412     for i in $USB2 uhci-hcd.ko ohci-hcd.ko usbhid.ko ; do
413       test -f /modules/div/$i && $INSMOD /modules/div/$i >/dev/null 2>&1 && FOUNDUSB="yes"
414     done
415     if test -n "$FOUNDUSB"; then
416       test -f /modules/div/usb-storage.ko && $INSMOD /modules/div/usb-storage.ko >/dev/null 2>&1
417       echo "                   $SUCCESS"
418     else
419       echo "                   ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
420       true
421     fi
422     if [ -n "$NOUSB2" ] ; then
423       echo "   Not loading usb2 module ehci-hcd as requested on commandline."
424       echo "   Notice: to skip loading of USB in initrd at all use bootoption nousb"
425     fi
426   fi
427 else
428   log_warn_msg "Not scanning for USB devices as requested on commandline." && echo " $SUCCESS"
429   echo "   Notice that bootoption nousb affects initrd only, it does *not*"
430   echo "   avoid loading of usb modules in userspace afterwards"
431   echo "   Boot using something like 'nousb blacklist=uhci-hcd' to avoid loading of usb modules at all"
432 fi
433 # End of USB check
434
435 # Check for Firewire, use modules on bootfloppy first
436 if test -z "$NOFIREWIRE" ; then
437   log_begin_msg "Checking for Firewire."
438   if test -f /modules/div/ieee1394.ko ; then
439     $INSMOD /modules/div/ieee1394.ko > /dev/null 2>&1
440     FOUNDFIREWIRE=""
441     test -f /modules/div/ohci1394.ko && $INSMOD /modules/div/ohci1394.ko > /dev/null 2>&1 && FOUNDFIREWIRE="yes"
442     if test -n "$FOUNDFIREWIRE" ; then
443       test -f /modules/div/sbp2.ko && $INSMOD /modules/div/sbp2.ko > /dev/null 2>&1
444       echo "              $SUCCESS"
445     else
446       echo "               ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
447       true
448     fi
449   fi
450 else
451   log_warn_msg "Not scanning for firewire devices as requested on commandline." && echo " $SUCCESS"
452   echo "   Notice that bootoption nofirewire affects initrd only, it does *not*"
453   echo "   avoid loading of firewire modules in userspace afterwards"
454   echo "   Boot with something like 'nofirewire blacklist=ohci1394' to avoid loading of firewire modules at all"
455 fi
456 # End of FIREWIRE check
457
458 # Unfortunately, hotpluggable devices tend to need some time in order to register
459 if test -n "$FOUNDUSB" -o -n "$FOUNDFIREWIRE"; then
460   log_begin_msg "Scanning for USB/Firewire devices."
461   sleep 4
462   if test -n "$USB"; then
463     sleep 10
464   fi
465  echo "  $SUCCESS"
466 fi
467
468 if checkbootparam scandelay ; then
469   DELAY="$(getbootparam 'scandelay' 2>/dev/null)"
470   [ -z $DELAY ] && DELAY='10'
471   log_begin_msg "Delaying bootsequence as requested for ${WHITE}${DELAY}${NORMAL} seconds."
472   sleep $DELAY && echo "  $SUCCESS"
473 fi
474
475 # boot via pcmcia
476 if checkbootparam bootpcmcia ; then
477   log_begin_msg "Bootoption bootpcmcia found. Trying to load ${WHITE}PCMCIA${NORMAL} modules..."
478   if $INSMOD /modules/div/pcmcia_core.ko 1>/dev/null ; then
479      $INSMOD /modules/div/firmware_class.ko 1>/dev/null && \
480      $INSMOD /modules/div/pcmcia.ko         1>/dev/null && \
481      $INSMOD /modules/div/rsrc_nonstatic.ko 1>/dev/null && \
482      $INSMOD /modules/div/yenta_socket.ko   1>/dev/null && echo " $SUCCESS"
483   else
484     echo " [ failed ]"
485   fi
486 fi
487
488 # Check for misc modules in expert mode
489 if test -n "$INTERACTIVE" ; then
490   another=""
491   answer=""
492   while test "$answer" != "n" -a "$answer" != "N" ; do
493     echo -n "${CYAN}Do you want to load additional modules from$another floppy disk? [${WHITE}Y${CYAN}/n] ${NORMAL}"
494     another=" another"
495     read answer
496     case "$answer" in n*|N*) break; ;; esac
497     if mountmodules new ; then
498        askmodules new $(cd /modules/scsi; echo *.ko)
499        test -n "$MODULES" && loadmodules new $MODULES
500        umountmodules current
501     fi
502   done
503 fi
504 # All interactively requested modules should be loaded now.
505
506 # Check for ide-scsi supported CD-Roms et al.
507 test -f /proc/scsi/scsi && FOUND_SCSI="yes"
508
509 # Disable kernel messages again
510 echo "0" > /proc/sys/kernel/printk
511
512 # We now enable DMA right here, for faster reading/writing from/to IDE devices
513 # in FROMHD or TORAM mode
514 case "$CMDLINE" in *\ nodma*) ;; *)
515  for d in $(cd /proc/ide 2>/dev/null && echo hd[a-z]); do
516   if test -d /proc/ide/$d; then
517     MODEL="$(cat /proc/ide/$d/model 2>/dev/null)"
518     test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
519     log_begin_msg "Enabling DMA acceleration for: ${MAGENTA}$d   ${YELLOW}[${MODEL}]${NORMAL}"
520     echo "using_dma:1" >/proc/ide/$d/settings && echo ""
521   fi
522  done
523  ;;
524 esac
525
526 stage=2
527 rundebugshell
528 if [ -n "$NFS" ]; then
529   tmp_="$(getbootparam nfsdir)"
530   log_begin_msg "Bootoption NFS found." ; echo "$SUCCESS"
531
532   /static/cdir
533
534   log_begin_msg "Trying to load network driver(s)." ; echo
535   modLoad()
536   {
537     for mod in $@ ; do
538       if [ -n "$DEBUG" ] ; then
539          echo "Debug: trying to load $mod:"
540          modprobe -v $mod
541       else
542          modprobe $mod 2>/dev/null
543       fi
544     done
545   }
546   # modules.alias and modules.dep are in place so USE IT :)!
547   find /sys/devices/ -name modalias |/static/xargs -r /static/grep -h pci: |while read i; do
548     modLoad "$i"
549   done
550   # loading additional modules
551   modLoad sunrpc lockd af_packet nfs
552
553   dhcp_iface_=$(getbootparam dhcp_iface)
554   if [ -z "$dhcp_iface_" ]; then
555         dhcp_iface_=`ifconfig -a | grep '^eth' | sed 's/ .*//'`
556   fi
557
558   # make sure we have a udhcpc executable, if it's not present
559   # assume that busybox provides one
560   if ! [ -x /static/udhcpc ] ; then
561      ln -s /static/busybox /static/udhcpc
562   fi
563
564   for INTERFACE in $dhcp_iface_ ; do
565       log_begin_msg "Requesting network configuration using udhcp for ${INTERFACE}:" ; echo
566       /static/timeout 10 /static/udhcpc --interface="${INTERFACE}" --foreground --quit --script=/static/udhcp-config.sh
567       # echo "press <enter> to start a system shell and configure your system"
568       # sh
569   done
570
571   # recreate dir layout + remove extra modules
572   /static/rdir
573
574   log_begin_msg "Looking for GRML in: ${MAGENTA}$NFS${NORMAL}" ; echo "$SUCCESS"
575   if mount -t nfs "$NFS" -o "async,ro,nolock" /cdrom #>/dev/null 2>&1
576     then
577     if test -f /cdrom/$GRML_DIR/$GRML_NAME
578       then
579       log_begin_msg "Accessing grml CDROM at ${MAGENTA}$NFS${NORMAL}" ; echo "$SUCCESS"
580       FOUND_GRML="$NFS"
581       break
582     fi
583   fi
584 fi
585
586 # Now that the right SCSI driver is (hopefully) loaded, try to find CD-ROM
587 grmlmount()
588 {
589   if test -z $NFS ; then
590     DEVICES="/dev/hd?"
591     test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
592     # New: Also try parallel port CD-ROMs
593     DEVICES="$DEVICES /dev/pcd?"
594     # New: also check HD partitions for a GRML/GRML image
595     # notice: use /dev/sd? for usb-sticks without partition(s)
596     test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9] /dev/sd?"
597     DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
598     case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
599     for i in $DEVICES ; do
600       log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in:    ${MAGENTA}$i${NORMAL}"
601       if mountit $i /cdrom "-o ro" >/dev/null 2>&1 ; then
602          echo "  $SUCCESS"
603          if test -f /cdrom/$GRML_DIR/$GRML_NAME ; then
604             log_begin_msg "Accessing grml CD-ROM at: ${MAGENTA}$i${NORMAL}" ; echo "  $SUCCESS"
605             FOUND_GRML="$i"
606             break
607          fi
608         umount /cdrom
609       fi
610     done
611   fi
612 }
613
614 # Rerun the grml-CDROM part 3 times at total
615 if ! grmlmount ; then
616    log_warning_msg "grml CD-ROM not yet found, sleeping for 5 seconds and trying again then."
617    sleep 5
618    if ! grmlmount ; then
619       log_warning_msg "grml CD-ROM still not yet found, sleeping for 5 more seconds and trying once more again."
620       sleep 5
621    fi
622 fi
623
624 # Harddisk-installed script part version has been removed
625 # (GRML can be booted directly from HD now).
626 mount_grml()
627 {
628   if test -n "$FOUND_GRML" -a -f $1/$GRML_DIR/$GRML_NAME; then
629     # echo "6" > /proc/sys/kernel/printk
630     mount -t squashfs $1/$GRML_DIR/$GRML_NAME /GRML -o loop,ro$SECURE || FOUND_GRML=""
631   fi
632 }
633
634 remount_grml()
635 {
636   if test -f $TARGET/$GRML_DIR/$GRML_NAME; then
637     umount /GRML # unmount it
638     umount $SOURCE  # unmount CD
639     [ -n "$SOURCE2" ] && umount $SOURCE2  # umount possible loop-device
640     mount_grml $TARGET
641   else
642     log_failure_msg "Warning: Changing to $TARGET failed."
643     return 1
644   fi
645
646   return 0
647 }
648
649 boot_from()
650 {
651   # preparations
652   /bin/mkdir $TARGET
653
654   SOURCE_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/bootfrom=/s/.*=//p' | /usr/bin/tail -1)
655
656   LOOP_DEV=$(echo $SOURCE_DEV | /usr/bin/gawk -F/ '{ print $1 "/" $2 "/" $3 }')
657   ISO_PATH=$(echo $SOURCE_DEV | /bin/sed "s|$LOOP_DEV||g" )
658   case "$ISO_PATH" in /*.[iI][sS][oO]) ;; *) ISO_PATH="" ;; esac
659   LOOP_SOURCE=""
660
661   # load filesystems
662   /GRML/sbin/modprobe fuse
663   /GRML/sbin/modprobe ntfs
664   $INSMOD /modules/div/ntfs.ko 1>/dev/null
665
666   if [ -n "$ISO_PATH" ]; then
667      LOOP_SOURCE="$TARGET.loop"
668      LOOP_SOURCE2="$LOOP_SOURCE"
669      TARGET_DEV="$LOOP_SOURCE$ISO_PATH"
670      /bin/mkdir $LOOP_SOURCE
671      /bin/mount -o ro $LOOP_DEV $LOOP_SOURCE || LOOP_SOURCE=""
672      /bin/mount -n -o loop $LOOP_SOURCE2$ISO_PATH $TARGET
673   else
674      TARGET_DEV="$SOURCE_DEV"
675     /bin/mount -n -o ro $SOURCE_DEV $TARGET
676   fi
677   if [ $? -ne 0 ]; then
678      [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
679      log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable."
680      sleep 2
681      return 1
682   fi
683
684   if [ -f $TARGET/$GRML_DIR/$GRML_NAME ]; then
685     log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}$TARGET_DEV${NORMAL}." ; echo "  $SUCCESS"
686   else
687     log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}"
688     [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
689     umount $TARGET
690     sleep 2
691     return 1
692   fi
693   # remount the CD
694   remount_grml
695 }
696
697 copy_to()
698 {
699   # preparations
700   /bin/mkdir $TARGET
701   COPY="$SOURCE/$GRML_DIR"
702
703   # look if we copy to hd or to ram
704   SIZE="$(/usr/bin/du -s $COPY | /usr/bin/gawk '{print int($1*1.1)}')"
705   test -n "$SIZE" || SIZE="800000"
706
707   case "$1" in
708     ram)
709       TARGET_DEV="/dev/shm"
710       TARGET_DEV_DESC="ramdisk"
711       FOUNDSPACE="$(/usr/bin/gawk '/MemTotal/{print $2}' /proc/meminfo)"
712       /bin/mount -n -t tmpfs -o size=${SIZE}k $TARGET_DEV $TARGET
713     ;;
714     hd)
715       TARGET_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/tohd=/s/.*=//p' | /usr/bin/tail -1)
716       TARGET_DEV_DESC="$TARGET_DEV"
717       # load filesystems
718       /GRML/sbin/modprobe fuse
719       /GRML/sbin/modprobe ntfs
720       FS="ext3 ext2 reiserfs reiser4 vfat ntfs"
721
722       MOUNTED=""
723       for i in $FS; do
724        if /GRML/bin/mount -o rw -t "$i" "$TARGET_DEV" "$TARGET"; then
725         MOUNTED="true"
726         break
727        fi
728       done
729       if test -z "$MOUNTED"; then
730         log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable."
731         sleep 2
732         return 1
733       fi
734       # check for enough free space
735       USED_SPACE=0
736       [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && USED_SPACE=$(/usr/bin/du -s $TARGET/$GRML_DIR/$GRML_NAME | /usr/bin/gawk '{ print $1 }')
737       FOUNDSPACE="$(/bin/df -k $TARGET | /usr/bin/tail -1 | /usr/bin/gawk '{ print $4+int('$USED_SPACE') }')"
738    ;;
739    *)
740      return 1
741    ;;
742   esac
743
744   # sanity check
745
746   if [ $FOUNDSPACE -lt $SIZE ]
747   then
748     log_failure_msg "Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${NORMAL}. Found: ${MAGENTA}${FOUNDSPACE}k${NORMAL} Need: ${MAGENTA}${SIZE}k${NORMAL}"
749     sleep 2
750     umount $TARGET
751     return 1
752   fi
753
754   # do the real copy
755
756   log_begin_msg "Copying grml CD-ROM to ${TARGET_DEV_DESC}... Please be patient."
757   echo
758   if [ -z "$use_cp" -a -x /usr/bin/rsync ]
759   then
760     # first cp the small files
761     /usr/bin/rsync -a --exclude="$GRML_DIR/$GRML_NAME" $COPY $TARGET # Copy grml to $TARGET
762     # then the big file with nice progress meter
763     [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && /bin/rm -f $TARGET/$GRML_DIR/$GRML_NAME
764     /usr/bin/rsync -a --progress --include="$GRML_DIR/$GRML_NAME" --include="$GRML_DIR/" --exclude="*" $COPY $TARGET # Copy grml to $TARGET
765     #/usr/bin/rsync -avP $COPY $TARGET # Copy grml to $TARGET
766     # make sure to support directories from http://grml.org/config/
767     for dir in scripts bootparams config debs ; do
768         if [ -d "/cdrom/$dir" ] ; then
769            log_begin_msg "Customization directory $dir found, copying to $TARGET"
770            cp -a /cdrom/$dir $TARGET/ && echo "$SUCCESS" || echo "$FAILED"
771         fi
772     done
773   else
774     /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET
775   fi
776   if [ $? -ne 0 ]
777   then
778     log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left."
779     sleep 2
780     return 1
781   fi
782   # remount r/o
783   /bin/mount -n -o remount,ro $TARGET 1>/dev/null 2>&1
784   remount_grml
785 }
786
787 mount_grml /cdrom
788
789 COPYTO=""
790 BOOTFROM=""
791 DO_REMOUNT=""
792 REAL_TARGET=""
793 UNIONFS=""
794
795 case "$CMDLINE" in *toram*) DO_REMOUNT="yes"; COPYTO="ram"; ;; esac
796 case "$CMDLINE" in *tohd=*) DO_REMOUNT="yes"; COPYTO="hd"; ;; esac
797 case "$CMDLINE" in *bootfrom=*) DO_REMOUNT="yes"; BOOTFROM="yes" ;; esac
798
799 # Remount later after copying/isoloading/driverloading?
800 # pre-test if everything succeeded
801 if  test -n "$DO_REMOUNT" -a -n "$FOUND_GRML" ; then
802   # copy library cache
803   cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
804   echo ""
805
806   SOURCE="/cdrom"
807   TARGET="/cdrom2"
808
809   # first copy_to, then boot_from
810   if [ -n "$COPYTO" ]; then
811      copy_to $COPYTO && REAL_TARGET="$TARGET"
812   fi
813   if [ -n "$BOOTFROM" ]; then
814      boot_from
815      if [ "$?" -eq "0" ]; then
816         # set new source / target paths
817         REAL_TARGET="$TARGET"
818         SOURCE2="$LOOP_SOURCE"
819         SOURCE="/cdrom2"
820         TARGET="/cdrom3"
821     fi
822   fi
823 fi
824
825 # Final test if everything succeeded.
826 if test -n "$FOUND_GRML" ; then
827 # copy library cache
828 cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
829
830 UNIONFS=""
831 if checkbootparam "unionfs" ; then
832    $INSMOD /modules/unionfs.ko 1>/dev/null
833    grep -q unionfs /proc/filesystems && UNIONFS=yes
834    unionfs='unionfs'
835    UNIONFS_FILETYPE='unionfs'
836    AUFS=''
837 else
838    $INSMOD /modules/aufs.ko 1>/dev/null
839    grep -q aufs /proc/filesystems && UNIONFS=yes
840    unionfs='unionfs (using aufs)'
841    UNIONFS_FILETYPE='aufs'
842    AUFS='yes'
843 fi
844
845 # Set paths
846 log_begin_msg "Setting paths"
847 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:."
848 export PATH
849
850 # Make space: We don't need the modules anymore from here.
851 /GRML/bin/rm -rf /modules
852 # Debian weirdness
853 /GRML/bin/cp -a /GRML/etc/alternatives /etc/ 2>/dev/null
854
855 # Replace /sbin
856 /GRML/bin/rm -f /sbin
857 /GRML/bin/ln -sf /GRML/sbin /sbin
858
859 # From here, we should have all essential commands available.
860 hash -r
861
862 # Did we remount the source media?
863 if  test -n "$REAL_TARGET"; then
864   /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot
865 fi
866
867 # Clean up /etc/mtab (and - just in case - make a nice entry for looped ISO)
868 egrep " /GRML | /cdrom " /proc/mounts 2>/dev/null | sed 's|/dev/loop0 /cdrom \(.*\) 0 0|'$LOOP_SOURCE$ISO_PATH' /cdrom/ \1,loop=/dev/loop0 0 0|g' >> /etc/mtab
869
870 # Clean up /
871 /GRML/bin/rm -rf /modules /static
872 echo "                       $SUCCESS"
873
874 # New in Kernel 2.4.x: tempfs with variable ramdisk size.
875 # We check for available memory anyways and limit the ramdisks
876 # to a reasonable size.
877 FOUNDMEM="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
878 TOTALMEM="$(awk 'BEGIN{m=0};/MemFree|Cached/{m+=$2};END{print m}' /proc/meminfo)"
879
880 # Be verbose
881 if [ -n "$FOUNDMEM" ] ; then
882    log_begin_msg "Total memory found: $FOUNDMEM kB" ; echo "       $SUCCESS"
883 else
884    log_failure_msg "Could not fetch memory information." ; echo "     $FAILED"
885 fi
886
887 # Now we need to use a little intuition for finding a ramdisk size
888 # that keeps us from running out of space, but still doesn't crash the
889 # machine due to lack of Ram
890
891 # Minimum size of additional ram partitions
892 MINSIZE=20000
893 # At least this much memory minus 30% should remain when home and var are full.
894 MINLEFT=16000
895 # Maximum ramdisk size
896 [ -n "$TOTALMEM" ] && MAXSIZE="$(/usr/bin/expr $TOTALMEM - $MINLEFT)"
897 # Default ramdisk size for ramdisk
898 [ -n "$TOTALMEM" ] && RAMSIZE="$(/usr/bin/expr $TOTALMEM / 5)"
899
900 # Create additional dynamic ramdisk.
901 test -z "$RAMSIZE" -o "$RAMSIZE" -lt "$MINSIZE" && RAMSIZE="$MINSIZE"
902 mkdir -p /ramdisk
903 # tmpfs/varsize version, can use swap
904 RAMSIZE=$(/usr/bin/expr $RAMSIZE \* 4)
905 log_begin_msg "Creating /ramdisk (dynamic size=${RAMSIZE}k) on shared memory"
906 # We need /bin/mount here for the -o size= option
907 /bin/mount -t tmpfs -o "size=${RAMSIZE}k" /ramdisk /ramdisk  && echo "$SUCCESS"
908 mkdir -p /ramdisk/tmp /ramdisk/home/grml && chmod 1777 /ramdisk/tmp && chown grml.grml /ramdisk/home/grml && ln -snf /ramdisk/home /home && /bin/mv /tmp /tmp.old && ln -s /ramdisk/tmp /tmp && rm -rf /tmp.old
909
910 stage=3
911 rundebugshell
912 # unionfs
913 log_begin_msg "Creating $unionfs and symlinks on ramdisk"
914 mkdir -p /UNIONFS
915 if test -n "$UNIONFS" && /bin/mount -t $UNIONFS_FILETYPE -o noatime${SECURE},dirs=/ramdisk=rw:/GRML=ro /UNIONFS /UNIONFS ; then
916  # check architecture
917  if [ -f /GRML/lib/ld-linux.so.2 ] ; then
918    LDLINUX=/GRML/lib/ld-linux.so.2
919    GRMLLIB=/GRML/lib
920  elif [ -f /GRML/lib64/ld-linux-x86-64.so.2 ] ; then
921    LDLINUX=/GRML/lib64/ld-linux-x86-64.so.2
922    EMUL='emul'
923    LIB64='lib64'
924    GRMLLIB=/GRML/lib64
925  fi
926  # We now have unionfs, copy some data from the initial ramdisk first
927  cp -a /etc/fstab /etc/auto.mnt /etc/filesystems /etc/mtab /UNIONFS/etc/
928  # disable resolvconf on the terminalserver client
929  if [ -n "$NFS" ] ; then
930     rm /UNIONFS/etc/resolv.conf
931     cp -a /etc/resolv.conf /UNIONFS/etc
932     echo REPORT_ABSENT_SYMLINK=no >> /UNIONFS/etc/default/resolvconf
933  fi
934  for i in bin boot etc sbin var opt root usr $EMUL $LIB64 lib ; do # Move directories to unionfs
935   if test -d /$i; then
936    /bin/mv /$i /$i.old && \
937    # /GRML/lib/ld-linux.so.2 --library-path /GRML/lib /GRML/bin/ln -snf /UNIONFS/$i /$i && \
938    $LDLINUX --library-path $GRMLLIB /GRML/bin/ln -snf /UNIONFS/$i /$i 1>/dev/null 2>/dev/null
939    rm -rf /$i.old
940   else
941    ln -snf /UNIONFS/$i /$i
942   fi
943  done
944  [ -n "$AUFS" ] && echo "    $SUCCESS" || echo "                 $SUCCESS"
945  log_begin_msg "Merging read-only system with read-writeable /ramdisk."
946  for i in $(cd /UNIONFS; echo *); do # Create links for new stuff on /UNIONFS
947    test "$i" = "home" -o "$i" = "tmp" && continue
948    test -L "/$i" || test -d "/$i" || test -f "/$i" || ln -snf "/UNIONFS/$i" /$i
949  done && echo "   $SUCCESS" || echo "   $FAILED"
950 else
951  echo ""
952  log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!"
953  echo "$FAILED"
954  sleep 2
955  echo "Can not continue booting, dropping you to a busybox shell."
956  stage=4
957  rundebugshell
958 fi
959
960 chown grml.grml /home/grml
961 # old:
962 # chmod 1777 /var/tmp
963 # new:
964 rm -rf /var/tmp/ ; mkdir /var/tmp ; chown root.root /var/tmp ; chmod 1777 /var/tmp
965
966 # Create empty utmp and wtmp
967 :> /var/run/utmp
968 :> /var/run/wtmp
969
970 # Make SURE that these are files, not links!
971 rm -rf /etc/ftpusers /etc/passwd /etc/shadow /etc/group \
972        /etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \
973        /etc/inittab /etc/network /etc/sudoers \
974        /etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf 2>/dev/null
975 cp -a /GRML/etc/ftpusers /GRML/etc/passwd /GRML/etc/shadow /GRML/etc/group \
976       /GRML/etc/ppp /GRML/etc/isdn /GRML/etc/ssh \
977       /GRML/etc/inittab /GRML/etc/network /GRML/etc/sudoers \
978       /GRML/sbin/init /GRML/etc/dhcpc /etc/ 2>/dev/null
979
980 # Extremely important, init crashes on shutdown if this is only a link
981 :> /etc/ioctl.save
982 :> /etc/pnm2ppa.conf
983 # Must exist for samba to work
984 [ -d /var/lib/samba ] && :> /var/lib/samba/unexpected.tdb
985 # Diet libc bug workaround
986 # cp -f /GRML/etc/localtime /etc/localtime
987 # echo "${BLUE}Done.${NORMAL}"
988
989 # Now tell kernel where the real modprobe lives
990 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
991
992 # Change root device from /dev/fd0 to /dev/ram0
993 echo "0x100" > /proc/sys/kernel/real-root-dev
994
995 /bin/umount /sys # (remount in grml-autoconfig)
996
997 stage=4
998 rundebugshell
999 # Give control to the init process.
1000 log_begin_msg "Starting init process. "
1001 [ -r /mountit ] && rm -f /mountit
1002 rm -f /linuxrc
1003 exit 0
1004
1005 else
1006  log_failure_msg "Error: Can't find grml filesystem, sorry."
1007  echo "
1008 Are you booting via USB or firewire?
1009 ====================================
1010 Try to boot with bootparam scandelay which delays the
1011 bootup sequence so modules should have enough time
1012 to initialize devices.
1013
1014 Usage examples on bootprompt of grml-iso:
1015
1016 grml scandelay       -> adds the default delay of 10 seconds
1017 grml scandelay=13    -> adds a delay of 13 seconds
1018
1019 Are you booting via SCSI?
1020 ====================================
1021 Use the bootparam scsi.
1022 Usage examples on bootprompt of grml-iso:
1023
1024 grml scsi=probe      -> autoprobing of scsi modules
1025 grml scsi=ask        -> list modules and prompt for module which should be loaded
1026 grml scsi=modulename -> loads specified module (without .ko extension)
1027 expert               -> activate expert mode, similar to scsi=ask
1028
1029 Are you getting SquashFS/zlib errors?
1030 =====================================
1031 Try to boot with \"grml nodma\"
1032
1033 Still problems?
1034 ===============
1035 Make sure the ISO itself is ok.
1036 Check the md5sum of downloaded ISO.
1037 Used a CD-RW? Make sure the medium is ok!
1038
1039 Please report any problems you notice to the grml-team!
1040 http://grml.org/contact/
1041 "
1042  echo "${RED}Now dropping you to the busybox shell.${NORMAL}"
1043  echo "${RED}Press reset button to quit.${NORMAL}"
1044  echo ""
1045  PS1="grml# "
1046  export PS1
1047  echo "6" > /proc/sys/kernel/printk
1048  # Allow signals
1049  trap 1 2 3 15
1050  exec /static/sh
1051 fi
1052 # EOF