Games

How to Set Up Linux for Gaming

When it comes to gaming in Linux, most people consider it as a distant possibility. But over the years, Linux has evolved in its gaming space and can be used as a gaming operating system.

The added advantage is that Linux provides more efficiency because it does not require a lot of memory. The article provides a detailed guide on setting up Ubuntu Linux as a platform for gaming.

Gaming on Linux

Gaming on Linux was a difficult task as it requires a lot of workarounds and specific hardware. But, the introduction of the game distribution platform known as Steam Play in 2012 revolutionized the Linux gaming experience. It allows gamers to play Windows games in Linux and introduces thousands of games specific to it but it did not support most of the triple-A games for Linux.

However, the integration of Proton with Steam Play adds a compatibility layer that has simplified gamer’s experience of playing thousands of Windows games on Linux. It further contains popular tools like Wine and DXVK that enhance game performance and user experience by relieving them from the burden of understanding the underlying system.

Setting up Linux for gaming requires some workarounds. Follow this step by step guide for a better experience of gaming on Linux:

Getting the Latest Video Drivers

Video drivers provide optimal system performance for games. Install the latest video drivers on your system by running the following commands.

32-bit Support:

To help Linux run 32-bit applications in a 64-bit architecture, enable the 32-bit libraries in debian-based distributions.

Run the following dpkg command in Ubuntu:

ubuntu@ubuntu:~$ sudo dpkg --add-architecture i386

For users with AMD Graphic cards, install the AMD Mesa driver as follows:

ubuntu@ubuntu:~$ sudo add-apt-repository ppa:kisak/kisak-mesa -y
ubuntu@ubuntu:~$ sudo apt update
ubuntu@ubuntu:~$ sudo apt install mesa

Install Lutris:

Lutris is a free-open source game management platform that provides smooth game installation and optimal settings. Lutris requires some dependencies for successful installation. For that, let’s begin with Wine installation to add a compatibility layer for running Windows applications on Linux. Without these dependencies, Litrus tools might not perform all the functions required for an optimized gaming experience:

Wine and Dependencies Installation

Download the repository key to add it to the system, as follows:

ubuntu@ubuntu:~$ wget -nc https://dl.winehq.org/wine-builds/winehq.key
ubuntu@ubuntu:~$ sudo apt-key add winehq.key

Finally add the Wine repository and update the system to install wine-staging version:

ubuntu@ubuntu:~$ sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main' -y
ubuntu@ubuntu:~$ apt update
ubuntu@ubuntu:~$ apt-get install winehq-staging -y

Get the debian compatible package for OpenSUSE Build Service by adding its repository for automatic updates, as follows:

ubuntu@ubuntu:~$ echo "deb http://download.opensuse.org/repositories/home:/strycore/Debian_10/ ./" | sudo tee /etc/apt/sources.list.d/lutris.list

Now download and add the repository key:

ubuntu@ubuntu:~$ wget -q https://download.opensuse.org/repositories/home:/strycore/Debian_10/Release.key
ubuntu@ubuntu:~$ sudo apt-key add Release.key

Finally update the system to install lutris:

ubuntu@ubuntu:~$ sudo apt-get install lutris -y

Esync

Esync aims to reduce the performance overhead of Wine in scenarios like CPU bound. It helps with the compile-time and improves the performance of the CPU. Use the following command to check if it is enabled by default.

ubuntu@ubuntu:~$ ulimit -Hn

It will return output in the form of numbers. A number greater than 500,000 means esync is enabled. If not edit the system.conf & user.conf files inside /etc/systemd directory with the following line:

DefaultLimitNOFILE=524288

Similarly, to maintain the settings after reboot set the ulimit value in the limits.conf file inside /etc/security as follows:

ubuntu@ubuntu:~$ sudo vim /etc/security/limits.conf
[domain] [type] [item] [value]
User hard nofile 524288

Such that the above settings enforces hard limits on the user (replace it with the username), to process 524288 open files.

Enable the GameMode

GameMode is a set of libraries and daemons that provide on request temporary optimizations to the hosting system or on a game for better game experience.

GameMode unlocks all cores of the system. It makes sure that no unusual background processes are running simultaneously with the game that might interrupt the performance. GameMode currently supports optimizations such as, custom scripts, input/output priority, kernel scheduler, etc.

Games like Rise of the Tomb Raider, Total War: Three Kingdoms, DiRT 4 etc integrate its support and players only need to run the game for its activation. While others need to request the GameMode support by launching the game using following command:

ubuntu@ubuntu:~$ gamemoderun ./name-of-the-game

For Steam, Type gamemoderun %command% at the game launch option. Before, GameMode installation, install the following dependencies on Ubuntu:

ubuntu@ubuntu:~$ apt install libdbus-1-dev ninja-build build-essential meson libsystemd-dev pkg-config git libinih-dev

Now Install GameMode as follows:

ubuntu@ubuntu:~$ git clone https://github.com/FeralInteractive/gamemode.git
ubuntu@ubuntu:~$ cd gamemode
ubuntu@ubuntu:~$ git checkout 1.5.1
ubuntu@ubuntu:~$ ./bootstrap.sh

Issues and Custom installation of Proton

As mentioned earlier, the compatibility layer that Proton provides has some issues as it is a bit under-developed as compared to Wine. But, users can resolve them by performing the custom installation of Proton.

For more details, check the Proton Update Script on Github. cd into the root folder and wget to download the cproton.sh file, allow execution permission, and run the script as follows.

ubuntu@ubuntu:~$ cd ~
ubuntu@ubuntu:~$ wget https://raw.githubusercontent.com/Termuellinator/ProtonUpdater/master/cproton.sh
ubuntu@ubuntu:~$ sudo chmod +x cproton.sh
./cproton.sh

Enabling ACO Compiler (AMD Users)

AMD compiler enhances performance by switching it from LLVM to ACO. It allows the ACO compiler games to perform exceptionally fast on Linux.Install latest video drivers for AMD to enable ACO compiler. After installation, include the following line in the /etc/environment file as:

RADV_PERFTEST=aco

Enabling the ACO compiler is optional as it might allow most ACO compatible to perform exceptionally well. However, it can also cause issues for some games.

Conclusion:

Setting up Linux for gaming can be a tough job, but playing games on Linux can be a better experience as it consumes limited PC resources. The article provides a step-by-step guide to customize Linux for gaming purposes and better game performance. We also give information for AMD users to help them set up their PC for gaming.

Even though Linux is in wide use for work, Windows is still dominating the gaming world. Linux provides high-level customization on every aspect of the system to make it suitable to play the best of all games.

About the author

Usama Azad

A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14