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