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 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
6 # Latest change: Don Nov 16 14:46:00 CET 2006 [mika]
8 # Latest change: Mon Sep 18 23:19:53 CEST 2006 [mika]
9 >>>>>>> /tmp/linuxrc~other.LuZLNY
10 #######################################################################################
12 # hardcoded configurable options
13 # Default maximum size of dynamic ramdisk in kilobytes
17 # Don't allow interrupt signals
21 INSMOD="/static/insmod"
22 # [ -x /modules/insmod ] && INSMOD="/modules/insmod"
25 # [ -x /modules/rmmod ] && RMMOD="/modules/rmmod"
28 # BUILTIN_FS="iso9660 ext2 vfat"
29 BUILTIN_FS="iso9660 ext2 ext3 reiserfs vfat xfs jfs reiser4"
32 # Usage: mountit src dst "options"
33 for fs in $BUILTIN_FS; do
37 # We REALLY need this for Knoppix on DOS-filesystems
38 shortname="shortname=winnt"
39 [ -n "$options" ] && options="$options,$shortname" || options="-o $shortname"
42 mount -t $fs $options $1 $2 >/dev/null 2>&1 && return 0
53 exec >/dev/console </dev/console 2>&1
55 # Mount /proc and /dev/pts
56 mount -t proc /proc /proc
58 # Disable kernel messages while probing modules in autodetect mode
59 echo "0" > /proc/sys/kernel/printk
61 mount -t devpts /dev/pts /dev/pts
63 mount -t sysfs /sys /sys >/dev/null 2>&1
65 # Read boot command line with builtin cat command (shell read function fails in Kernel 2.4.19-rc1)
66 CMDLINE="$(cat /proc/cmdline)"
70 case "$(cat $2)" in *$1*) return 0;; esac
76 case "$2" in *$1*) return 0;; esac
80 # Reread boot command line; echo last parameter's argument or return false.
82 stringinstring " $1=" "$CMDLINE" || return 1
83 result="${CMDLINE##*$1=}"
84 result="${result%%[ ]*}"
89 # Check boot commandline for specified option
91 stringinstring " $1" "$CMDLINE"
95 if checkbootparam "nocolor" ; then
96 echo "Disabling colors in bootsequence as requested on commandline."
100 # Erase to end of line
102 # Clear and reset Screen
105 # Reset fb color mode
108 # Erase to end of line
110 # Clear and reset Screen
114 # RED: Failure or error message
116 # GREEN: Success message
118 # YELLOW: Descriptions
120 # BLUE: System mesages
122 # MAGENTA: Found devices or drivers
130 # don't output anything if running with bootsplash feature
131 if checkbootparam "splash" ; then
133 echo "${WHITE}Welcome to"
135 echo "${RED} ____ ____ __ __ _ "
136 echo "${RED} / ___| _ \| \/ | | "
137 echo "${RED} | | _| |_) | |\/| | | "
138 echo "${RED} | |_| | _ <| | | | |___ "
139 echo "${RED} \____|_| \_\_| |_|_____|"
141 echo "${WHITE}grml.org - Linux for users of texttools and sysadmins."
143 exec >/dev/null </dev/null 2>&1
146 # helper functions {{{
147 #log_success_msg () {
152 echo " ${RED}*${NORMAL} $@"
155 #log_warning_msg () {
156 # echo " ${BLUE}*${NORMAL} $@"
159 # int log_begin_message (char *message)
161 echo -n " ${GREEN}*${NORMAL} $@"
165 echo -n " ${YELLOW}*${NORMAL} $@"
168 # int log_end_message (int exitstatus)
169 SUCCESS=" ${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}"
170 FAILED=" ${NORMAL}[${RED}fail${NORMAL}]"
173 # Clear screen with colormode reset
174 # echo "$CLEAR$RESET"
176 # Just go to the top of the screen
179 echo "${WHITE}Welcome to"
181 echo "${RED} ____ ____ __ __ _ "
182 echo "${RED} / ___| _ \| \/ | | "
183 echo "${RED} | | _| |_) | |\/| | | "
184 echo "${RED} | |_| | _ <| | | | |___ "
185 echo "${RED} \____|_| \_\_| |_|_____|"
187 echo "${WHITE}grml.org - Linux for users of texttools and sysadmins."
190 # We only need the builtin commands and /static at this point
196 case "$CMDLINE" in *debuglinuxrc*) set -x; echo "linuxrc debugging activated"; DEBUG="yes"; ;; esac
197 case "$CMDLINE" in *BOOT_IMAGE=expert\ *) INTERACTIVE="yes"; :>/interactive; ;; esac
198 case "$CMDLINE" in *BOOT_IMAGE=vmware\ *) VMWARE="yes"; ;; esac
199 case "$CMDLINE" in *modules-disk*) INTERACTIVE="yes"; ;; esac
200 case "$CMDLINE" in *BOOT_IMAGE=debug\ *|*\ debug\ *) DEBUG="yes"; ;; esac
201 case "$CMDLINE" in *secure*) SECURE=",nosuid"; ;; esac
202 # Does the user want to skip scsi detection?
206 case "$CMDLINE" in *noscsi*|*nobootscsi*) NOSCSI="yes"; ;; esac
207 case "$CMDLINE" in *nousb\ *|*nobootusb*) NOUSB="yes"; ;; esac
208 case "$CMDLINE" in *nofirewire*|*nobootfirewire*) NOFIREWIRE="yes"; ;; esac
210 case "$CMDLINE" in *fromhd*) NOCD="yes"; ;; esac
211 case "$CMDLINE" in *fromdvd*) FROMDVD="yes"; ;; esac
212 case "$CMDLINE" in *idecd*|*atapicd*) IDECD="yes"; ;; esac
213 case "$CMDLINE" in *noideraid*) NOIDERAID="yes"; ;; esac
215 case "$CMDLINE" in *nousb2*) USB2="" NOUSB2="yes"; ;; esac
216 case "$CMDLINE" in *\ usb*) USB="yes"; ;; esac
220 case "$CMDLINE" in *grml_dir=*) GRML_DIR="$grml_dir"; ;; esac
221 case "$CMDLINE" in *grml_name=*) GRML_NAME="$grml_name"; ;; esac
223 if [ -n "$DEBUG" ]; then
224 log_begin_msg "Bootoption debug detected. Printing kernel command line:"
229 # Run a shell if in debug mode
230 # echo "${BLUE}Dropping you to a busybox shell for debugging.${NORMAL}"
233 if [ -n "$DEBUG" ]; then
234 log_begin_msg "Starting intermediate shell stage $stage as requested by \"debug\" option."
236 echo " ${GREEN}-${NORMAL} Just exit the shell to continue boot process...${NORMAL}"
237 if [ -x /static/sh ]; then
249 echo -n "${CRE}Please insert ${TYPE} modules disk and hit Return."
251 echo -n "${CRE}Mounting ${TYPE} modules disk... "
252 # We always mount over /modules/scsi (because it's there ;-)
253 if mountit /dev/fd0 /modules/scsi "-o ro"; then
254 echo "${GREEN}OK.${NORMAL}"
257 echo "${RED}NOT FOUND.${NORMAL}"
261 # Unmount module disk
264 echo -n "${CRE}Unmounting ${TYPE} modules disk... "
265 umount /modules/scsi 2>/dev/null
266 echo "${GREEN}DONE.${NORMAL}"
269 # Ask user for modules
271 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
273 echo "${TYPE} modules available:${WHITE}"
276 if test -f "/modules/scsi/$m"; then
277 test -z "$c" && { echo -n " $m"; c="1"; } || { echo " $m"; c=""; }
280 [ -n "$c" ] && echo ""
281 echo "Load ${TYPE} Modules?"
282 echo "[Enter full filename(s) (space-separated), Return for autoprobe, n for none] "
283 echo -n "insmod module(s)> "
285 case "$MODULES" in n|N) MODULES=""; ;; y|"") MODULES="$*"; ;; esac
288 echo "${TYPE} modules available:${WHITE}"
291 if test -f "/modules/scsi/$m"; then
292 test -z "$c" && { echo -n " $m"; c="1"; } || { echo " $m"; c=""; }
295 [ -n "$c" ] && echo ""
296 echo "Load ${TYPE} Modules?"
297 echo "[Enter full filename(s) (space-separated), Return for autoprobe, n for none] "
298 echo -n "insmod module(s)> "
300 case "$MODULES" in n|N) MODULES=""; ;; y|"") MODULES="$*"; ;; esac
301 >>>>>>> /tmp/linuxrc~other.LuZLNY
304 # Try to load the given modules (full path or current directory)
307 test -n "$INTERACTIVE" && echo "6" > /proc/sys/kernel/printk
310 echo -n " Probing ${TYPE}... ${WHITE}$i${NORMAL}: "
311 if test -f /modules/scsi/$i.ko && $INSMOD -f /modules/scsi/$i.ko >/dev/null 2>&1 && echo " $SUCCESS" || echo " failed " ; then
312 case "$TYPE" in scsi|SCSI) FOUND_SCSI="yes"; ;; esac
315 test -n "$INTERACTIVE" && echo "0" > /proc/sys/kernel/printk
319 # Check for SCSI, use modules on bootfloppy first
320 # Trying to do kind of /proc/pci hardware detection
321 if checkbootparam oldscsi ; then
322 PROCPCI="`cat /proc/pci 2>/dev/null`"
323 case "$PROCPCI" in *[Aa][Ii][Cc]-*|*[Aa][Hh][Aa]-*) SCSI_PROBE="$SCSI_PROBE aic7xxx" ;; esac
324 case "$PROCPCI" in *[Bb][Uu][Ss][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE BusLogic" ;; esac
325 case "$PROCPCI" in *[Tt][Rr][Mm]-[Ss]1040*|*[Dd][Cc]395*|*[Dd][Cc]315*) SCSI_PROBE="$SCSI_PROBE dc395x" ;; esac
326 case "$PROCPCI" in *53[Cc]8*) SCSI_PROBE="$SCSI_PROBE sym53c8xx" ;; esac
327 case "$PROCPCI" in *53[Cc]9*) SCSI_PROBE="$SCSI_PROBE NCR53C9x" ;; esac
328 case "$PROCPCI" in *53[Cc]406*) SCSI_PROBE="$SCSI_PROBE NCR53c406a" ;; esac
329 case "$PROCPCI" in *[Ii][Nn][Ii][Tt][Ii][Oo]\ *|*[Ii][Nn][Ii]-[Aa]100[Uu]2[Ww]*) SCSI_PROBE="$SCSI_PROBE initio" ;; esac
330 case "$PROCPCI" in *[Mm][Pp][Tt]*[Ss][Cc][Ss][Ii]*) SCSI_PROBE="$SCSI_PROBE mptbase mptscsih" ;; esac
331 case "$PROCPCI" in *[Aa][Dd][Vv][Aa][Nn][Cc][Ee][Dd]\ [Ss][Yy][Ss]*) SCSI_PROBE="$SCSI_PROBE advansys" ;; esac
332 case "$PROCPCI" in *[Aa][Tt][Pp]8*|*[Aa][Ee][Cc]6*) SCSI_PROBE="$SCSI_PROBE atp870u" ;; esac
333 case "$PROCPCI" in *[Dd][Tt][Cc]*) SCSI_PROBE="$SCSI_PROBE dtc" ;; esac
334 case "$PROCPCI" in *[Ee][Aa][Tt][Aa]*) SCSI_PROBE="$SCSI_PROBE eata" ;; esac
335 case "$PROCPCI" in *[Ff]*[Dd][Oo][Mm][Aa][Ii][Nn]*) SCSI_PROBE="$SCSI_PROBE fdomain" ;; esac
336 case "$PROCPCI" in *[Gg][Dd][Tt]\ *) SCSI_PROBE="$SCSI_PROBE gdth" ;; esac
337 case "$PROCPCI" in *[Mm][Ee][Gg][Aa][Rr][Aa][Ii][Dd]*) SCSI_PROBE="$SCSI_PROBE megaraid_mm megaraid_mbox" ;; esac
338 case "$PROCPCI" in *[Qq][Ll][Oo][Gg][Ii][Cc]*) SCSI_PROBE="$SCSI_PROBE qlogicfas408 qlogicfas qlogicfc" ;; esac
339 case "$PROCPCI" in *53[Cc]974*) SCSI_PROBE="$SCSI_PROBE tmscsim" ;; esac
340 case "$PROCPCI" in *[Uu][Ll][Tt][Rr][Aa][Ss][Tt][Oo][Rr]*) SCSI_PROBE="$SCSI_PROBE ultrastor" ;; esac
341 case "$PROCPCI" in *3[Ww][Aa][Rr][Ee]*) SCSI_PROBE="$SCSI_PROBE 3w-xxxx" ;; esac
344 # New sysfs based SCSI detection (thanks, Jörg Schirottke)
346 SYS=$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x; done|cut -f2 -d:)
347 while read id driver; do
348 for sysid in $SYS; do
350 if [ -z "$SCSI_PROBE" ]; then
353 SCSI_PROBE="$SCSI_PROBE $driver"
359 $(cat /modules/scsi/scsi-modules.txt)
363 if test -n "$INTERACTIVE"; then
364 # Let the user select interactively
365 askmodules SCSI $(cd /modules/scsi; echo *.ko)
367 # these are the autoprobe-safe modules
369 MODULES="$SCSI_PROBE"
372 if test -z "$NOSCSI" ; then
373 log_begin_msg "Scanning for SCSI devices."
374 $INSMOD -f /modules/scsi/firmware_class.ko 1>/dev/null
375 test -n "$MODULES" && loadmodules SCSI $MODULES && echo -n "" || echo " ${BLUE}[${NORMAL} none found ${BLUE}]${NORMAL} (try bootoption scsi=probe)"
377 log_warn_msg "Not scanning for SCSI devices as requested on commandline." && echo " $SUCCESS"
380 if checkbootparam scsi ; then
381 MODULE="$(getbootparam 'scsi' 2>/dev/null)"
382 if test "$MODULE" = "probe" ; then
383 log_begin_msg "Bootoption scsi=probe found. Trying to autoprobe SCSI modules:"
385 echo -n " Trying to load scsi_debug: " ; $INSMOD -f /modules/scsi/scsi_debug.ko 1>/dev/null && echo " $SUCCESS" || echo " [ failed ]"
386 for module in /modules/scsi/*.ko ; do
387 echo -n " Probing ${WHITE}${module}${NORMAL}..."
388 $INSMOD -f ${module} >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
390 elif test "$MODULE" = "ask" ; then
391 askmodules SCSI $(cd /modules/scsi; echo *.ko)
392 test -z "$NOSCSI" && test -n "$MODULES" && loadmodules SCSI $MODULES
394 [ -n "$MODULE" ] || echo " ${RED}Neither a specific module nor option probe nor option ask for SCSI module given. Skipping.${NORMAL}"
395 [ -n "$MODULE" ] && echo -n " Trying to load module ${WHITE}${MODULE}${NORMAL}:" ; \
396 $INSMOD -f "/modules/scsi/${MODULE}.ko" 1>/dev/null && echo " $SUCCESS" || echo " [ failed ]"
401 if test -n "$VMWARE" ; then
402 log_begin_msg "Bootoption VMware detected. Trying to load SCSI modules:"
404 for module in mptbase mptscsih mptspi BusLogic ; do
405 echo -n " Trying to load ${WHITE}${module}${NORMAL}: "
406 $INSMOD -f /modules/scsi/${module}.ko >/dev/null 2>&1 && echo " $SUCCESS" || echo " [ failed ]"
410 # Check for USB, use modules on bootfloppy first
411 if test -z "$NOUSB"; then
412 log_begin_msg "Checking for USB."
413 if test -f /modules/div/usbcore.ko; then
414 $INSMOD /modules/div/usbcore.ko >/dev/null 2>&1
416 for i in $USB2 uhci-hcd.ko ohci-hcd.ko ; do
417 test -f /modules/div/$i && $INSMOD /modules/div/$i >/dev/null 2>&1 && FOUNDUSB="yes"
419 if test -n "$FOUNDUSB"; then
420 test -f /modules/div/usb-storage.ko && $INSMOD /modules/div/usb-storage.ko >/dev/null 2>&1
423 echo " ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
426 if [ -n "$NOUSB2" ] ; then
427 echo " Not loading usb2 module ehci-hcd as requested on commandline."
428 echo " Notice: to skip loading of USB in initrd at all use bootoption nousb"
432 log_warn_msg "Not scanning for USB devices as requested on commandline." && echo " $SUCCESS"
433 echo " Notice that bootoption nousb affects initrd only, it does *not*"
434 echo " avoid loading of usb modules in userspace afterwards"
435 echo " Boot using something like 'nousb blacklist=uhci-hcd' to avoid loading of usb modules at all"
439 # Check for Firewire, use modules on bootfloppy first
440 if test -z "$NOFIREWIRE" ; then
441 log_begin_msg "Checking for Firewire."
442 if test -f /modules/div/ieee1394.ko ; then
443 $insmoD /modules/div/ieee1394.ko > /dev/null 2>&1
445 test -f /modules/div/ohci1394.ko && $INSMOD /modules/div/ohci1394.ko > /dev/null 2>&1 && FOUNDFIREWIRE="yes"
446 if test -n "$FOUNDFIREWIRE" ; then
447 test -f /modules/div/sbp2.ko && $INSMOD /modules/div/sbp2.ko > /dev/null 2>&1
450 echo " ${BLUE}[${NORMAL} not found ${BLUE}]${NORMAL}"
455 log_warn_msg "Not scanning for firewire devices as requested on commandline." && echo " $SUCCESS"
456 echo " Notice that bootoption nofirewire affects initrd only, it does *not*"
457 echo " avoid loading of firewire modules in userspace afterwards"
458 echo " Boot with something like 'nofirewire blacklist=ohci1394' to avoid loading of firewire modules at all"
460 # End of FIREWIRE check
462 # Unfortunately, hotpluggable devices tend to need some time in order to register
463 if test -n "$FOUNDUSB" -o -n "$FOUNDFIREWIRE"; then
464 log_begin_msg "Scanning for USB/Firewire devices."
466 if test -n "$USB"; then
472 if checkbootparam scandelay ; then
473 DELAY="$(getbootparam 'scandelay' 2>/dev/null)"
474 [ -z $DELAY ] && DELAY='10'
475 log_begin_msg "Delaying bootsequence as requested for ${WHITE}${DELAY}${NORMAL} seconds."
476 sleep $DELAY && echo " $SUCCESS"
480 if checkbootparam bootpcmcia ; then
481 log_begin_msg "Bootoption bootpcmcia found. Trying to load ${WHITE}PCMCIA${NORMAL} modules..."
482 if $INSMOD -f /modules/div/pcmcia_core.ko 1>/dev/null ; then
483 $INSMOD -f /modules/div/firmware_class.ko 1>/dev/null && \
484 $INSMOD -f /modules/div/pcmcia.ko 1>/dev/null && \
485 $INSMOD -f /modules/div/rsrc_nonstatic.ko 1>/dev/null && \
486 $INSMOD -f /modules/div/yenta_socket.ko 1>/dev/null && echo " $SUCCESS"
492 # Check for misc modules in expert mode
493 if test -n "$INTERACTIVE" ; then
496 while test "$answer" != "n" -a "$answer" != "N" ; do
497 echo -n "${CYAN}Do you want to load additional modules from$another floppy disk? [${WHITE}Y${CYAN}/n] ${NORMAL}"
500 case "$answer" in n*|N*) break; ;; esac
501 if mountmodules new ; then
502 askmodules new $(cd /modules/scsi; echo *.ko)
503 test -n "$MODULES" && loadmodules new $MODULES
504 umountmodules current
508 # All interactively requested modules should be loaded now.
510 # Check for ide-scsi supported CD-Roms et al.
511 test -f /proc/scsi/scsi && FOUND_SCSI="yes"
513 # Disable kernel messages again
514 echo "0" > /proc/sys/kernel/printk
516 # We now enable DMA right here, for faster reading/writing from/to IDE devices
517 # in FROMHD or TORAM mode
518 case "$CMDLINE" in *\ nodma*) ;; *)
519 for d in $(cd /proc/ide 2>/dev/null && echo hd[a-z]); do
520 if test -d /proc/ide/$d; then
521 MODEL="$(cat /proc/ide/$d/model 2>/dev/null)"
522 test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
523 log_begin_msg "Enabling DMA acceleration for: ${MAGENTA}$d ${YELLOW}[${MODEL}]${NORMAL}"
524 echo "using_dma:1" >/proc/ide/$d/settings && echo ""
533 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
534 if [ -n "$NFS" ]; then
535 tmp_="$(getbootparam nfsdir)"
536 echo -n "checkbootparam nfsdir "
537 checkbootparam "nfsdir" && echo "OK" || echo "FAILED"
538 echo "getbootparam nfsdir=\"$tmp_\""
540 # put the mylibs into /lib for discover and udhcpc
543 # starting hw-detection for network card
544 echo "Starting hw-detection"
545 kernel_version_=`uname -r`
546 modules_to_load=$(/static/discover --disable-bus all --enable-bus pci --type network --normalize-whitespace --data-path=linux/module/name --data-version=$kernel_version_ | grep -v '^ $' | uniq)
547 echo "trying to load the following network modules: \"$modules_to_load\""
549 # FIXME modprobe is buggy from busybox
550 modules_to_load=`echo $modules_to_load | xargs`
554 tmp_="`modprobe -vn $mod`"
555 if [ $? -ne 0 ]; then
561 modLoad "$modules_to_load"
563 # loading additional modules
564 modLoad sunrpc lockd af_packet nfs
566 /static/udhcpc --foreground --quit --script=/static/udhcp-config.sh
567 #echo "press <enter> to start a system shell and configure your system"
570 # recreate the old dir structures
572 #rm -rf /myusr /mylib
574 log_begin_msg "${RED}Debug: NFS = ${NFS}${NORMAL}"
575 log_begin_msg -n "${CRE}${BLUE}Looking for GRML in: ${MAGENTA}$NFS${NORMAL} "
576 if mount -t nfs "$NFS" -o "async,ro,nolock" /cdrom #>/dev/null 2>&1
578 if checkbootparam "nfsdir" ; then
579 NFS="$(getbootparam nfsdir)"
583 # echo "${CRE}${BLUE}No NFS-server given, assuming default $NFS${NORMAL}"
585 echo "${RED}Debug: NFS = ${NFS}${NORMAL}"
586 log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$NFS${NORMAL}"
587 if mountit -t nfs $NFS "-o ro" >/dev/null 2>&1
588 >>>>>>> /tmp/linuxrc~other.LuZLNY
590 if test -f /cdrom/$GRML_DIR/$GRML_NAME
592 log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}${NFS}${NORMAL}" ; echo " $SUCCESS"
600 # Now that the right SCSI driver is (hopefully) loaded, try to find CD-ROM
601 if test -z $NFS ; then
603 test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
604 # New: Also try parallel port CD-Roms [for Mike].
605 DEVICES="$DEVICES /dev/pcd?"
606 # New: also check HD partitions for a GRML/GRML image
607 # notice: use /dev/sd? for usb-sticks without partition(s)
608 test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9] /dev/sd?"
609 DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
610 case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
613 log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$i${NORMAL}"
614 if mountit $i /cdrom "-o ro" >/dev/null 2>&1
617 if test -f /cdrom/$GRML_DIR/$GRML_NAME
619 log_begin_msg "Accessing grml CD-ROM at: ${MAGENTA}$i${NORMAL}" ; echo " $SUCCESS"
628 # Harddisk-installed script part version has been removed
629 # (GRML can be booted directly from HD now).
632 if test -n "$FOUND_GRML" -a -f $1/$GRML_DIR/$GRML_NAME; then
633 # echo "6" > /proc/sys/kernel/printk
634 mount -t squashfs $1/$GRML_DIR/$GRML_NAME /GRML -o loop,ro$SECURE || FOUND_GRML=""
640 if test -f $TARGET/$GRML_DIR/$GRML_NAME; then
641 umount /GRML # unmount it
642 umount $SOURCE # unmount CD
643 [ -n "$SOURCE2" ] && umount $SOURCE2 # umount possible loop-device
646 log_failure_msg "Warning: Changing to $TARGET failed."
658 SOURCE_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/bootfrom=/s/.*=//p' | /usr/bin/tail -1)
660 LOOP_DEV=$(echo $SOURCE_DEV | /usr/bin/gawk -F/ '{ print $1 "/" $2 "/" $3 }')
661 ISO_PATH=$(echo $SOURCE_DEV | /bin/sed "s|$LOOP_DEV||g" )
662 case "$ISO_PATH" in /*.[iI][sS][oO]) ;; *) ISO_PATH="" ;; esac
666 /GRML/sbin/modprobe fuse
667 /GRML/sbin/modprobe ntfs
668 $INSMOD -f /modules/div/ntfs.ko 1>/dev/null
670 if [ -n "$ISO_PATH" ]; then
671 LOOP_SOURCE="$TARGET.loop"
672 LOOP_SOURCE2="$LOOP_SOURCE"
673 TARGET_DEV="$LOOP_SOURCE$ISO_PATH"
674 /bin/mkdir $LOOP_SOURCE
675 /bin/mount -o ro $LOOP_DEV $LOOP_SOURCE || LOOP_SOURCE=""
676 /bin/mount -n -o loop $LOOP_SOURCE2$ISO_PATH $TARGET
678 TARGET_DEV="$SOURCE_DEV"
679 /bin/mount -n -o ro $SOURCE_DEV $TARGET
681 if [ $? -ne 0 ]; then
682 [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
683 log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable."
688 if [ -f $TARGET/$GRML_DIR/$GRML_NAME ]; then
689 log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}$TARGET_DEV${NORMAL}." ; echo " $SUCCESS"
691 log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}"
692 [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE
705 COPY="$SOURCE/$GRML_DIR"
707 # look if we copy to hd or to ram
708 SIZE="$(/usr/bin/du -s $COPY | /usr/bin/gawk '{print int($1*1.1)}')"
709 test -n "$SIZE" || SIZE="800000"
713 TARGET_DEV="/dev/shm"
714 TARGET_DEV_DESC="ramdisk"
715 FOUNDSPACE="$(/usr/bin/gawk '/MemTotal/{print $2}' /proc/meminfo)"
716 /bin/mount -n -t tmpfs -o size=${SIZE}k $TARGET_DEV $TARGET
719 TARGET_DEV=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/tohd=/s/.*=//p' | /usr/bin/tail -1)
720 TARGET_DEV_DESC="$TARGET_DEV"
722 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
723 /GRML/sbin/modprobe fuse
724 /GRML/sbin/modprobe ntfs
725 FS="ext3 ext2 reiserfs reiser4 vfat ntfs"
729 if /GRML/bin/mount -o rw -t "$i" "$TARGET_DEV" "$TARGET"; then
734 if test -z "$MOUNTED"; then
735 log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable."
738 /GRML/sbin/modprobe fuse
739 /GRML/sbin/modprobe ntfs
740 FS="ext3 ext2 reiserfs reiser4 vfat ntfs"
744 if /GRML/bin/mount -o rw -t "$i" "$TARGET_DEV" "$TARGET"; then
749 if test -z "$MOUNTED"; then
750 echo -n "${CRE} ${RED}Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${RED} is not mountable.${NORMAL}"
752 >>>>>>> /tmp/linuxrc~other.LuZLNY
755 # check for enough free space
757 [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && USED_SPACE=$(/usr/bin/du -s $TARGET/$GRML_DIR/$GRML_NAME | /usr/bin/gawk '{ print $1 }')
758 FOUNDSPACE="$(/bin/df -k $TARGET | /usr/bin/tail -1 | /usr/bin/gawk '{ print $4+int('$USED_SPACE') }')"
767 if [ $FOUNDSPACE -lt $SIZE ]
769 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}"
776 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
778 log_begin_msg "Copying grml CD-ROM to ${TARGET_DEV_DESC}... Please be patient."
782 echo "${CRE} ${GREEN}Copying grml CD-ROM to ${MAGENTA}$TARGET_DEV_DESC${GREEN}... Please be patient. ${NORMAL}"
783 >>>>>>> /tmp/linuxrc~other.LuZLNY
784 if [ -z "$use_cp" -a -x /usr/bin/rsync ]
786 # first cp the small files
787 /usr/bin/rsync -a --exclude="$GRML_DIR/$GRML_NAME" $COPY $TARGET # Copy grml to $TARGET
788 # then the big file with nice progress meter
789 [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && /bin/rm -f $TARGET/$GRML_DIR/$GRML_NAME
790 /usr/bin/rsync -a --progress --include="$GRML_DIR/$GRML_NAME" --include="$GRML_DIR/" --exclude="*" $COPY $TARGET # Copy grml to $TARGET
791 #/usr/bin/rsync -avP $COPY $TARGET # Copy grml to $TARGET
792 # make sure to support directories from http://grml.org/config/
793 for dir in scripts bootparams config debs ; do
794 if [ -d "/cdrom/$dir" ] ; then
795 log_begin_msg "Customization directory $dir found, copying to $TARGET"
796 cp -a /cdrom/$dir $TARGET/ && echo "$SUCCESS" || echo "$FAILED"
800 /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET
804 log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left."
809 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
810 /bin/mount -n -o remount,ro $TARGET 1>/dev/null 2>&1
812 /bin/mount -n -o remount,ro $TARGET
813 >>>>>>> /tmp/linuxrc~other.LuZLNY
825 case "$CMDLINE" in *toram*) DO_REMOUNT="yes"; COPYTO="ram"; ;; esac
826 case "$CMDLINE" in *tohd=*) DO_REMOUNT="yes"; COPYTO="hd"; ;; esac
827 case "$CMDLINE" in *bootfrom=*) DO_REMOUNT="yes"; BOOTFROM="yes" ;; esac
829 # Remount later after copying/isoloading/driverloading?
830 # pre-test if everything succeeded
831 if test -n "$DO_REMOUNT" -a -n "$FOUND_GRML" ; then
833 cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
838 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
840 # first copy_to, then boot_from
841 if [ -n "$COPYTO" ]; then
842 copy_to $COPYTO && REAL_TARGET="$TARGET"
844 if [ -n "$BOOTFROM" ]; then
846 if [ "$?" -eq "0" ]; then
847 # set new source / target paths
848 REAL_TARGET="$TARGET"
849 SOURCE2="$LOOP_SOURCE"
854 # first copy_to, then boot_from
855 if [ -n "$COPYTO" ]; then
856 copy_to $COPYTO && REAL_TARGET="$TARGET"
858 if [ -n "$BOOTFROM" ]; then
860 if [ "$?" -eq "0" ]; then
861 # set new source / target paths
862 REAL_TARGET="$TARGET"
863 SOURCE2="$LOOP_SOURCE"
866 >>>>>>> /tmp/linuxrc~other.LuZLNY
871 # Final test if everything succeeded.
872 if test -n "$FOUND_GRML"
875 cat /GRML/etc/ld.so.cache > /etc/ld.so.cache
878 $INSMOD /modules/unionfs.ko 1>/dev/null
879 grep -q unionfs /proc/filesystems && UNIONFS=yes
881 # Enable kernel messages
882 echo "6" > /proc/sys/kernel/printk
885 log_begin_msg "Setting paths"
886 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:."
889 # Make space: We don't need the modules anymore from here.
890 /GRML/bin/rm -rf /modules
892 /GRML/bin/cp -a /GRML/etc/alternatives /etc/ 2>/dev/null
895 /GRML/bin/rm -f /sbin
896 /GRML/bin/ln -sf /GRML/sbin /sbin
898 # From here, we should have all essential commands available.
901 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
902 # Did we remount the source media?
903 if test -n "$REAL_TARGET"; then
904 /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot
906 # Did we remount the source media ?
907 if test -n "$REAL_TARGET";
909 /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot
910 >>>>>>> /tmp/linuxrc~other.LuZLNY
913 # Clean up /etc/mtab (and - just in case - make a nice entry for looped ISO)
914 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
917 /GRML/bin/rm -rf /modules /static
920 # New in Kernel 2.4.x: tempfs with variable ramdisk size.
921 # We check for available memory anyways and limit the ramdisks
922 # to a reasonable size.
923 FOUNDMEM="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
924 TOTALMEM="$(awk 'BEGIN{m=0};/MemFree|Cached/{m+=$2};END{print m}' /proc/meminfo)"
927 log_begin_msg "Total memory found: $FOUNDMEM kB" ; echo " $SUCCESS"
929 # Now we need to use a little intuition for finding a ramdisk size
930 # that keeps us from running out of space, but still doesn't crash the
931 # machine due to lack of Ram
933 # Minimum size of additional ram partitions
935 # At least this much memory minus 30% should remain when home and var are full.
937 # Maximum ramdisk size
938 MAXSIZE="$(expr $TOTALMEM - $MINLEFT)"
939 # Default ramdisk size for ramdisk
940 RAMSIZE="$(expr $TOTALMEM / 5)"
942 # Create additional dynamic ramdisk.
943 test -z "$RAMSIZE" -o "$RAMSIZE" -lt "$MINSIZE" && RAMSIZE="$MINSIZE"
945 # tmpfs/varsize version, can use swap
946 RAMSIZE=$(expr $RAMSIZE \* 4)
947 log_begin_msg "Creating /ramdisk (dynamic size=${RAMSIZE}k) on shared memory"
948 # We need /bin/mount here for the -o size= option
949 /bin/mount -t tmpfs -o "size=${RAMSIZE}k" /ramdisk /ramdisk && echo "$SUCCESS"
950 mkdir -p /ramdisk/tmp /ramdisk/home/grml && chmod 1777 /ramdisk/tmp && chown grml.grml /ramdisk/home/grml && ln -snf /ramdisk/home /home && mv /tmp /tmp.old && ln -s /ramdisk/tmp /tmp && rm -rf /tmp.old
955 log_begin_msg "Creating unionfs and symlinks on ramdisk"
957 if test -n "$UNIONFS" && /bin/mount -t unionfs -o noatime${SECURE},dirs=/ramdisk=rw:/GRML=ro /UNIONFS /UNIONFS; then
958 # We now have unionfs, copy some data from the initial ramdisk first
959 cp -a /etc/fstab /etc/auto.mnt /etc/filesystems /etc/mtab /UNIONFS/etc/
960 for i in bin boot etc sbin var lib opt root usr; do # Move directories to unionfs
963 /GRML/lib/ld-linux.so.2 --library-path /GRML/lib /GRML/bin/ln -snf /UNIONFS/$i /$i && \
966 ln -snf /UNIONFS/$i /$i
970 log_begin_msg "Merging read-only system with read-writeable /ramdisk."
971 for i in $(cd /UNIONFS; echo *); do # Create links for new stuff on /UNIONFS
972 test "$i" = "home" -o "$i" = "tmp" && continue
973 test -L "/$i" || test -d "/$i" || test -f "/$i" || ln -snf "/UNIONFS/$i" /$i
974 done && echo " $SUCCESS" || echo " $FAILED"
977 log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!"
980 /GRML/sbin/halt -f -n
983 chown grml.grml /home/grml
985 # chmod 1777 /var/tmp
987 rm -rf /var/tmp/ ; mkdir /var/tmp ; chown root.root /var/tmp ; chmod 1777 /var/tmp
989 # Create empty utmp and wtmp
993 # Make SURE that these are files, not links!
994 rm -rf /etc/ftpusers /etc/passwd /etc/shadow /etc/group \
995 /etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \
996 /etc/inittab /etc/network /etc/sudoers \
997 /etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf 2>/dev/null
998 cp -a /GRML/etc/ftpusers /GRML/etc/passwd /GRML/etc/shadow /GRML/etc/group \
999 /GRML/etc/ppp /GRML/etc/isdn /GRML/etc/ssh \
1000 /GRML/etc/inittab /GRML/etc/network /GRML/etc/sudoers \
1001 /GRML/sbin/init /GRML/etc/dhcpc /etc/ 2>/dev/null
1003 # Extremely important, init crashes on shutdown if this is only a link
1005 :> /etc/pnm2ppa.conf
1006 # Must exist for samba to work
1007 [ -d /var/lib/samba ] && :> /var/lib/samba/unexpected.tdb
1008 # Diet libc bug workaround
1009 # cp -f /GRML/etc/localtime /etc/localtime
1010 # echo "${BLUE}Done.${NORMAL}"
1012 # Now tell kernel where the real modprobe lives
1013 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
1015 # Change root device from /dev/fd0 to /dev/ram0
1016 echo "0x100" > /proc/sys/kernel/real-root-dev
1018 umount /sys # (remount in grml-autoconfig)
1022 # Give control to the init process.
1023 log_begin_msg "Starting init process."
1024 [ -r /mountit ] && rm -f /mountit
1029 <<<<<<< /home/mika/grml/hg/grml-terminalserver/linuxrc
1030 log_failure_msg "Error: Can't find grml filesystem, sorry."
1032 Are you booting via USB or firewire?
1033 ====================================
1034 Try to boot with bootparam scandelay which delays the
1035 bootup sequence so modules should have enough time
1036 to initialize devices.
1038 Usage examples on bootprompt of grml-iso:
1040 grml scandelay -> adds the default delay of 10 seconds
1041 grml scandelay=13 -> adds a delay of 13 seconds
1043 Are you booting via SCSI?
1044 ====================================
1045 Use the bootparam scsi.
1046 Usage examples on bootprompt of grml-iso:
1048 grml scsi=probe -> autoprobing of scsi modules
1049 grml scsi=ask -> list modules and prompt for module which should be loaded
1050 grml scsi=modulename -> loads specified module (without .ko extension)
1051 expert -> activate expert mode, similar to scsi=ask
1053 Are you getting SquashFS/zlib errors?
1054 =====================================
1055 Try to boot with \"grml nodma\"
1059 Make sure the ISO itself is ok.
1060 Check the md5sum of downloaded ISO.
1061 Used a CD-RW? Make sure the medium is ok!
1063 Please report any problems you notice to the grml-team!
1064 http://grml.org/contact/
1066 echo "${RED}Now dropping you to the busybox shell.${NORMAL}"
1067 echo "${RED}Press reset button to quit.${NORMAL}"
1071 echo "6" > /proc/sys/kernel/printk
1076 echo "${CRE}${RED}Can't find grml filesystem, sorry.${NORMAL}"
1078 Are you booting via USB or firewire?
1079 ====================================
1080 Try to boot with bootparam scandelay which delays the
1081 bootup sequence so modules should have enough time
1082 to initialize devices.
1084 Usage examples on bootprompt of grml-iso:
1086 grml scandelay -> adds the default delay of 10 seconds
1087 grml scandelay=13 -> adds a delay of 13 seconds
1089 Are you booting via SCSI?
1090 ====================================
1091 Use the bootparam scsi.
1092 Usage examples on bootprompt of grml-iso:
1094 grml scsi=probe -> autoprobing of scsi modules
1095 grml scsi=ask -> list modules and prompt for module which should be loaded
1096 grml scsi=modulename -> loads specified module (without .ko extension)
1097 expert -> activate expert mode, similar to scsi=ask
1099 Are you getting SquashFS/zlib errors?
1100 =====================================
1101 Try to boot with \"grml nodma\"
1105 Make sure the ISO itself is ok.
1106 Check the md5sum of downloaded ISO.
1107 Used a CD-RW? Make sure the medium is ok!
1109 Please report any problems you notice to the grml-team!
1110 http://grml.org/contact/
1112 echo "${RED}Now dropping you to the busybox shell.${NORMAL}"
1113 echo "${RED}Press reset button to quit.${NORMAL}"
1117 echo "6" > /proc/sys/kernel/printk
1121 >>>>>>> /tmp/linuxrc~other.LuZLNY