Skip to content

Commit d0160cf

Browse files
author
Kyle Krueger
committed
add nvidia-open driver install option
1 parent e528a31 commit d0160cf

File tree

2 files changed

+74
-17
lines changed

2 files changed

+74
-17
lines changed

ZFS-root.conf.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ XFCE=n
158158
# 390 or 470 for legacy driver
159159
# 550 for current latest, or whatever version you prefer
160160
NVIDIA=none
161+
# If you want Nvidia drivers from their PPA, you can instead specify NVIDIA_OPEN.
162+
# Setting both NVIDIA and NVIDIA open will cause the install to fail.
163+
# See the repository for available versions:
164+
# https://developer.download.nvidia.com/compute/cuda/repos
165+
# Or take the latest open driver by selecting "nvidia-open"
166+
# Please note, older hardware may not be supported in the latest.
167+
#
168+
# NVIDIA_OPEN=nvidia-open
161169

162170
# If installing Sound Open Firmware binaries (mostly for laptops) choose
163171
# the version here. Defaults to 2025.05.1

ZFS-root.sh

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -556,27 +556,54 @@ query_nvidia() {
556556
echo "${FUNCNAME[0]}"
557557
# See if we need to install Nvidia drivers, notify if so
558558
# shellcheck disable=SC2046,SC2086 # Don't need quotes or double-quotes
559-
if [[ ! -v NVIDIA ]] ; then
560-
NVIDIA=none
561-
if [ "${GNOME}" = "y" ] || [ "${KDE}" = "y" ] || [ "${NEON}" = "y" ] || [ "${XFCE}" = "y" ] ; then
562-
if [ $(lspci | grep -ic nvidia) -gt 0 ] ; then
563-
# Installing Nvidia PPA here just so we can search for versions
564-
apt-add-repository --yes --update ppa:graphics-drivers/ppa
565-
NVIDIA_LATEST=$(apt-cache search nvidia-driver- | cut -d ' ' -f1 | grep -e "nvidia-driver-...$" | cut -d'-' -f3 | sort | tail -1)
566-
NVIDIA=$(whiptail --title "Nvidia Hardware detected - install latest driver ?" --radiolist "Gnome/KDE/NEON was selected, and Nvidia graphics HW was detected on this system. The ppa:graphics-drivers/ppa repo could be installed in order to get the binary Nvidia driver\n\nNOTE: Be sure to select the correct driver - the latest (${NVIDIA_LATEST}) may not support older legacy HW. See\n\nhttps://www.nvidia.com/en-us/drivers/unix/legacy-gpu/\n\nfor more information on legacy HW. It is safe to select NONE if you are unsure. You can always install the appropriate driver later via Additional Drivers" 22 70 4 \
567-
${NVIDIA_LATEST} "Latest ${NVIDIA_LATEST}" OFF \
568-
470 "Legacy 470 driver" OFF \
569-
390 "Legacy 390 driver" OFF \
570-
none "No Nvidia driver" ON \
571-
3>&1 1>&2 2>&3)
572-
RET=${?}
573-
[[ ${RET} = 1 ]] && exit 1
574-
fi
559+
if [[ -v NVIDIA || -v NVIDIA_OPEN ]] ; then return 0; fi
560+
561+
NVIDIA=none
562+
if [ "${GNOME}" = "y" ] || [ "${KDE}" = "y" ] || [ "${NEON}" = "y" ] || [ "${XFCE}" = "y" ] ; then
563+
if [ $(lspci | grep -ic nvidia) -gt 0 ] ; then
564+
# Installing Nvidia PPA here just so we can search for versions
565+
apt-add-repository --yes --update ppa:graphics-drivers/ppa
566+
NVIDIA_LATEST=$(apt-cache search nvidia-driver- | cut -d ' ' -f1 | grep -e "nvidia-driver-...$" | cut -d'-' -f3 | sort | tail -1)
567+
NVIDIA=$(whiptail --title "Nvidia Hardware detected - install latest driver ?" --radiolist "Gnome/KDE/NEON was selected, and Nvidia graphics HW was detected on this system. The ppa:graphics-drivers/ppa repo could be installed in order to get the binary Nvidia driver\n\nNOTE: Be sure to select the correct driver - the latest (${NVIDIA_LATEST}) may not support older legacy HW. See\n\nhttps://www.nvidia.com/en-us/drivers/unix/legacy-gpu/\n\nfor more information on legacy HW. It is safe to select NONE if you are unsure. You can always install the appropriate driver later via Additional Drivers" 22 70 4 \
568+
${NVIDIA_LATEST} "Latest ${NVIDIA_LATEST}" OFF \
569+
470 "Legacy 470 driver" OFF \
570+
390 "Legacy 390 driver" OFF \
571+
none "No Nvidia driver" ON \
572+
3>&1 1>&2 2>&3)
573+
RET=${?}
574+
[[ ${RET} = 1 ]] && exit 1
575575
fi
576576
fi
577577
} # query_nvidia()
578578

