NVidia X11 Config Overwritten on reboot/unlock

Garuda Linux Friends,

I am a fairly new user and loving the distro but I am having an issue that I resorted to a "hacky" workaround to fix and figured someone had a better solution.

My X11 config keeps reverting to an xrandr generated config but I am trying to use nvidia-settings to manage the 4-monitor setup.

Here's what I have tried (garuda-inxi output is at the bottom):

  • setup the X config how I want it in nvidia-settings, applied, confirmed
  • used nvidia-settings -q CurrentMetaMode to dump the current mode, looks right
  • saved the X config from nvidia-settings to a file, copied it as root to /etc/X11/xorg.conf.d/20-nvidia.conf
  • ensured no /etc/X11/xorg.conf is present
  • reboot, back to the wrong thing
  • noticed that nvidia-settings -q CurrentMetaMode source=xrandr, before it was source=nv-control
  • set an alias (below) to quickly apply the settings
  • decided to ask the forum <3

nvidia-settings --assign "CurrentMetaMode=DPY-6: 2560x1440 @2560x1440 +2560+1440 {Vi
ewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-0: nvidia-auto-select @2560x1440 +5120+1440 {ViewPortIn=25
60x1440, ViewPortOut=2560x1440+0+0}, DPY-3: nvidia-auto-select @2560x1440 +0+1440 {ViewPortIn=2560x1440, ViewP
ortOut=2560x1440+0+0}, DPY-5: nvidia-auto-select @2560x1440 +2560+0 {ViewPortIn=2560x1440, ViewPortOut=3840x21
60+0+0}"

(below is in the state that I want after applying the above quick fix)

garuda-inxi
System:
  Kernel: 5.19.6-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=80927eea-06a8-42ce-b5a9-9ffa087078ac rw [email protected]
    quiet
    cryptdevice=UUID=045eb10e-716b-4661-8aa3-7e242f97120c:luks-045eb10e-716b-4661-8aa3-7e242f97120c
    root=/dev/mapper/luks-045eb10e-716b-4661-8aa3-7e242f97120c quiet splash
    rd.udev.log_priority=3 vt.global_cursor_default=0
    resume=/dev/mapper/luks-e3675f64-b489-415b-ab00-39e4b0f0d96c loglevel=3
  Desktop: GNOME v: 42.4 tk: GTK v: 3.24.34 wm: gnome-shell dm: GDM v: 42.0
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required>
  Mobo: ASUSTeK model: ROG CROSSHAIR VIII HERO v: Rev X.0x
    serial: <superuser required> UEFI: American Megatrends v: 3402
    date: 03/22/2021
