summaryrefslogtreecommitdiff
path: root/content/posts/optimus-void.md
diff options
context:
space:
mode:
authorShubham Saini <me@ubh.sh>2023-02-09 00:19:28 +0000
committerShubham Saini <me@ubh.sh>2023-02-09 00:19:28 +0000
commitd7da16ecfa5cadb643df78694db44963ba665cbe (patch)
tree00c5234f542f7064e91827064767bcf59f094a2c /content/posts/optimus-void.md
init
Diffstat (limited to 'content/posts/optimus-void.md')
-rwxr-xr-xcontent/posts/optimus-void.md98
1 files changed, 98 insertions, 0 deletions
diff --git a/content/posts/optimus-void.md b/content/posts/optimus-void.md
new file mode 100755
index 0000000..6ae889c
--- /dev/null
+++ b/content/posts/optimus-void.md
@@ -0,0 +1,98 @@
1---
2title: "Using Optimus on Void or Non Systemd Distros"
3date: 2019-09-13T12:10:56+05:30
4description: This article is for those who are a victim of laptop vendors but want to squeeze out maximum performance of their machine.
5draft: false
6---
7
8## What is optimus technology?
9According to gentoo wiki
10> NVIDIA Optimus is a proprietary technology that seamlessly switches between two GPUs. It is typically used on systems that have an integrated Intel GPU and a discrete NVIDIA GPU. The main benefit of using NVIDIA Optimus is to extend battery life by providing maximum GPU performance only when needed.
11
12There is a great wiki about using bumblebee(not transformer) on void linux but bumblebee’s project last commit was in 2013 and it doesn’t support vulkan, so no luck for linux gamers. A better way is to use a utility like nvidia-prime which is available for ubuntu or optimus-manager which is available for arch-based distros(available in AUR). Sadly, these projects require systemd as a init system. There is only one project which uses shell script and partly depends on systemd but is pretty hackable - [nvidia-xrun](https://github.com/Witko/nvidia-xrun).
13
14## Problem on void
15libglvnd is broken in void repos which makes it hard to have multiple drivers from different vendors to coexist on the same filesystem. This results in having either openGL libraries from mesa or nvidia.
16
17## The Hack
18Install nvidia openGL libraries in /opt directory and point nvidia-xrun to use them. This is just a workaround of libglvnd.
19
20First of all install these packages:
21- nvidia-dkms - for kernel modules
22- libGL libEGL - mesa drivers
23- xrandr xorg - display server
24- any wm/de
25
26Create a file /etc/modprobe.d/nvidia.conf for blacklisting nvidia kernel modules so that they won’t be loaded at boot. Add the following text:
27```
28blacklist nvidia
29blacklist nvidia-drm
30blacklist nvidia-modeset
31blacklist nvidia-uv
32blacklist nouveau
33```
34
35Next create some directories
36```shell
37$ sudo mkdir /opt/nvidia
38$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib
39$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib32
40$ sudo mkdir /etc/X11/nvidia
41```
42
43Now we have to create a fakeroot directory with nvidia openGL libraries
44```shell
45$ sudo ln -s /opt/nvidia/fakeroot/usr/lib /opt/nvidia/fakeroot/lib
46$ sudo ln -s /opt/nvidia/fakeroot/usr/lib32 /opt/nvidia/fakeroot/lib32
47$ sudo chmod 755 -R /opt/nvidia/fakeroot
48$ xbps-install --rootdir /opt/nvidia/fakeroot --repository https://alpha.de.repo.voidlinux.org/current --repository https://alpha.de.repo.voidlinux.org/current/nonfree --repository https://alpha.de.repo.voidlinux.org/current/multilib --repository https://alpha.de.repo.voidlinux.org/current/multilib/nonfree --yes --sync nvidia nvidia-libs nvidia-libs-32bit
49```
50
51Next clone my repo and move the scripts to respective location
52```shell
53$ git clone https://github.com/fd0e/optimus-hack.git
54$ cd optimus-hack/
55$ sudo cp -r xorg.conf xorg.conf.d /etc/X11/nvidia/
56$ sudo cp run.sh /opt/nvidia/
57```
58
59There is also off.sh which ensures that GPU is off. Run this as root at boot.
60
61Also add these lines in your ~/.xinitrc.
62```shell
63# load additional configs
64if [ "$2" = "nvidia" ]; then
65 XINIT_D="/etc/X11/nvidia/xinit/xinitrc.d"
66else
67 XINIT_D="/etc/X11/xinit/xinitrc.d"
68fi
69
70if [ -d "$XINIT_D" ]; then
71 for f in "$XINIT_D/?*.sh" ; do
72 [ -x "$f" ] && . "$f"
73 done
74 unset f
75fi
76unset XINIT_D
77
78# additional nvidia specific settings
79if [ "$2" = "nvidia" ]; then
80 xrandr --setprovideroutputsource modesetting NVIDIA-0
81 xrandr --auto
82fi
83```
84
85Now close your X session and run /opt/nvidia/run.sh.
86
87And boom! Your X session is now running on nvidia opengl libraries.
88
89## Troubleshooting
90If steam complains about missing libGL. Run steam using this command
91```shell
92$ STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0 steam
93```
94
95## Conclusion
96I don’t recommend using this method but this is the only thing that worked for me.
97
98See this article for more details - [here](https://www.ifnull.org/articles/void_optimus_nvidia_intel/#disqus_thread)