Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save oprizal/998635a2ff5cbecb0519455c12b2994f to your computer and use it in GitHub Desktop.
Save oprizal/998635a2ff5cbecb0519455c12b2994f to your computer and use it in GitHub Desktop.
Install Nvidia legacy driver 340xx on Debian 11 Bullseye

How to Install Nvidia Legacy 340xx Driver on Debian 11 Bullseye

DE/WM: Xfce4 & i3

First of all, always update the system first.

$ sudo apt update && sudo apt upgrade

Then adding Debian SID repository since there are no available Nvidia 340xx legacy driver available on Debian 11---or at least it's not available if we read the Debian documentation here: Debian Nvidia Documentation.

There we can see that on Bullseye and Bookworm the only available are version 390xx and 460xx for Bullseye then 390xx and 470xx for Bookworm.

But bare in mind, it's not stable. But on my system with GeForce 310M it's working fine.

WARNING: It's important to run sudo apt update above BEFORE adding Debian SID repositories. You don't want to mix your current installed system Bullseye version with SID version. All we need only access to Nvidia legacy 340xx driver that's not available on Bullseye repositories.

Create a *.list file on /etc/apt/sources.list.d/. Then edit it and add Debian SID repositories address.

$ sudo touch /etc/apt/sources.list.d/sid-repositories.list
$ sudo nano /etc/apt/sources.list.d/sid-repositories.list

Below are Debian SID repositories address.

# Insert this line to /etc/apt/sources.list.d/sid-repositories.list
# we created above.
# Debian Sid.
deb http://deb.debian.org/debian/ sid main contrib non-free

After that install the Nvidia proprietary driver and let it finished.

$ sudo apt update && sudo apt install nvidia-legacy-340xx-driver firmware-misc-nonfree

You'll get a message prompt mentioning about conflict with nouveau driver, but this is ok. Read carefully. This message prompt only remainder to reboot your system after installation has finished.

After installation finished, then reboot your system.

$ systemctl reboot

When you successfully reboot and login to the system, you should remove the file---we created above---which have Debian SID address to prevent mixing the system version.

There should be no more update with Nvidia 340xx driver since it's no more development to this driver version---as long as I remember. That's why it must be safe to not using Debian SID repositories address again in the future.

$ sudo rm /etc/apt/sources.list.d/sid-repositories.list

Check if your driver successfully installed.

$ lsmod | grep -i nvidia

You should get drm mentioning nvidia.

Once more, it doesn't work with wayland.

@dcazabat
Copy link

Many, thank you very much

@shadowruge
Copy link

Ótimo parabéns

@sktedro
Copy link

sktedro commented Nov 24, 2022

Tried exactly following the process two times, but it broke my debian both times (on startup, it said something like "System is broken, contact administrator"). Easy fix was going to the recovery mode and uninstalling. Just saying, be careful

@katrat
Copy link

katrat commented Jan 16, 2023

I have to correct myself: latest driver (340.108-17) now also works. It seems that xfce4 was causing the random black screens and also being responsible for crashes after suspend/hibernate. Switching to lxqt solved it (Compaq 8510w with G84GLM / Quadro FX 570M).

thanks for bringing me on the right track, didn't work for me on the first try (black screen after reboot). I also followed
https://forums.debian.net/viewtopic.php?t=151155
and now works! I am now using nvidia-legacy-340xx-*_340.108-11_amd64.deb

@lnicolao
Copy link

lnicolao commented Mar 8, 2023

Beware of this method. This will pull the drivers from sid, which will write to 6.1 kernel modules, not the current 5.10 on Bullseye.

@katrat
Copy link

katrat commented Mar 9, 2023

Beware of this method. This will pull the drivers from sid, which will write to 6.1 kernel modules, not the current 5.10 on Bullseye.

Exactly. Don't do an "apt upgrade" while the sid repositories are enabled. If you follow the instructions exactly you end up with kernel 5.10 and the nvidia legacy drivers from sid. Haven't had problems since my last installation (apart from running on "ancient" hardware).

@lenainjaune
Copy link

lenainjaune commented Mar 24, 2023

Hi,

With a nVidia GeForce 8400GS 256MB DDR2 GPU as the nouveau driver did not working correctly in my case (suspend to RAM S3 did not working) I tested this workaround without success.

I did not dug further but I remember at boot there was some extra lines displayed from the console but startx does not launched anymore.

Note : to revert I had just to re-enable the Debian SID repo and applyied apt remove nvidia-legacy-340xx-driver firmware-misc-nonfree, disabled the SID repo, apt update, reboot and delete the remaining nVidia packages with apt autoremove nvidia* --purge and finally reboot

For your information, I managed to make nouveau allows the S3 in disabling the init_on_alloc kernel parameter (source) :

root@host:~# grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet init_on_alloc=0"

Note : this parameter enable heap memory zeroing on allocation by default (more here)

In my case the nouveau driver is working perfectly and I can use the suspend to RAM functionnality.

@edsonmarcks
Copy link

Comigo funcionou da seguinte maneira, após instalar o nvidia-legacy-340xx-driver como descrito acima, o sistema (Debian 11) não iniciava, emitia o erro: systemd-module.service failed, a falha foi contornada primeiro adicionado os parâmetros na inicialização:
Como usuário root:
No arquivo /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet nomodeset pcie_port_pm=off nouveau.blacklist=1 nouveau.modeset=0"

Na sequência
grub-mkconfig -o /boot/grub/grub.cfg

depois executei o seguinte comando
update-initramfs -u -k (versão do kernel)

reiniciei e nvidia funcionando com o driver legado!

@JuscelinoCarvalho
Copy link

You were the best!!! Thank you!! It works perfectly.

@gustavoomelo
Copy link

WOWWW, thanks i spend crazy.

@maiconjs
Copy link

Before deleting the "sid-repositories.list" file, it is useful to install nvidia-smi:

sudo apt install nvidia-legacy-340xx-smi

Once installed, using nvidia-smi will display details of GPU operation

@abzrg
Copy link

abzrg commented Nov 29, 2023

thanks man!

I confirm (in my case) this worked on bookworm as well.

@vansnyder
Copy link

I followed the instructions but "apt install nvidia-legacy-340xx-driver" replied "Unable to locate package nvidia-legacy-340xx-driver". It also complained that "firmware-misc-nonfree is not available". I didn't include the comments in the sid-repositories.list file. Are they necessary?

@fr33m0nk
Copy link

I followed the instructions but "apt install nvidia-legacy-340xx-driver" replied "Unable to locate package nvidia-legacy-340xx-driver". It also complained that "firmware-misc-nonfree is not available". I didn't include the comments in the sid-repositories.list file. Are they necessary?

The comments aren't necessary.
You may have missed executing sudo apt-get update after adding the sid repositories.

@NikolayKuraga
Copy link

Боже правый!
Worked for Devuan 5 (daedalus), runit, Linux 6.1.0-17-amd64:

  1. Commented sources in /etc/apt/sources.list, then added there this line:
    deb http://deb.devuan.org/merged ceres main contrib non-free non-free-firmware
  2. sudo apt update && sudo apt install nvidia-legacy-340xx-driver firmware-misc-nonfree
  3. Uncommented sources in /etc/apt/sources.list, removed added previously line
  4. sudo reboot

Thank you very much!

@Anakiev2
Copy link

Anakiev2 commented Apr 16, 2024

This method will mix your stable packages with packages from unstable.
Try this method instead it won't mix your packages. It's for Debian 12 but will probably work on Debian 11 too:
https://gist.github.com/Anakiev2/b828ed2972c04359d52a44e9e5cf2c63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment