From 66fbed66d8a37591dee95e815e374f026286c16c Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Thu, 30 Apr 2020 22:26:40 +0200 Subject: Make "load=nvidia" work Using a squashfs module created from nvidia-kernel and nvidia-driver packages. A sample script for creating this nvidia module was added to liveslak, see: ./contrib/scripts/makemod_nvidia. These two packages were created using the scripts from slackbuilds.org: https://slackbuilds.org/repository/14.2/system/nvidia-kernel/ https://slackbuilds.org/repository/14.2/system/nvidia-driver/ Note that the nvidia-driver package was created on a multilib system so that it could pick up 32bit compat libraries (needed for Steam among others), and the CURRENT variable was set to 'yes' so that the nvidia drivers are fully separated from mesa and xorg-server and do not overwrite system libraries: # COMPAT32="yes" CURRENT="yes" ./nvidia-driver.SlackBuild --- make_slackware_live.sh | 68 +++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'make_slackware_live.sh') diff --git a/make_slackware_live.sh b/make_slackware_live.sh index ff2e96d..dce69a6 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -90,6 +90,12 @@ LIVEUIDNR=${LIVEUIDNR:-"1000"} ROOTPW=${ROOTPW:-"root"} LIVEPW=${LIVEPW:-"live"} +# The nvidia persistence account: +NVUID=${NVUID:-"nvidia"} +NVUIDNR=${NVUIDNR:-"365"} +NVGRP=${NVFRP:-"nvidia"} +NVGRPNR=${NVUIDNR:-"365"} + # Distribution name: DISTRO=${DISTRO:-"slackware"} @@ -1442,6 +1448,14 @@ EOL # Set a root password. echo "root:${ROOTPW}" | chroot ${LIVE_ROOTDIR} /usr/sbin/chpasswd +# Create group and user for the nvidia persistence daemon: +if ! chroot ${LIVE_ROOTDIR} /usr/bin/getent passwd ${NVUID} > /dev/null 2>&1 ; +then + chroot ${LIVE_ROOTDIR} /usr/sbin/groupadd -g ${NVGRPNR} ${NVGRP} + chroot ${LIVE_ROOTDIR} /usr/sbin/useradd -c "Nvidia persistence" -u ${NVUIDNR} -g ${NVGRPNR} -d /dev/null -s /bin/false ${NVUID} + echo "${NVUID}:$(openssl rand -base64 12)" | chroot ${LIVE_ROOTDIR} /usr/sbin/chpasswd +fi + # Create a nonprivileged user account (called "live" by default): chroot ${LIVE_ROOTDIR} /usr/sbin/useradd -c "Slackware Live User" -g users -G wheel,audio,cdrom,floppy,plugdev,video,power,netdev,lp,scanner,kmem,dialout,games,disk,input -u ${LIVEUIDNR} -d /home/${LIVEUID} -m -s /bin/bash ${LIVEUID} echo "${LIVEUID}:${LIVEPW}" | chroot ${LIVE_ROOTDIR} /usr/sbin/chpasswd @@ -2397,37 +2411,32 @@ sed -e "s% /usr/bin/update.*verbose%#&%" -i ${LIVE_ROOTDIR}/etc/rc.d/rc.M sed -e '/^ *\/usr\/bin\/glib-c/ s, /usr/bin/glib-c,#&,' -i ${LIVE_ROOTDIR}/etc/rc.d/rc.M 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: +# Start/stop the NVIDIA persistence daemon if a NVIDIA driver is loaded; +# Note that this assumes the nvidia-driver and nvidia-kernel packages +# from slackbuilds.org are being used: 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 - 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: +# For CUDA/OpenCL to work after reboot, create missing nvidia device nodes: +if [ -x /usr/bin/nvidia-modprobe ]; then + echo "Creating missing nvidia device nodes..." /usr/bin/nvidia-modprobe -c 0 -u -else - # Take care of a reboot where nvidia drivers disappeared - # afer being used earlier, by restoring the original libraries: - if ls /usr/lib${DIRSUFFIX}/xorg/modules/extensions/libglx.so-xorg 1>/dev/null 2>/dev/null ; 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 ls /usr/lib${DIRSUFFIX}/libGL.so.*-xorg 1>/dev/null 2>/dev/null ; 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 ls /usr/lib${DIRSUFFIX}/libEGL.so.*-xorg 1>/dev/null 2>/dev/null ; 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 + +# Start the nvidia-persistenced daemon: +if [ -x /etc/rc.d/rc.nvidia-persistenced ] && [ -d /var/run/nvidia-persistenced ]; then + echo "Starting nvidia persistence daemon..." + sed -e "s/NVPD_USER=.*/NVPD_USER=${NVUID}/" -i /etc/rc.d/rc.nvidia-persistenced + chown ${NVUID}:${NVGRP} /var/run/nvidia-persistenced 2>/dev/null + /etc/rc.d/rc.nvidia-persistenced start +fi +EOT + +cat <> ${LIVE_ROOTDIR}/etc/rc.d/rc.local_shutdown + +# Stop the nvidia-persistenced daemon: +if [ -x /etc/rc.d/rc.nvidia-persistenced ]; then + echo "Stopping nvidia persistence daemon..." + /etc/rc.d/rc.nvidia-persistenced stop fi EOT @@ -2701,6 +2710,9 @@ if [ "$LIVEDE" != "XFCE" -a "$LIVEDE" != "SLACKWARE" ]; then # Add custom (proprietary) graphics drivers: echo "-- Adding binary GPU drivers supporting kernel ${KVER}." cp ${LIVE_TOOLDIR}/graphics/*${KVER}-${SL_VERSION}-${SL_ARCH}.sxz ${LIVE_MOD_OPT}/ + if ls ${LIVE_TOOLDIR}/graphics/nvidia-*xx.ids 1>/dev/null 2>&1 ; then + cp ${LIVE_TOOLDIR}/graphics/nvidia-*xx.ids ${LIVE_MOD_OPT}/ + fi fi fi -- cgit v1.2.3