579579

580+
# -------------------------------------------------------------------------------------------------------
581+
# Possibly offer Nvidia driver install
582+
query_nvidia_open() {
583+
echo "--------------------------------------------------------------------------------"
584+
echo "${FUNCNAME[0]}"
585+
# See if we need to install Nvidia drivers, notify if so
586+
# shellcheck disable=SC2046,SC2086 # Don't need quotes or double-quotes
587+
if [[ -v NVIDIA || -v NVIDIA_OPEN ]] ; then return 0; fi
588+
589+
NVIDIA=none
590+
if [ "${GNOME}" = "y" ] || [ "${KDE}" = "y" ] || [ "${NEON}" = "y" ] || [ "${XFCE}" = "y" ] ; then
591+
if [ $(lspci | grep -ic nvidia) -gt 0 ] ; then
592+
# Installing Nvidia PPA here just so we can search for versions
593+
apt-add-repository --yes --update ppa:graphics-drivers/ppa
594+
NVIDIA_LATEST=$(apt-cache search nvidia-driver- | cut -d ' ' -f1 | grep -e "nvidia-driver-...$" | cut -d'-' -f3 | sort | tail -1)
595+
NVIDIA=$(whiptail --title "Nvidia Hardware detected - install latest driver ?" --radiolist "Gnome/KDE/NEON was selected, and Nvidia graphics HW was detected on this system. The ppa:graphics-drivers/ppa repo could be installed in order to get the binary Nvidia driver\n\nNOTE: Be sure to select the correct driver - the latest (${NVIDIA_LATEST}) may not support older legacy HW. See\n\nhttps://www.nvidia.com/en-us/drivers/unix/legacy-gpu/\n\nfor more information on legacy HW. It is safe to select NONE if you are unsure. You can always install the appropriate driver later via Additional Drivers" 22 70 4 \
596+
${NVIDIA_LATEST} "Latest ${NVIDIA_LATEST}" OFF \
597+
470 "Legacy 470 driver" OFF \
598+
390 "Legacy 390 driver" OFF \
599+
none "No Nvidia driver" ON \
600+
3>&1 1>&2 2>&3)
601+
RET=${?}
602+
[[ ${RET} = 1 ]] && exit 1
603+
fi
604+
fi
605+
} # query_nvidia_open()
606+
580607
# -------------------------------------------------------------------------------------------------------
581608
# Query for Google Authenticator, create secret for install
582609
query_google_auth() {
@@ -866,6 +893,7 @@ show_options() {
866893
KDE = $(echo $KDE) : Install Ubuntu KDE Plasma desktop\n \
867894
NEON = $(echo $NEON) : Install Neon KDE Plasma desktop\n \
868895
NVIDIA = $(echo $NVIDIA) : Install Nvidia drivers\n \
896+
NVIDIA_OPEN= $(echo $NVIDIA_OPEN) : Install Nvidia Open drivers\n \
869897
SOF = $(echo $SOF) : Install Sound Open Firmware ${SOF_VERSION} binaries\n \
870898
HIBERNATE = $(echo $HIBERNATE) : Enable SWAP disk partition for hibernation\n \
871899
DISCENC = $(echo $DISCENC) : Enable disk encryption (No, LUKS, ZFS)\n \
@@ -894,6 +922,7 @@ show_options() {
894922
KDE = $(echo $KDE) : Install Ubuntu KDE Plasma desktop\n \
895923
NEON = $(echo $NEON) : Install Neon KDE Plasma desktop\n \
896924
NVIDIA = $(echo $NVIDIA) : Install Nvidia drivers\n \
925+
NVIDIA_OPEN= $(echo $NVIDIA) : Install Nvidia Open drivers\n \
897926
SOF = $(echo $SOF) : Install Sound Open Firmware ${SOF_VERSION} binaries\n \
898927
DISCENC = $(echo $DISCENC) : Enable disk encryption (No, LUKS, ZFS)\n \
899928
DROPBEAR = $(echo $DROPBEAR) : Enable Dropbear unlocking of encrypted disks\n \
@@ -938,6 +967,7 @@ log_options() {
938967
NEON = ${NEON}
939968
KDE = ${KDE}
940969
NVIDIA = ${NVIDIA}
970+
NVIDIA_OPEN = ${NVIDIA_OPEN}
941971
HIBERNATE = ${HIBERNATE}
942972
SIZE_SWAP = ${SIZE_SWAP}
943973
PARTITION_BOOT = ${PARTITION_BOOT}
@@ -1535,6 +1565,7 @@ prep_setup() {
15351565
export NEON=${NEON}
15361566
export KDE=${KDE}
15371567
export NVIDIA=${NVIDIA}
1568+
export NVIDIA_OPEN=${NVIDIA_OPEN}
15381569
export HIBERNATE=${HIBERNATE}
15391570
export SIZE_SWAP=${SIZE_SWAP}
15401571
export PARTITION_BOOT=${PARTITION_BOOT}
@@ -3181,10 +3212,21 @@ cat >> ${ZFSBUILD}/root/Setup.sh << '__EOF__'
31813212
31823213
# Check for Nvidia graphics - if so, install from the ppa:graphics-drivers/ppa
31833214
# The NVIDIA var should be set to the appropriate version from the menu query
3184-
if [ "${NVIDIA}" != "none" ] ; then
3215+
if [[ -v NVIDIA && -v NVIDIA_OPEN ]] ; then
3216+
echo "Set NVIDIA for Ubuntu PPA or NVIDIA_OPEN for Nvidia PPA" 1>&2
3217+
echo "But not both!" 1>&2
3218+
exit 1;
3219+
fi
3220+
if [ -v NVIDIA ] && [ "${NVIDIA}" != "none" ] ; then
31853221
apt-add-repository --yes --update ppa:graphics-drivers/ppa
31863222
apt-get -qq --yes install nvidia-driver-${NVIDIA} libxnvctrl0
31873223
fi
3224+
if [ -v NVIDIA_OPEN ] && [ "${NVIDIA_OPEN}" != "none" ] ; then
3225+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${SUITE_NUM//.}/x86_64/cuda-keyring_1.1-1_all.deb
3226+
dpkg -i cuda-keyring_1.1-1_all.deb
3227+
apt update
3228+
apt-get -qq --yes install ${NVIDIA_OPEN}
3229+
fi
31883230
31893231
####
31903232
#### Install seems to bork when done under livecd
@@ -3275,6 +3317,7 @@ __EOF__
32753317
## select_encryption() {
32763318
## query_install_options() {
32773319
## query_nvidia() {
3320+
## query_nvidia_open() {
32783321
## query_google_auth() {
32793322
## query_ssh_auth() {
32803323
## query_swap() {
@@ -3329,7 +3372,13 @@ query_install_options
33293372
# zrepl has no release for 25.04/plucky or 25.10/questing yet
33303373
[ "${SUITE}" == "plucky" ] || [ "${SUITE}" == "questing" ] && ZREPL=n
33313374

3375+
if [[ -v NVIDIA && -v NVIDIA_OPEN ]] ; then
3376+
echo "Set NVIDIA for Ubuntu PPA or NVIDIA_OPEN for Nvidia PPA" 1>&2
3377+
echo "But not both!" 1>&2
3378+
exit 1;
3379+
fi
33323380
query_nvidia
3381+
query_nvidia_open
33333382
query_google_auth
33343383
query_ssh_auth
33353384
query_swap

0 commit comments

Comments
 (0)