Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 2509

Installation • Complete set of steps for Debian installation with an NVidia card as of October 2024

$
0
0
1. Check the health of your hard-drive
$ sudo apt install smartmontools
$ sudo smartctl -t short -a /dev/sda
$ sudo smartctl -a /dev/sda

Look for the "Wear_Leveling_Count", which starts at 100 (healthy) and decreases toward 0 (dead). If it's well below 100, order a new NVMe or SATA SSD and postpone the installation until the replacement arrives.

2. Download and burn the ISO image from https://www.debian.org/distrib/netinst
# Insert a USB, learn its device, check that its space is sufficient for the image
$ df -h
And write the ISO to USB:
$ sudo dd status=progress if=<path-to-iso> of=/dev/<device>

3. BIOS

1) Disable PCIe power management entirely, to prevent Nvidia drivers from adjusting the voltage and cooling parameters:
Inside "Platform Misc Config", switch off all { PCE Express, PCH, ASPM, L1, ... , PEG-ASPM } -> [Disabled]
If this is not done, the video card might shut down shortly after waking up, rendering the entire system dysfunctional.
2) Enable re-bar 4G access:
1. PCI Subsystem
1. Above 4G -> Enabled
2. Re-Size BAR -> Auto
3. SR-IOV -> Disabled
3) Enable booting from the USB drive.

4. Boot up from USB and install Debian
1) The very first thing you've got to do once the Debian installation commences is press CTRL-ALT-F2 to drop into a text console, press ENTER to log in as an admin, and
$ swapoff -a
If this is not done, the installation will refuse to proceed after specifying a password during the disk encryption setup step.
2) Make sure to encrypt your primary partition. Encrypted LVM is a sensible choice.
3) Do enter the root password during the installation.
4) Pick KDE plasma together with Debian desktop experience.
Now, this one begs some explanation. If you've tried KDE before and concluded that it's a complete clown fiesta with all its animations and inane graphical widgets wasting memory, CPU/GPU resources, and your time, I can assure you that you are absolutely 100% correct. I kid you not; they actually play an animation of a jumping app icon right on your mouse cursor every time you launch an application - it simply can't possibly get any worse. Well, just bear with me on this one: after turning off almost all of its functionality, it'll turn out to be a decent and performant desktop environment, with solid font rendering.
5) Wait for the installation to finish and boot up.

5. First things after booting up Debian for the first time
It loads up with the Nouveau Nvidia drivers, which either freezes or switches off your Nvidia card after suspend/resume. Therefore, the very first thing you need to do is to click Power Management on the system bar, and select "Manually block sleep and screen locking". This buys you some time to set things up.

1) Start with small things first like

1.1) System settings:
Input Devices > Keyboard > Advanced > Caps lock is Ctrl

1.2) Enable sudo for your user account:
# CTRL-ALT-F2, log in under root
$ usermod -aG sudo <username>
# CTRL-ALT-F1 to return back to GUI

1.3) Ensure you have "noatime" for each partition in /etc/fstab (https://serverfault.com/questions/19969 ... filesystem)
$ vi /etc/fstab
add "noatime" to ext4/ext3/ext2 options, e.g. "noatime,errors=remount-ro", "noatime,defaults"

1.4) Animation speed to instant. Replace wallpapers with a solid color of your choosing.

1.5) Desktop Effects: Give in to your reflexes, and when you see anything with the word "animation" in it, nuke it from orbit without thinking twice. If you do it properly, you'll have exactly 4 effects enabled:
1.5.1) "Invert", you can rebind the hotkeys to match the compiz negate plugin.
1.5.2) "Desaturate Unresponsive Applications"
1.5.3) "Dialog Parent"
1.5.4) "Overview", triggered by win-W.

2) Fonts and mc
$ sudo apt install fonts-liberation mc
mc -> appearance -> "modarin256-defbg" -> save setup
You want to download and install "ubuntu mono", "DejaVuLGCSansMono", "DroidFamily", "Inconsolata", "ProggyLcean", "monof55". All of them are available for free.



6. Nvidia drivers
$ sudo vi /etc/apt/sources.list
Append "contrib" and "non-free" to every line, e.g.
deb http://deb.debian.org/debian/ bullseye main contrib non-free
$ sudo apt install linux-headers-$(uname -r)
$ sudo apt update

Install the NVIDIA drivers (do not reboot yet):
$ sudo apt install nvidia-driver

Edit /etc/modprobe.d/nvidia-options.conf to ensure it has the following lines:
$ sudo vim /etc/modprobe.d/nvidia-options.conf
#options nvidia-current NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=44 NVreg_DeviceFileMode=0660
options nvidia-drm fbdev=1
# To grant performance counter access to unprivileged users, uncomment the following line:
options nvidia-current NVreg_RestrictProfilingToAdminUsers=0
# Uncomment to enable this power management feature:
options nvidia-current NVreg_PreserveVideoMemoryAllocations=1
options nvidia NVreg_TemporaryFilePath=/var/tmp
# Uncomment to enable this power management feature:
options nvidia-current NVreg_EnableS0ixPowerManagement=1

