X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=rewrite%2Flinuxrc;h=5f4a09ce9ef82cd13490014f11779a350ff6216d;hb=ec8b1031df42f0854327649a0d7761228d3acd40;hp=48b2aa9d0d68db5e9105e588974cec99d2484c28;hpb=c2973166d09f796d31916b37790739730071a8d6;p=grml-live.git diff --git a/rewrite/linuxrc b/rewrite/linuxrc index 48b2aa9..5f4a09c 100644 --- a/rewrite/linuxrc +++ b/rewrite/linuxrc @@ -2,7 +2,7 @@ # Filename: /linuxrc # Purpose: minirt for kernel 2.6 running on grml live-cd # Authors: (c) Klaus Knopper , (c) Michael Prokop -# Latest change: Tue Mar 27 23:05:51 CEST 2007 +# Latest change: Sat Apr 14 12:41:44 CEST 2007 [mika] ####################################################################################### # hardcoded configurable options @@ -145,7 +145,7 @@ fi #} log_failure_msg () { - echo " ${RED}*${NORMAL} $@" + echo -n " ${RED}*${NORMAL} $@" } #log_warning_msg () { @@ -171,17 +171,30 @@ FAILED=" ${NORMAL}[${RED}fail${NORMAL}]" # echo "$CLEAR" # Just go to the top of the screen # echo -n "" +DISTRI="$(getbootparam 'distri' 2>/dev/null)" +if [ -n "$DISTRI" ] ; then +SPLASH=" +${RED} $DISTRI + +${WHITE}based on grml.org. + +${NORMAL}" +else +SPLASH=" +${RED} ____ ____ __ __ _ +${RED} / ___| _ \| \/ | | +${RED} | | _| |_) | |\/| | | +${RED} | |_| | _ <| | | | |___ +${RED} \____|_| \_\_| |_|_____| + +${WHITE}grml.org - Linux for users of texttools and sysadmins. + +${NORMAL}" +fi + echo "" echo "${WHITE}Welcome to" -echo "" -echo "${RED} ____ ____ __ __ _ " -echo "${RED} / ___| _ \| \/ | | " -echo "${RED} | | _| |_) | |\/| | | " -echo "${RED} | |_| | _ <| | | | |___ " -echo "${RED} \____|_| \_\_| |_|_____|" -echo "" -echo "${WHITE}grml.org - Linux for users of texttools and sysadmins." -echo "${NORMAL}" +echo "$SPLASH" # We need the builtin commands and /static only starting at this point PATH=/static @@ -215,6 +228,7 @@ GRML_DIR="GRML" GRML_NAME="GRML" case "$CMDLINE" in *grml_dir=*) GRML_DIR="$grml_dir"; ;; esac case "$CMDLINE" in *grml_name=*) GRML_NAME="$grml_name"; ;; esac +case "$CMDLINE" in *small*) GRML_TYPE="small"; ;; esac # NFS for i in $cmdline; do case "$i" in nfsdir=*|NFSDIR=*) eval $i;; esac; done @@ -326,7 +340,7 @@ fi # New sysfs based SCSI detection (thanks, Jörg Schirottke) sysfsscsi(){ -SYS=$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x; done|cut -f2 -d:) +SYS=$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x 2>/dev/null; done|cut -f2 -d:) while read id driver; do for sysid in $SYS; do case $sysid in $id) @@ -531,14 +545,15 @@ if [ -n "$NFS" ]; then done } # modules.alias and modules.dep are in place so USE IT :)! - modLoad "$(for x in $(find /sys/devices/ -name modalias); do grep pci: $x; done |/static/xargs)" - + find /sys/devices/ -name modalias |/static/xargs -r /static/grep -h pci: |while read i; do + modLoad "$i" + done # loading additional modules modLoad sunrpc lockd af_packet nfs dhcp_iface_=$(getbootparam dhcp_iface) if [ -z "$dhcp_iface_" ]; then - dhcp_iface_=`ifconfig -a | grep '^eth' | sed 's/ .*//'` + dhcp_iface_=`ifconfig -a | grep '^eth' | sed 's/ .*//'` fi # make sure we have a udhcpc executable, if it's not present @@ -570,31 +585,45 @@ if [ -n "$NFS" ]; then fi # Now that the right SCSI driver is (hopefully) loaded, try to find CD-ROM -if test -z $NFS ; then - DEVICES="/dev/hd?" - test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES" - # New: Also try parallel port CD-Roms [for Mike]. - DEVICES="$DEVICES /dev/pcd?" - # New: also check HD partitions for a GRML/GRML image - # notice: use /dev/sd? for usb-sticks without partition(s) - test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9] /dev/sd?" - DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]" - case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac - for i in $DEVICES - do - log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$i${NORMAL}" - if mountit $i /cdrom "-o ro" >/dev/null 2>&1 - then - echo " $SUCCESS" - if test -f /cdrom/$GRML_DIR/$GRML_NAME - then - log_begin_msg "Accessing grml CD-ROM at: ${MAGENTA}$i${NORMAL}" ; echo " $SUCCESS" - FOUND_GRML="$i" - break - fi - umount /cdrom +grmlmount() +{ + if test -z $NFS ; then + DEVICES="/dev/hd?" + test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES" + # New: Also try parallel port CD-ROMs + DEVICES="$DEVICES /dev/pcd?" + # New: also check HD partitions for a GRML/GRML image + # notice: use /dev/sd? for usb-sticks without partition(s) + test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9] /dev/sd?" + DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]" + case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac + for i in $DEVICES ; do + log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$i${NORMAL}" + if mountit $i /cdrom "-o ro" >/dev/null 2>&1 ; then + echo " $SUCCESS" + if test -f /cdrom/$GRML_DIR/$GRML_NAME ; then + log_begin_msg "Accessing grml CD-ROM at: ${MAGENTA}$i${NORMAL}" ; echo " $SUCCESS" + FOUND_GRML="$i" + break + fi + umount /cdrom + fi + done fi - done +} + +# Rerun the grml-CDROM part 3 times at total +grmlmount +if [ -z "$FOUND_GRML" ] ; then + echo + log_warn_msg "grml CD-ROM not yet found, sleeping for 5 seconds and trying again then." + sleep 5 && echo " $SUCCESS" + grmlmount + if [ -z "$FOUND_GRML" ] ; then + echo + log_warn_msg "grml CD-ROM still not yet found, sleeping for 5 more seconds and trying once more again." + sleep 5 && echo " $SUCCESS" + fi fi # Harddisk-installed script part version has been removed @@ -615,7 +644,7 @@ remount_grml() [ -n "$SOURCE2" ] && umount $SOURCE2 # umount possible loop-device mount_grml $TARGET else - log_failure_msg "Warning: Changing to $TARGET failed." + log_failure_msg "Warning: Changing to $TARGET failed." ; echo "$FAILED" return 1 fi @@ -652,7 +681,7 @@ boot_from() fi if [ $? -ne 0 ]; then [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE - log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable." + log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable." ; echo "$FAILED" sleep 2 return 1 fi @@ -660,7 +689,7 @@ boot_from() if [ -f $TARGET/$GRML_DIR/$GRML_NAME ]; then log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}$TARGET_DEV${NORMAL}." ; echo " $SUCCESS" else - log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}" + log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}" ; echo "$FAILED" [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE umount $TARGET sleep 2 @@ -703,7 +732,7 @@ copy_to() fi done if test -z "$MOUNTED"; then - log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable." + log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable." ; echo "$FAILED" sleep 2 return 1 fi @@ -718,21 +747,18 @@ copy_to() esac # sanity check - - if [ $FOUNDSPACE -lt $SIZE ] - then - 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}" + if [ $FOUNDSPACE -lt $SIZE ] ; then + log_failure_msg "Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${NORMAL}:" ; echo "$FAILED" + log_failure_msg "Found: ${MAGENTA}${FOUNDSPACE}k${NORMAL} Need: ${MAGENTA}${SIZE}k${NORMAL}" ; echo "$FAILED" sleep 2 umount $TARGET return 1 fi # do the real copy - log_begin_msg "Copying grml CD-ROM to ${TARGET_DEV_DESC}... Please be patient." echo - if [ -z "$use_cp" -a -x /usr/bin/rsync ] - then + if [ -z "$use_cp" -a -x /usr/bin/rsync ] ; then # first cp the small files /usr/bin/rsync -a --exclude="$GRML_DIR/$GRML_NAME" $COPY $TARGET # Copy grml to $TARGET # then the big file with nice progress meter @@ -749,9 +775,8 @@ copy_to() else /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET fi - if [ $? -ne 0 ] - then - log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left." + if [ $? -ne 0 ] ; then + log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left." ; echo "$FAILED" sleep 2 return 1 fi @@ -804,7 +829,7 @@ if test -n "$FOUND_GRML" ; then cat /GRML/etc/ld.so.cache > /etc/ld.so.cache UNIONFS="" -if checkbootparam "unionfs" ; then +if checkbootparam "unionfs" || test ! -r /modules/aufs.ko ; then $INSMOD /modules/unionfs.ko 1>/dev/null grep -q unionfs /proc/filesystems && UNIONFS=yes unionfs='unionfs' @@ -873,6 +898,24 @@ MINLEFT=16000 # Default ramdisk size for ramdisk [ -n "$TOTALMEM" ] && RAMSIZE="$(/usr/bin/expr $TOTALMEM / 5)" +# check for available RAM +# check for bootoption small and/or grml-small +if [ -n "$FOUNDMEM" ] ; then + if [ "$GRML_TYPE" = "small" ] ; then + if [ "$FOUNDMEM" -lt 25000 ] ; then + log_begin_msg "Bootoption *small detected, but you need at least 32MB of RAM available." ; echo " $FAILED" + log_begin_msg "Dropping you to a shell, continue on your own risk." ; echo " $FAILED" + /bin/bash + fi + else + if [ "$FOUNDMEM" -lt 58000 ] ; then + log_begin_msg "You need at least 64MB of RAM available for grml." ; echo " $FAILED" + log_begin_msg "Dropping you to a shell, continue on your own risk." ; echo " $FAILED" + /bin/bash + fi + fi +fi + # Create additional dynamic ramdisk. test -z "$RAMSIZE" -o "$RAMSIZE" -lt "$MINSIZE" && RAMSIZE="$MINSIZE" mkdir -p /ramdisk @@ -901,15 +944,13 @@ if test -n "$UNIONFS" && /bin/mount -t $UNIONFS_FILETYPE -o noatime${SECURE},dir fi # We now have unionfs, copy some data from the initial ramdisk first cp -a /etc/fstab /etc/auto.mnt /etc/filesystems /etc/mtab /UNIONFS/etc/ - # disable resolvconf on the terminalserver client if [ -n "$NFS" ] ; then rm /UNIONFS/etc/resolv.conf cp -a /etc/resolv.conf /UNIONFS/etc echo REPORT_ABSENT_SYMLINK=no >> /UNIONFS/etc/default/resolvconf fi - - for i in bin boot etc sbin var lib opt root usr; do # Move directories to unionfs + for i in bin boot etc sbin var opt root usr $EMUL $LIB64 lib ; do # Move directories to unionfs if test -d /$i; then /bin/mv /$i /$i.old && \ # /GRML/lib/ld-linux.so.2 --library-path /GRML/lib /GRML/bin/ln -snf /UNIONFS/$i /$i && \ @@ -927,12 +968,9 @@ if test -n "$UNIONFS" && /bin/mount -t $UNIONFS_FILETYPE -o noatime${SECURE},dir done && echo " $SUCCESS" || echo " $FAILED" else echo "" - log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!" - echo "$FAILED" - sleep 2 - echo "Can not continue booting, dropping you to a busybox shell." - stage=4 - rundebugshell + log_failure_msg "ERROR: CANNOT UNITE READ-ONLY MEDIA AND INITIAL RAMDISK!" ; echo "$FAILED" + log_failure_msg "Can not continue booting, dropping you to a shell." ; echo "$FAILED" + /bin/bash fi chown grml.grml /home/grml