Code: Select all
sudo apt install smartmontools
sudo smartctl -t short -a /dev/sda
sudo smartctl -a /dev/sda
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
Code: Select all
df -h
Code: Select all
sudo dd status=progress if=<path-to-iso> of=/dev/<device>
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
Code: Select all
swapoff -a
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
Code: Select all
usermod -aG sudo <username>
1.3) Ensure you have "noatime" for each partition in /etc/fstab (https://serverfault.com/questions/19969 ... filesystem)
Code: Select all
vi /etc/fstab
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
Code: Select all
sudo apt install fonts-liberation mc
You want to download and install monospace fonts for software engineering, like "ubuntu mono", "DejaVuLGCSansMono", "DroidFamily", "Inconsolata", "ProggyLcean", "monof55". All of them are available online for free.
6. Nvidia drivers
Follow the Debian wiki page to check if your Nvidia card is supported by the proprietary drivers. Assuming that you sport the latest RTX capable of running CUDA workload,
Code: Select all
sudo apt install build-essential
sudo vi /etc/apt/sources.list
deb http://deb.debian.org/debian/ bookworm main non-free-firmware contrib non-free
Code: Select all
sudo apt install linux-headers-$(uname -r)
sudo apt update
Code: Select all
sudo apt install nvidia-driver
Code: Select all
sudo vi /etc/modprobe.d/nvidia-options.conf
Enable NVidia suspend/resume services:#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
Code: Select all
sudo systemctl status nvidia-suspend.service
# Run if the first command indicates these services are disabled.
sudo systemctl enable nvidia-suspend.service
sudo systemctl enable nvidia-hibernate.service
sudo systemctl enable 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
Code: Select all
sudo shutdown -r now
Verify that the proprietary driver is now active:
Code: Select all
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
Code: Select all
vi ~/.screenrc
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, etcshell "/usr/bin/bash"
termcapinfo xterm* ti@:te@
10. Install Node.js
Start by installing the nodejs package:
Code: Select all
sudo apt install nodejs npm
Code: Select all
sudo chown -R user /usr/local
mkdir /usr/local/n; sudo chown user /usr/local/n
npm install -g n
n lts
Code: Select all
sudo apt purge nodejs
sudo apt autoremove
npm install -g pnpm
11. Attaching another encrypted disk
Code: Select all
sudo apt install smartmontools
sudo smartctl -t short -a /dev/sda
sudo smartctl -a /dev/sda
Check the speed, compare against the promised throughput:
Code: Select all
sudo hdparm -tT /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
Code: Select all
# 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
# You can't edit files with the encryption key with "vi" because it'll auto-append new lines.
# You must enable mc's built-in editor in the option, then press SHIFT-F4 to create a file. E.g. create and edit the file /etc/keys/crucial_key.key
sudo mc
# Once the file is created, save it, and open the viewer, where you can switch to hexidecimal representation to ensure that the file contain exactly all characters of your key and nothing else.
# Ensure no trailing whitespaces or newlines.
sudo chmod 400 /etc/keys/crucial_key.key
# Attach the decrypted disk automatically during startup
sudo vi /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 vi /etc/fstab
# /dev/mapper/enc_sdc /storage ext4 noatime,defaults 0 2
systemctl daemon-reload
sudo mount /storage
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
Code: Select all
sysctl vm.max_map_count
sudo vi /etc/sysctl.conf
And that, ladies and gentlemen, is exactly how you install Debian with an Nvidia card in October 2024.vm.max_map_count=1048576