Enable NVidia suspend/resume services:
$ sudo systemctl status nvidia-suspend.service
Loaded: loaded (/lib/systemd/system/nvidia-suspend.service; *disabled*; preset: enabled)
Active: inactive (dead)
$ sudo systemctl enable nvidia-suspend.service
Created symlink /etc/systemd/system/systemd-suspend.service.wants/nvidia-suspend.service → /lib/systemd/system/nvidia-suspend.service.
$ sudo systemctl enable nvidia-hibernate.service
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-hibernate.service → /lib/systemd/system/nvidia-hibernate.service.
$ sudo systemctl enable nvidia-resume.service
Created symlink /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.
$ sudo systemctl status nvidia-suspend.service
○ nvidia-suspend.service - NVIDIA system suspend actions
Loaded: loaded (/lib/systemd/system/nvidia-suspend.service; *enabled*; preset: enabled)


Now you can finally reboot your system to load the drivers
$ sudo shutdown -r now

Make sure that you boot into an X11/Plasma session; Wayland will not work with these drivers.

Verify that the proprietary driver is now active:
$ nvidia-smi


7. Set up Firefox extensions
7.1) uBlock Origin, add custom filter to block Google sign in popups:
"accounts.google.com/gsi/*"
7.2) adguard adblocker, flip all its settings on on except for "unlock advanced features"
7.3) Stylus to cut out unwanted divs and styles.

8. Set up ssh screen scrolling
$ vim ~/.screenrc
shell "/usr/bin/bash"
termcapinfo xterm* ti@:te@

9. Set up CUDA drivers and miniconda. Miniconda will corrupt you $PATH in .bashrc file, make sure to edit it to, at the very least, swap the sequence. Setup a miniconda python environment with numpy, XGBoost, Optuna, Pytorch, etc

10. Install Node.js
Start by installing the nodejs package:
$ sudo apt install nodejs npm
Now, you don't have to chown /usr/local, it's a habit I'm still trying to break. However, if running [n <arbitrary version to match the server setup>] is a must, and setting it all up locally has its own downsides, proceed with:
$ sudo chown -R user /usr/local
$ mkdir /usr/local/n; sudo chown user /usr/local/n
$ npm install -g n
$ n lts

Once "n" is installed, it takes over Node.js management, so we can remove the Debian's nodejs packages:
$ sudo apt purge nodejs
$ sudo apt autoremove

$ npm install -g pnpm



11. Attaching another encrypted disk
$ sudo apt install smartmontools
$ sudo smartctl -t short -a /dev/sda
$ sudo smartctl -a /dev/sda

Look at "VALUE" of "Wear_Leveling_Count", it should be 100 or slightly below. Ignore "RAW_VALUE". 0=dead .. 100=healthy

Check the speed, compare against the promised throughput:
$ sudo hdparm -tT /dev/sdb1
E.g. /dev/sdb1:
Timing cached reads: 39114 MB in 2.00 seconds = 19588.95 MB/sec
Timing buffered disk reads: 1466 MB in 3.00 seconds = 488.45 MB/sec


Erase everything
$ sudo wipefs -a /dev/sdc
Optionally wipe all data before starting, to avoid damage from e.g. e2fsck erroneously recognizing former disk records.
This takes forever (5+ hours), make sure it doesn't fall asleep
$ sudo dd status=progress oflag=sync if=/dev/urandom of=/dev/sdc bs=16M

Create LUKS container
$ sudo cryptsetup luksFormat --type luks2 /dev/sdc
Attach the device
$ sudo cryptsetup luksOpen /dev/sdc enc_sdc
Ensure it exists
$ ls /dev/mapper
Check the configured ext4 settings
$ less /etc/mke2fs.conf
$ sudo mke2fs -t ext4 /dev/mapper/enc_sdc
Mount the file system
$ sudo mount /dev/mapper/enc_sdc /storage2

Look up UUID
$ sudo blkid
UUID="15492e6e-890d-44b2-a581-805d1c287376"
$ sudo mkdir /etc/keys
$ sudo mc to create and edit the file /etc/keys/crucial_key.key
Ensure no trailing whitespaces or newlines
$ sudo chmod 400 /etc/keys/crucial_key.key

Attach the decrypted disk automatically during startup
$ sudo vim /etc/crypttab
ENTRY UUID KEY OPTIONS
enc_sdb UUID=15492e6e-890d-44b2-a581-805d1c287376 /etc/keys/crucial_key.key luks,discard
systemctl daemon-reload
systemctl restart cryptsetup.target

$ sudo vim /etc/fstab
/dev/mapper/enc_sdc /storage ext4 noatime,defaults 0 2
$ systemctl daemon-reload
$ sudo mount /storage

12. top
V = # toggle tree view & remove filter
o COMMAND=node # filter out all processes except those including "node"

0 # suppress zeros
t # cpu toggle
m # memory/swap toggle
z # enable color
c # full command line
f # fields: PID %CPU %MEM RES COMMAND TIME
S => off # no cumulative time reporting
W # write-config

13. Check and increase vm.max_map_count 65530 -> 1048576
$ sysctl vm.max_map_count
$ sudo vim /etc/sysctl.conf
vm.max_map_count=1048576

And that, ladies and gentlemen, is exactly how you install Debian with an Nvidia card in October 2024.

Statistics: Posted by Willavu — 2024-10-12 19:10 — Replies 0 — Views 74



Viewing all articles
Browse latest Browse all 2509

Trending Articles