CPU:
  Info: model: AMD Ryzen 7 5800X bits: 64 type: MT MCP arch: Zen 3 gen: 4
    built: 2021-22 process: TSMC n7 (7nm) family: 0x19 (25) model-id: 0x21 (33)
    stepping: 0 microcode: 0xA201009
  Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled cache:
    L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 4 MiB desc: 8x512 KiB
    L3: 32 MiB desc: 1x32 MiB
  Speed (MHz): avg: 3773 high: 3800 min/max: 2200/4850 boost: enabled
    scaling: driver: acpi-cpufreq governor: performance cores: 1: 3800 2: 3800
    3: 3800 4: 3718 5: 3800 6: 3800 7: 3800 8: 3800 9: 3800 10: 3597 11: 3667
    12: 3800 13: 3800 14: 3800 15: 3800 16: 3800 bogomips: 121591
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: always-on, RSB filling, PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: NVIDIA GA104 [GeForce RTX 3070 Ti] vendor: ASUSTeK driver: nvidia
    v: 515.65.01 alternate: nouveau,nvidia_drm non-free: 515.xx+ status: current
    (as of 2022-07) arch: Ampere code: GAxxx process: TSMC n7 (7nm)
    built: 2020-22 pcie: gen: 4 speed: 16 GT/s lanes: 8 link-max: lanes: 16
    bus-ID: 09:00.0 chip-ID: 10de:2482 class-ID: 0300
  Device-2: NVIDIA GA104 [GeForce RTX 3070] vendor: ASUSTeK driver: nvidia
    v: 515.65.01 alternate: nouveau,nvidia_drm non-free: 515.xx+ status: current
    (as of 2022-07) arch: Ampere code: GAxxx process: TSMC n7 (7nm)
    built: 2020-22 pcie: gen: 1 speed: 2.5 GT/s lanes: 8 link-max: gen: 4
    speed: 16 GT/s lanes: 16 bus-ID: 0a:00.0 chip-ID: 10de:2484
    class-ID: 0300
  Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.3
    compositor: gnome-shell driver: X: loaded: nvidia gpu: nvidia,nvidia
    display-ID: :1 screens: 1
  Screen-1: 0 s-res: 7680x2880 s-dpi: 108 s-size: 1806x683mm (71.10x26.89")
    s-diag: 1931mm (76.02")
  Monitor-1: DP-0 pos: bottom-r res: 2560x1440 hz: 60 dpi: 109
    size: 597x336mm (23.5x13.23") diag: 685mm (26.97") modes: N/A
  Monitor-2: DP-2 pos: bottom-l res: 2560x1440 hz: 60 dpi: 109
    size: 597x336mm (23.5x13.23") diag: 685mm (26.97") modes: N/A
  Monitor-3: DP-4 pos: primary,bottom-c res: 2560x1440 hz: 60 dpi: 105
    size: 621x341mm (24.45x13.43") diag: 708mm (27.89") modes: N/A
  Monitor-4: HDMI-1 pos: top-center res: 2560x1440 hz: 30 dpi: 35
    size: 1872x1053mm (73.7x41.46") diag: 2148mm (84.56") modes: N/A
  OpenGL: renderer: NVIDIA GeForce RTX 3070 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA
    515.65.01 direct render: Yes
Audio:
  Device-1: NVIDIA GA104 High Definition Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel bus-ID: 3-2.2.3:7 pcie: chip-ID: 1532:0527
    class-ID: 0300 gen: 4 speed: 16 GT/s serial: <filter> lanes: 8 link-max:
    lanes: 16 bus-ID: 09:00.1 chip-ID: 10de:228b class-ID: 0403
  Device-2: NVIDIA GA104 High Definition Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 8
    link-max: gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 0a:00.1
    chip-ID: 10de:228b class-ID: 0403
  Device-3: AMD Starship/Matisse HD Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
    bus-ID: 0c:00.4 chip-ID: 1022:1487 class-ID: 0403
  Device-4: Razer USA RZ04-0318 Gaming Headset [Kraken Ultimate] type: USB
    driver: hid-generic,snd-usb-audio,usbhid
  Sound Server-1: ALSA v: k5.19.6-zen1-1-zen running: yes
  Sound Server-2: PulseAudio v: 16.1 running: no
  Sound Server-3: PipeWire v: 0.3.56 running: yes
Network:
  Device-1: Realtek RTL8125 2.5GbE vendor: ASUSTeK driver: r8169 v: kernel
    pcie: gen: 2 speed: 5 GT/s lanes: 1 port: d000 bus-ID: 04:00.0
    chip-ID: 10ec:8125 class-ID: 0200
  IF: enp4s0 state: down mac: <filter>
  Device-2: Intel I211 Gigabit Network vendor: ASUSTeK driver: igb
    v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: c000 bus-ID: 05:00.0
    chip-ID: 8086:1539 class-ID: 0200
  IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  IF-ID-1: docker0 state: down mac: <filter>
  IF-ID-2: vmnet1 state: unknown speed: N/A duplex: N/A mac: <filter>
  IF-ID-3: vmnet8 state: unknown speed: N/A duplex: N/A mac: <filter>
RAID:
  Supported mdraid levels: raid1
  Device-1: md0 maj-min: 9:0 type: mdraid level: mirror status: active
    size: 1.86 TiB
  Info: report: 2/2 UU blocks: 2000265536 chunk-size: N/A super-blocks: 1.2
  Components: Online:
  0: sda1 maj-min: 8:1 size: 1.86 TiB
  1: sdb1 maj-min: 8:17 size: 1.86 TiB
Drives:
  Local Storage: total: raw: 5.55 TiB usable: 3.68 TiB used: 172.21 GiB
    (4.6%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 980 PRO 1TB
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B
    speed: 63.2 Gb/s lanes: 4 type: SSD serial: <filter> rev: 2B2QGXA7
    temp: 39.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860 PRO 2TB
    size: 1.86 TiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 2B6Q scheme: MBR
  ID-3: /dev/sdb maj-min: 8:16 vendor: Samsung model: SSD 860 PRO 2TB
    size: 1.86 TiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 2B6Q scheme: MBR
  ID-4: /dev/sdc maj-min: 8:32 type: USB vendor: ASUS model: ROG ESD-S1C
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B type: N/A
    serial: <filter> scheme: GPT
Partition:
  ID-1: / raw-size: 862.24 GiB size: 862.24 GiB (100.00%) used: 22.82 GiB
    (2.6%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-045eb10e-716b-4661-8aa3-7e242f97120c
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%) used: 752 KiB
    (0.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 862.24 GiB size: 862.24 GiB (100.00%) used: 22.82
    GiB (2.6%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-045eb10e-716b-4661-8aa3-7e242f97120c
  ID-4: /var/log raw-size: 862.24 GiB size: 862.24 GiB (100.00%) used: 22.82
    GiB (2.6%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-045eb10e-716b-4661-8aa3-7e242f97120c
  ID-5: /var/tmp raw-size: 862.24 GiB size: 862.24 GiB (100.00%) used: 22.82
    GiB (2.6%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
    mapped: luks-045eb10e-716b-4661-8aa3-7e242f97120c
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 62.71 GiB used: 0 KiB (0.0%) priority: 100
    dev: /dev/zram0
  ID-2: swap-2 type: partition size: 68.98 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/dm-1 maj-min: 254:1
    mapped: luks-e3675f64-b489-415b-ab00-39e4b0f0d96c
Sensors:
  System Temperatures: cpu: 36.0 C mobo: 34.0 C gpu: nvidia temp: 55 C
  Fan Speeds (RPM): cpu: 0 fan-2: 825 fan-3: 791 fan-5: 1240 fan-6: 1245
    gpu: nvidia fan: 0%
Info:
  Processes: 396 Uptime: 19m wakeups: 0 Memory: 62.71 GiB used: 3.15 GiB
  (5.0%) Init: systemd v: 251 default: graphical tool: systemctl Compilers:
  gcc: 12.2.0 Packages: pacman: 1346 lib: 358 Shell: fish v: 3.5.1
  default: Bash v: 5.1.16 running-in: gnome-terminal inxi: 3.3.20
Garuda (2.6.6-1):
  System install date:     2022-09-02
  Last full system update: 2022-09-02
  Is partially upgraded:   No
  Relevant software:       NetworkManager
  Windows dual boot:       No/Undetected
  Snapshots:               Snapper
  Failed units:            bluetooth-autoconnect.service mdmonitor.service

In general, the user-specific settings are applied last. So although your method for configuring /etc/X11/xorg.conf.d/20-nvidia.conf or /etc/X11/xorg.conf may be correct, if there is a dot file in ~/ somewhere that specifies any of the same settings, the dot file will win.

This is from the nvidia-settings man page:


The NVIDIA X driver does not preserve values set with nvidia-settings between runs of the X server (or even between logging in and logging out of X, with xdm(1), gdm, or kdm ). This is intentional, because different users may have different preferences, thus these settings are stored on a per-user basis in a configuration file stored in the user's home directory.

The configuration file is named ~/.nvidia-settings-rc. You can specify a different configuration file name with the --config command line option.

After you have run nvidia-settings once and have generated a configuration file, you can then run:

nvidia-settings --load-config-only

at any time in the future to upload these settings to the X server again. For example, you might place the above command in your ~/.xinitrc file so that your settings are applied automatically when you log in to X.

Your .xinitrc file, which controls what X applications should be started when you log into X (or startx), might look something like this:

 nvidia-settings --load-config-only &


 xterm &

 evilwm

or:

 nvidia-settings --load-config-only &

 gnome-session

If you do not already have an ~/.xinitrc file, then chances are that xinit(1) is using a system-wide xinitrc file. This system wide file is typically here:

 /etc/X11/xinit/xinitrc

To use it, but also have nvidia-settings upload your settings, you could create an ~/.xinitrc with the contents:

 nvidia-settings --load-config-only &

 . /etc/X11/xinit/xinitrc

System administrators may choose to place the nvidia-settings load command directly in the system xinitrc script.
Please see the xinit(1) man page for further details of configuring your ~/.xinitrc file.


I hope that helps! Welcome to the community @dshawth. :slightly_smiling_face:

3 Likes

I wonder what would that mean exactly... :thinking:
My Magic Crystal Ball :crystal_ball: says you have more than usual computer and/or Linux experience, and is rarely wrong :wink:

Would you mind giving more info on which part of the tutorial you have used you have difficulty understanding, so we help you be a happy Arch/Garuda user? :joy:

As @BluishHumility said already, the usual method to apply monitors layout with nvidia is with a local solution, not system.
Even so, was the custom xorg file deleted on reboot? Why do you say "config overwritten"?

Have you looked at Archwiki, or other documentation site for this task, and what have you got?

If you have your preferred setup with nvidia settings app, you just need to apply this locally, as explained in Archwiki/Nvidia.
Use Gnome Autostart function in Settings to run that script/command.

The .xinitrc is a general example and does not work with DM started sessions.

If it doesn't work like this, post your Xorg log in a web pastebin (like garuda's) and share the link.

3 Likes

Thanks for the replies! I am digging in on both of them. Today one monitor was not working at all and upon swapping the cable, I found at least part of this problem, a DP cable on the fritz. More to follow. @petsam new to Garuda :slight_smile:

1 Like

Having replaced two failed cables now, I am working my way thru the advice. The first thing I noticed was that:

nvidia-settings --load-config-only

has no effect at any point. Looking at the contents of ~/.nvidia-settings-rc it does not contain any of the gemoetry seen in the below output that would be required to get the monitors correct.

Before reboot, after having used the nvidia-settings GUI (as my non-root user to adjust the displays), the command and output look like:

nvidia-settings -q CurrentMetaMode
  Attribute 'CurrentMetaMode' (x20:1.0): id=50, switchable=no, source=nv-control :: DPY-6: 2560x1440
  @2560x1440 +2560+1440 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-2: nvidia-auto-select
  @2560x1440 +0+1440 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-5: nvidia-auto-select @2560x1440
  +2560+0 {ViewPortIn=2560x1440, ViewPortOut=3840x2160+0+0}, DPY-0: nvidia-auto-select @2560x1440 +5120+1440
  {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}

After reboot:

nvidia-settings --load-config-only
nvidia-settings -q CurrentMetaMode
  Attribute 'CurrentMetaMode' (x20:1.0): id=50, switchable=yes, source=RandR :: DPY-6: nvidia-auto-select
  @3840x2160 +2560+0 {ViewPortIn=3840x2160, ViewPortOut=3840x2160+0+0}, DPY-0: nvidia-auto-select @2560x1440
  +0+0 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-2: nvidia-auto-select @2560x1440 +6400+0
  {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-5: nvidia-auto-select @3840x2160 +8960+0
  {ViewPortIn=3840x2160, ViewPortOut=3840x2160+0+0}

Nothing changed and the difference in the config is evident.

My default ~/.xinitrc looks like:

#!/bin/bash
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# Xinitrc.d
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

# Start GNOME session
export XDG_SESSION_TYPE=x11
export GDK_BACKEND=x11
exec gnome-session

Steps related to the .xinitrc file

  • I investigated the xinitrc.d and did not anything that I expected was causing the problem nor did anything in this default script itself stand out to me.
  • I also tried both the possible ways to use nvidia-settings --load-config-only in the .xinitrc with no effect.

I am still resorting to running the below once I log in, which I even tried putting into the above script to no avail.

nvidia-settings --assign CurrentMetaMode="DPY-6: 2560x1440 @2560x1440 +2560+1440 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-2: nvidia-auto-select @2560x1440 +0+1440 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}, DPY-5: nvidia-auto-select @2560x1440 +2560+0 {ViewPortIn=2560x1440, ViewPortOut=3840x2160+0+0}, DPY-0: nvidia-auto-select @2560x1440 +5120+1440 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}"

My default /etc/X11/xinit/xinitrc looks like:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

Still working thru the advice, thanks for the patience fellas!

There might be a possibility you have confused two different methods and application.

Using GUI

  • Use nvidia settings gui to configure your monitors as you prefer.
  • Save this configuration, using gui to ~/.nvidia-settings-rc
    (quote from Archwiki)

... by using the option Save Current Configuration under nvidia-settings Configuration tab.

  • Make this script autostart on session login (with appropriate to DE method)

Using CLI

Use nvidia-settings cli and get currentmetamodes bla, bla, bla...

First confirm that you have properly tried GUI method and failed, and then we talk about CLI method.


Do not forget that, you are running on an unusual HW setup (not alien, but not frequent), having two nvidia GPUs, active and similar, but not same. I hope you find your way easily, but just have that in mind :wink:
There is a difference on the system depending on which GPU is run first. If there is no specific configuration about which one should always be first, the order may change during random boots.

4 Likes

Ah! I was in the wrong tab, trying the X config approach! I did attempt the nvidia-settings tab approach to no avail. I am going to remove one of the cards and put it in another system that is currently running headless, as it was going to be used for CUDA rather than displays. Still working down the list. Thanks for being patient!