This guide will show you how to compile and install the legacy Nvidia driver on Debian. The steps bellow are compatible with both nvidia-legacy-340xx-driver
and nvidia-legacy-390xx-driver
and can be installed on Debian 13 (Trixie)
as well as Debian 12 (Bookworm)
or Debian 11 (Bullseye)
in both 64-bit
and 32-bit
version. Execute the lines one by one and wait for every line to finish before proceeding to next. Only the lines starting with sudo
should be executed as root
. The lines with sudo pbuilder
will take a lot of time.
To install the nvidia-legacy-390xx-driver
version replace 340xx
with 390xx
everywhere bellow.
To install both 64-bit
and 32-bit
libraries for wine
/steam
you should run Step 2.
twice.
Update, upgrade and install the required packages.
If you use 32-bit
system do not install linux-headers-amd64
.
If you plan on using both 64-bit
and 32-bit
libraries check if your mirror list
support both amd64
and i386
. If not select one which does before you install pbuilder
.
sudo apt update
sudo apt upgrade
sudo apt install pbuilder linux-headers-amd64
Edit your /etc/apt/sources.list
by adding contrib
to the end of every line which starts with deb
(if it's not already there).
Add this line too.
deb-src http://httpredir.debian.org/debian unstable main non-free contrib
Download the source code from Debian Sid
.
sudo apt update
mkdir "$HOME/nvidia-340xx" "$HOME/nvidia-settings"
cd "$HOME/nvidia-340xx"
apt source --download-only nvidia-legacy-340xx-driver
cd "$HOME/nvidia-settings"
apt source --download-only nvidia-settings-legacy-340xx
Edit /etc/apt/sources.list
and remove this line.
deb-src http://httpredir.debian.org/debian unstable main non-free contrib
To compile the 64-bit
version replace ????
with amd64
.
To compile the 32-bit
version replace ????
with i386
.
In case you want both amd64
and i386
libraries on a 64-bit
system run Step 2.
twice.
sudo apt update
sudo pbuilder create --distribution trixie --architecture ????
cd "$HOME/nvidia-340xx"
sudo pbuilder build nvidia-graphics-drivers-legacy-340xx_340.108-25.dsc
cd "$HOME/nvidia-settings"
sudo pbuilder build nvidia-settings-legacy-340xx_340.108-7.dsc
Optional: If you no longer need the files created during this process.
sudo rm /var/cache/pbuilder/aptcache/*
sudo rm /var/cache/pbuilder/base.tgz
rm -r "$HOME/nvidia-340xx" "$HOME/nvidia-settings"
Create a local repository for automated install with apt
.
The -m
flag is only required if you want both amd64
and i386
versions.
cd /var/cache/pbuilder/result
sudo sh -c 'dpkg-scanpackages -m . > Packages'
Edit your /etc/apt/sources.list
once more to add this line.
deb [trusted=yes] file:/var/cache/pbuilder/result ./
Optional: Run the next step only if you are on 64-bit
system and want both 64-bit
and 32-bit
libraries.
sudo dpkg --add-architecture i386
Before you proceed make sure that you have matching linux-headers
for every single linux-image
version on your system.
sudo apt update
sudo apt install nvidia-legacy-340xx-driver nvidia-settings-legacy-340xx
Optional: I recommend to create /etc/X11/xorg.conf
file.
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
EndSection
Section "ServerFlags"
Option "IgnoreABI" "1"
EndSection
-> Was this tested?
Yes, it was tested on Debian 13 and Debian 12 with lxde
and bspwm
.
But I won't be surprised if modern desktop environments like GNOME
or KDE Plasma
don't work.
-> Does suspend to RAM work?
Yes, it does.
-> Which display manager works?
I've tested only lxdm
and lightdm
but should work with others as well.
-> Why should I even bother with this when I can just install from Debian Sid
?
The drivers in Sid
are compiled with newer version libraries which are not compatible with your current system. Installing them may look fine at first glance but will also install new incompatible packages and will overwrite some of your existing packages with ones from Sid
. This may result in insatiability or even in unrecoverable system.
-> Is Wayland
supported?
No.
-> My mouse and keyboard work in tty
but not in Xorg
.
Install xserver-xorg-input-all
.
-> Some applications don't start. Especially the GTK4 ones.
GTK4 is not supported by this driver. But there is a workaround. Open a terminal-emulator
and prepend GSK_RENDERER=cairo
before the application's name, like this.
GSK_RENDERER=cairo pavucontrol
GSK_RENDERER=cairo ghb
Do not put GSK_RENDERER=cairo
in /etc/environment
or in any other way as environment variable
. Because this will force almost all GUI programs to run in Cairo fallback renderer
.
-> VDPAU doesn't work in mpv
.
The version of mpv
in the repositories doesn't include the x11 backend
.
It can be added by recompiling mpv
with this rule
enabled -Dgl-x11=enabled
. Then start mpv
like this.
mpv --gpu-context=x11 --hwdec=vdpau
-> I've followed every single step but it doesn't work.
Run these and see if you have matching linux-headers
for every linux-image
.
apt list --installed | grep linux-image
apt list --installed | grep linux-headers
If there are missing ones, install them and go to the next question.
-> I've installed the linux-headers
(after the Nvidia driver) but doesn't work. How to fix it?
Installing the headers after the driver doesn't trigger dkms
. Run this.
sudo apt reinstall nvidia-legacy-340xx-kernel-dkms
-> Still doesn't work.
There might be a problem with /etc/X11/xorg.conf
. Delete this file and try without it.
If doesn't work try to delete everything in /etc/X11/xorg.conf.d/
except 20-nvidia-legacy-340xx.conf
.
Another possible solution is to generate new Xorg configuration with nvidia-xconfig
.
-> How to use the deb822-style format
sources?
If you prefer to use this format append the @macflav snipped to /etc/apt/sources.list.d/debian.sources
.
I haven't tested this method yet.
# added for building nvidia-legacy driver
# deb-src http://httpredir.debian.org/debian unstable main non-free contrib
Types: deb-src
URIs: http://httpredir.debian.org/debian/
Suites: unstable
Components: main non-free contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
#
# deb [trusted=yes] file:/var/cache/pbuilder/result ./
Types: deb
URIs: file:/var/cache/pbuilder/result/
Suites: trixie
Components: main
Trusted: yes
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Then you have to move all amd64
packages from /var/cache/pbuilder/result
to /var/cache/pbuilder/result/dists/trixie/main/binary-amd64/
.
If you have any i386
they go to /var/cache/pbuilder/result/dists/trixie/main/binary-i386/
.
-> Why pbuilder
complains that either i386
or amd64
packages were not found even though I've updated my mirror list
?
Modifying /etc/apt/sources.list
after the pbuilder
installation doesn't affect pbuilder
. Fix your mirrors then run.
sudo apt purge pbuilder
sudo apt install pbuilder
-> I have Nvidia Optimus what should I do?
I don't have such hardware to test but this has been discussed in my previous guide.
-> In my case apt
didn't automatically install the i386
packages.
Try to install them like this.
The third line is optional.
sudo dpkg --add-architecture i386
sudo apt install nvidia-legacy-340xx-driver-libs-i386
sudo apt install libnvidia-legacy-340xx-cuda1-i386
-> Should I keep the source?
Yes, you will have to recompile the driver once in a while.
Some day the Debian team will deprecate these drivers and delete the source from the servers.
Then you will have hard time finding the source elsewhere.
-> How often should I recompile the driver?
I don't know the exact answer but I have few assumptions.
Every time any of the dependencies is updated.
Every time GCC is updated.
If the driver stops working.
If dkms fails.
Before you start recompiling you can run these just in case.
sudo rm /var/cache/pbuilder/base.tgz
sudo rm /var/cache/pbuilder/result/*
-> Can I somehow make pbuilder
faster?
Yes, if you use HDD and you have at least 8GB RAM you can significantly speed the process up.
If you use SSD there won't be much difference.
I can't find this method documented so I'm not sure if I can recommended it or not.
sudo mount -t tmpfs -o size=4G tmpfs /var/cache/pbuilder/build
When you finish using pbuilder
run.
Everything in /var/cache/pbuilder/build
will be instantly deleted after this command.
sudo umount /var/cache/pbuilder/build
-> Wine/Steam doesn't work. Failed to load libGL: libGL.so.1:... No such file or directory...
Read the very first comment in the comments section below.
-> I see RIP warnings in the kernel log.
I was able to remove them (except one), by the following...
The nvidia-340xx
source doesn't include this patch, while nvidia-390xx
does.
--- a/nv-drm.c
+++ b/nv-drm.c
@@ -168,6 +168,9 @@
.poll = drm_poll,
.read = drm_read,
.llseek = noop_llseek,
+#if defined(FOP_UNSIGNED_OFFSET)
+ .fop_flags = FOP_UNSIGNED_OFFSET,
+#endif
};
static struct drm_driver nv_drm_driver = {
The easiest way to install it is to apply the patch directly to /usr/src/nvidia-legacy-340xx-340.108/nv-drm.c
then run.
sudo apt reinstall nvidia-legacy-340xx-kernel-dkms
Uninstalling these, since I don't use them, removed the rest RIP warnings.
libnvidia-legacy-340xx-cuda1
libnvidia-legacy-340xx-nvcuvid1
libnvidia-legacy-340xx-encode1
-> I have other video drivers should I keep them?
These are not necessary.
Purging xserver-xorg
will also delete /etc/X11/xorg.conf
. Recreate it if necessary.
xserver-xorg
xserver-xorg-video-all
xserver-xorg-video-amdgpu
xserver-xorg-video-ati
xserver-xorg-video-dummy
xserver-xorg-video-fbdev
xserver-xorg-video-nouveau
xserver-xorg-video-vesa
xserver-xorg-video-vmware
-> My question is not listed here.
I've made an earlier version of this guide here where a lot has been discussed. You might find something useful reading there.
Replace lxdm
with your display manager
.
systemctl status lxdm.service
cat /var/log/Xorg.0.log
journalctl
dmesg
lsmod | grep nouveau
lsmod | grep nvidia
modprobe -r nouveau
modprobe nvidia
nvidia-settings
nvidia-xconfig
nvidia-smi
vdpauinfo
glxgears
glxinfo
lspci
Fresh install from debian-13.0.0-amd64-netinst.iso on asus-k70io laptop.

Unable to satisfy dependencies issue : see attached file.
Thanks in advance for help.
Regards, Pierre