From 3181df215dd7cd9d9fd3955c7443859878bacd03 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sat, 6 Feb 2016 21:45:21 +0100 Subject: liveinit: use MARKER instead of INITRD as prefix for message display at boot. --- liveinit | 66 ++++++++++++++++++++++++++------------------------ make_slackware_live.sh | 37 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 31 deletions(-) diff --git a/liveinit b/liveinit index 69783b8..8b10fdc 100755 --- a/liveinit +++ b/liveinit @@ -37,6 +37,7 @@ MEDIALABEL="@MEDIALABEL@" LIVEMAIN="@LIVEMAIN@" +MARKER="@MARKER@" PERSISTENCE="@PERSISTENCE@" LIVEMEDIA="" @@ -174,11 +175,11 @@ fi if [ ! -d /lib/modules/$(uname -r) ]; then echo "No kernel modules found for Linux $(uname -r)." elif [ -x ./load_kernel_modules ]; then # use load_kernel_modules script: - echo "${INITRD}: Loading kernel modules from initrd image:" + echo "${MARKER}: Loading kernel modules from initrd image:" . ./load_kernel_modules 1>/dev/null 2>/dev/null else # load modules (if any) in order: if ls /lib/modules/$(uname -r)/*.*o 1> /dev/null 2> /dev/null ; then - echo "${INITRD}: Loading kernel modules from initrd image:" + echo "${MARKER}: Loading kernel modules from initrd image:" for module in /lib/modules/$(uname -r)/*.*o ; do /sbin/modprobe $module 1>/dev/null 2>/dev/null done @@ -194,7 +195,7 @@ blkid 1>/dev/null 2>/dev/null # Load a custom keyboard mapping: if [ -n "$KEYMAP" ]; then - echo "${INITRD}: Loading '$KEYMAP' keyboard mapping:" + echo "${MARKER}: Loading '$KEYMAP' keyboard mapping:" tar xzOf /etc/keymaps.tar.gz ${KEYMAP}.bmap | loadkmap fi @@ -347,16 +348,16 @@ if [ "$RESCUE" = "" ]; then # Finished determining the media availability, it should be mounted now. if [ ! -z "$LIVEMEDIA" ]; then - echo "${INITRD}: Live media found at ${LIVEMEDIA}." + echo "${MARKER}: Live media found at ${LIVEMEDIA}." if [ ! -d /mnt/media/${LIVEMAIN} ]; then - echo "${INITRD}: However, live media was not mounted... trouble ahead." + echo "${MARKER}: However, live media was not mounted... trouble ahead." fi if [ "$LIVEMEDIA" != "$LIVEALL" ]; then - echo "${INITRD}: NOTE: Multiple partitions with '$MEDIALABEL' label were found ($(echo $LIVEALL))... success not guaranteed." + echo "${MARKER}: NOTE: Multiple partitions with '$MEDIALABEL' label were found ($(echo $LIVEALL))... success not guaranteed." fi else - echo "${INITRD}: No live media found... trouble ahead." - echo "${INITRD}: Try adding \"rootdelay=20\" to the boot command." + echo "${MARKER}: No live media found... trouble ahead." + echo "${MARKER}: Try adding \"rootdelay=20\" to the boot command." fi debugit @@ -368,7 +369,7 @@ if [ "$RESCUE" = "" ]; then mkdir /mnt/live/modules if [ $TORAM -ne 0 ]; then - echo "${INITRD}: Copying Live modules to RAM, please be patient." + echo "${MARKER}: Copying Live modules to RAM, please be patient." fi # Modules were created in specific order and will be mounted in that order. @@ -393,7 +394,7 @@ if [ "$RESCUE" = "" ]; then RODIRS=$(echo $RODIRS |cut -c2-) if [ $TORAM -ne 0 ]; then - echo "${INITRD}: Live OS copied to RAM, you can remove the Live medium." + echo "${MARKER}: Live OS copied to RAM, you can remove the Live medium." if [ "LIVEFS" = "iso9660" ]; then eject ${LIVEMEDIA} fi @@ -415,7 +416,7 @@ if [ "$RESCUE" = "" ]; then # Try a write... just to be dead sure: if touch /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null && rm /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null ; then # Writable media and we are allowed to write to it. - echo "${INITRD}: Writing persistent changes to media directory '/${PERSISTENCE}'." + echo "${MARKER}: Writing persistent changes to media directory '/${PERSISTENCE}'." UPPERDIR=/mnt/media/${PERSISTENCE} OVLWORK=/mnt/media/.ovlwork fi @@ -430,18 +431,21 @@ if [ "$RESCUE" = "" ]; then prfs=$(blkid $prdev |rev |cut -d'"' -f2 |rev) mount -t $prfs $prdev /mnt/live/${prdir} if [ $? -ne 0 ]; then - echo "${INITRD}: Failed to mount persistence file '/${PERSISTENCE}.img'." - echo "${INITRD}: Falling back to RAM." + echo "${MARKER}: Failed to mount persistence file '/${PERSISTENCE}.img'." + echo "${MARKER}: Falling back to RAM." else - echo "${INITRD}: Writing persistent changes to file '/${PERSISTENCE}.img'." + echo "${MARKER}: Writing persistent changes to file '/${PERSISTENCE}.img'." UPPERDIR=/mnt/live/${prdir}/${PERSISTENCE} OVLWORK=/mnt/live/${prdir}/.ovlwork fi fi - elif [ ! -z "$LUKSVOL" ]; then - # Even without persistence, we need to be able to write to the partition - # if we are using a LUKS container file: - mount -o remount,rw /mnt/media + else + echo "${MARKER}: Writing changes to RAM - no persistence:" + if [ ! -z "$LUKSVOL" ]; then + # Even without persistence, we need to be able to write to the partition + # if we are using a LUKS container file: + mount -o remount,rw /mnt/media + fi fi # Create the writable upper directory, plus the workdir which is required @@ -454,7 +458,7 @@ if [ "$RESCUE" = "" ]; then mount -t overlay -o workdir=${OVLWORK},upperdir=${UPPERDIR},lowerdir=${RODIRS} overlay /mnt/overlay if [ $? -ne 0 -a "$VIRGIN" = "0" ]; then # Failed to create the persistent overlay - try without persistence: - echo "${INITRD}: Failed to create persistent overlay, attempting to continue in RAM." + echo "${MARKER}: Failed to create persistent overlay, attempting to continue in RAM." UPPERDIR=/mnt/live/changes OVLWORK=/mnt/live/.ovlwork mkdir -p ${UPPERDIR} @@ -475,14 +479,14 @@ if [ "$RESCUE" = "" ]; then if [ ! -z "$USE_SWAP" ]; then # Use any available swap device: for SWAPD in $(blkid |grep TYPE="\"swap\"" |cut -d: -f1) ; do - echo "${INITRD}: Enabling swapping to '$SWAPD'" + echo "${MARKER}: Enabling swapping to '$SWAPD'" echo "$SWAPD swap swap defaults 0 0" >> /mnt/overlay/etc/fstab done fi if [ ! -z "$KEYMAP" ]; then # Configure custom keyboard mapping in console and X: - echo "${INITRD}: Switching live console to '$KEYMAP' keyboard" + echo "${MARKER}: Switching live console to '$KEYMAP' keyboard" cat < /mnt/overlay/etc/rc.d/rc.keymap #!/bin/sh # Load the keyboard map. More maps are in /usr/share/kbd/keymaps. @@ -510,12 +514,12 @@ EOT else XKBLAYOUT="us" fi - echo "${INITRD}: Switching live X desktop to '$XKBLAYOUT' keyboard" + echo "${MARKER}: Switching live X desktop to '$XKBLAYOUT' keyboard" # If the layout is not 'us' then add 'us' as a secondary nevertheless: if [ "$XKBLAYOUT" != "us" ]; then XKBLAYOUT="$XKBLAYOUT,us" XKBVARIANT="$XKBVARIANT," - XKBOPTIONS="grp:alt_shift_toggle,$XKBOPTIONS" + XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll,$XKBOPTIONS" fi mkdir -p /mnt/overlay/etc/X11/xorg.conf.d cat < /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf @@ -531,13 +535,13 @@ EOT if [ ! -z "$LOCALE" ]; then # Configure custom locale: - echo "${INITRD}: Switching to '$LOCALE' locale" + echo "${MARKER}: Switching to '$LOCALE' locale" sed -i -e "s/^ *export LANG=.*/export LANG=${LOCALE}/" /mnt/overlay/etc/profile.d/lang.sh fi if [ ! -z "$TZ" -a -f /mnt/overlay/usr/share/zoneinfo/${TZ} ]; then # Configure custom timezone: - echo "${INITRD}: Configuring timezone '$TZ'" + echo "${MARKER}: Configuring timezone '$TZ'" cp /mnt/overlay/usr/share/zoneinfo/${TZ} /mnt/overlay/etc/localtime cp /mnt/overlay/usr/share/zoneinfo/${TZ} /mnt/overlay/etc/localtime rm /mnt/overlay/etc/localtime-copied-from @@ -554,7 +558,7 @@ EOT if [ ! -z "$LIVEPW" ]; then # User entered a custom live password on the boot commandline: - echo "${INITRD}: Changing password for user 'live'." + echo "${MARKER}: Changing password for user 'live'." chroot /mnt/overlay /usr/sbin/chpasswd < /mnt/overlay/etc/HOSTNAME if [ -f /mnt/overlay/etc/NetworkManager/NetworkManager.conf ]; then sed -i -e "s/^hostname=.*/hostname=${LIVE_HOSTNAME}/" \ @@ -612,7 +616,7 @@ EOPW echo "Unlocking LUKS encrypted container '$luksfil' at mount point '$luksmnt'" cryptsetup luksOpen $lodev $luksnam /dev/tty0 2>&1 if [ $? -ne 0 ]; then - echo "${INITRD}: Failed to unlock LUKS container '$luksfil'... trouble ahead." + echo "${MARKER}: Failed to unlock LUKS container '$luksfil'... trouble ahead." else # Create the mount directory if it does not exist (unlikely): mkdir -p /mnt/overlay/$luksmnt @@ -673,7 +677,7 @@ umount /run # We disable the filesystem checking code in /etc/rc.d/rc.S, # so we need to keep the fs writable here. #mount -o ro,remount /mnt/overlay 2>/dev/null -echo "${INITRD}: Slackware Live system is ready." +echo "${MARKER}: Slackware Live system is ready." -echo "${INITRD}: exiting" +echo "${MARKER}: exiting" exec switch_root /mnt/overlay $INIT $RUNLEVEL diff --git a/make_slackware_live.sh b/make_slackware_live.sh index 9defa17..f9ee680 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -1289,6 +1289,7 @@ sed -e "s% /sbin/depmod -%#&%" -i ${LIVE_ROOTDIR}/etc/rc.d/rc.modules # If we detect a NVIDIA driver, then run the nvidia install routine: cat <> ${LIVE_ROOTDIR}/etc/rc.d/rc.local +# Deal with the presence of NVIDIA drivers: if [ -x /usr/sbin/nvidia-switch ]; then if [ -f /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so.*-nvidia -a -f /usr/lib${DIRSUFFIX}/xorg/modules/drivers/nvidia_drv.so ]; then # The nvidia kernel module needs to ne announced to the kernel. @@ -1297,8 +1298,43 @@ if [ -x /usr/sbin/nvidia-switch ]; then echo "-- Installing binary Nvidia drivers: /usr/sbin/nvidia-switch --install" /usr/sbin/nvidia-switch --install fi + # For CUDA/OpenCL to work after reboot, create missing nvidia device nodes: + /usr/bin/nvidia-modprobe -c 0 -u +else + # Take care of a sudden reboot when nvidia drivers were activated, + # by restoring the original libraries: + if [ -L /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so -a ! -e $(readlink -f /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so) ]; then + mv /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so{-xorg,} 2>/dev/null + mv /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.la{-xorg,} 2>/dev/null + fi + if [ -L /usr/lib${DIRSUFFIX}/libGL.so -a ! -e $(readlink -f /usr/lib${DIRSUFFIX}/libGL.so) ]; then + LIBGL=$(ls -1 /usr/lib${DIRSUFFIX}/libGL.so.*-xorg |rev |cut -d/ -f1 |cut -d- -f2- |rev) + mv /usr/lib${DIRSUFFIX}/${LIBGL}-xorg /usr/lib${DIRSUFFIX}/${LIBGL} 2>/dev/null + ln -sf ${LIBGL} /usr/lib${DIRSUFFIX}/libGL.so.1 2>/dev/null + ln -sf ${LIBGL} /usr/lib${DIRSUFFIX}/libGL.so 2>/dev/null + mv /usr/lib${DIRSUFFIX}/libGL.la-xorg /usr/lib${DIRSUFFIX}/libGL.la 2>/dev/null + fi + if [ -L /usr/lib${DIRSUFFIX}/libEGL.so -a ! -e $(readlink -f /usr/lib${DIRSUFFIX}/libEGL.so) ]; then + LIBEGL=$(ls -1 /usr/lib${DIRSUFFIX}/libEGL.so.*-xorg |rev |cut -d/ -f1 |cut -d- -f2- |rev) + mv /usr/lib${DIRSUFFIX}/${LIBEGL}-xorg /usr/lib${DIRSUFFIX}/${LIBEGL} 2>/dev/null + ln -sf ${LIBEGL} /usr/lib${DIRSUFFIX}/libEGL.so.1 2>/dev/null + ln -sf ${LIBEGL} /usr/lib${DIRSUFFIX}/libEGL.so 2>/dev/null + fi +fi +EOT + +# If we detect a NVIDIA driver, we run nvidia un-install on shutdown: +cat <> ${LIVE_ROOTDIR}/etc/rc.d/rc.local_shutdown + +if [ -x /usr/sbin/nvidia-switch ]; then + if [ -f /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so-xorg -a -f /usr/lib${DIRSUFFIX}/xorg/modules/drivers/nvidia_drv.so ]; then + # At shutdown, revert to the non-nvidia default: + echo "-- Removing binary Nvidia drivers: /usr/sbin/nvidia-switch --remove" + /usr/sbin/nvidia-switch --remove + fi fi EOT +chmod +x ${LIVE_ROOTDIR}/etc/rc.d/rc.local_shutdown # Clean out the unneeded stuff: # Note: this will fail when a directory is encountered. This failure points @@ -1353,6 +1389,7 @@ chroot ${LIVE_ROOTDIR} /sbin/mkinitrd -c -w ${WAIT} -l us -o /boot/initrd_${KVER # Modify the initrd content for the Live OS: cat $LIVE_TOOLDIR/liveinit | sed \ -e "s/@LIVEMAIN@/$LIVEMAIN/g" \ + -e "s/@MARKER@/$MARKER/g" \ -e "s/@MEDIALABEL@/$MEDIALABEL/g" \ -e "s/@PERSISTENCE@/$PERSISTENCE/g" \ -e "s/@DARKSTAR@/$LIVE_HOSTNAME/g" \ -- cgit v1.2.3