Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Steam/LXD"

From Funtoo
Jump to navigation Jump to search
m (Added pciutils to prerequisites)
m (Remove gdebi-core as it is unneeded)
Line 68: Line 68:
Install some prerequisites:
Install some prerequisites:
{{console|body=
{{console|body=
%steam-ubuntu% ##i##apt install wget gdebi-core software-properties-common pciutils
%steam-ubuntu% ##i##apt install wget software-properties-common pciutils
}}
}}
We also need to install graphics drivers in the container. The following instructions are taken from [https://github.com/lutris/docs/blob/master/InstallingDrivers.md Lutris], where you can find up-to-date instructions for different distributions as well.
We also need to install graphics drivers in the container. The following instructions are taken from [https://github.com/lutris/docs/blob/master/InstallingDrivers.md Lutris], where you can find up-to-date instructions for different distributions as well.
Line 100: Line 100:
Finally, download the official Steam package and install it:
Finally, download the official Steam package and install it:
{{console|body=
{{console|body=
%steam-ubuntu% ##i##wget -O ~/steam.deb http://media.steampowered.com/client/installer/steam.deb && gdebi ~/steam.deb && rm ~/steam.deb
%steam-ubuntu% ##i##wget -O ~/steam.deb http://media.steampowered.com/client/installer/steam.deb && apt install ~/steam.deb && rm ~/steam.deb
}}
}}
Before launching Steam, we need to disable the PulseAudio client's shared memory, so we force it to only use the socket:
Before launching Steam, we need to disable the PulseAudio client's shared memory, so we force it to only use the socket:

Revision as of 22:12, April 1, 2021

This page covers the process of installing Steam in a LXD container. The instructions assume that the container is Ubuntu, but it should be very similar for all other distributions.

Installing LXD

Please refer to the LXD page for instructions on setting up LXD.

Preparing the host

To be able to run graphical applications in the LXD container and to have audio, we need to allow connections to the host's X and PulseAudio sockets. To allow X connections, run as your regular user:

user $ xhost +local:

To allow PulseAudio connections, run as root:

root # sed -i "s/load-module module-native-protocol-unix/& auth-anonymous=1/" /etc/pulse/default.pa

Then, restart PulseAudio for the changes to take immediate effect:

user $ killall pulseaudio

Creating and configuring the container

In this example, we'll create an Ubuntu Groovy Gorilla container, which will be called 'steam-ubuntu':

root # lxc launch images:ubuntu/groovy steam-ubuntu

Now, it's time to configure the container. First, we need to pass the necessary devices and sockets to the container. Pass the GPU to the container:

root # lxc config device add steam-ubuntu mygpu gpu

Pass the X socket (specifically display 0):

root # lxc config device add steam-ubuntu X0 proxy bind=container connect=unix:/tmp/.X11-unix/X0 listen=unix:/tmp/.X11-unix/X0 uid=1000 gid=1000 mode=0777 security.uid=1000 security.gid=1000

Pass the PulseAudio socket:

root # lxc config device add steam-ubuntu PASocket1 proxy bind=container connect=unix:/run/user/1000/pulse/native listen=unix:/home/ubuntu/pulse-native uid=1000 gid=1000 mode=0777 security.uid=1000 security.gid=1000

Also, we'll set some environment variables. Set the DISPLAY environment variable:

root # lxc config set steam-ubuntu environment.DISPLAY :0

Set the PULSE_SERVER environment variable:

root # lxc config set steam-ubuntu environment.PULSE_SERVER unix:/home/ubuntu/pulse-native

Disable Proton's esync, as it appears to cause crashes in certain games (workaround):

root # lxc config set steam-ubuntu environment.PROTON_NO_ESYNC 1

Installing Steam

We're ready to spawn a shell inside the container and install Steam:

root # lxc exec steam-ubuntu -- bash

We're now inside the container. Steam requires certain x86 libraries, so we need to add the i386 architecture repository:

steam-ubuntu # dpkg --add-architecture i386

Update and upgrade the system:

steam-ubuntu # apt update && apt upgrade

Install some prerequisites:

steam-ubuntu # apt install wget software-properties-common pciutils

We also need to install graphics drivers in the container. The following instructions are taken from Lutris, where you can find up-to-date instructions for different distributions as well.

Mesa drivers (AMD/Intel)

To get the latest Mesa drivers it is necessary to add the kisak-mesa PPA:

steam-ubuntu # add-apt-repository ppa:kisak/kisak-mesa

Upgrade the system again:

steam-ubuntu # apt update && apt upgrade

Install the drivers:

steam-ubuntu # apt install libgl1-mesa-dri:i386 mesa-vulkan-drivers mesa-vulkan-drivers:i386

Nvidia (proprietary) drivers

To get the latest Nvidia drivers it is necessary to add the Proprietary GPU Drivers PPA:

steam-ubuntu # add-apt-repository ppa:graphics-drivers/ppa

Upgrade the system again:

steam-ubuntu # apt update && apt upgrade

Install the correct Nvidia driver for your GPU, i.e. version 460. The version should match your host's driver version:

steam-ubuntu # apt install nvidia-driver-460 libvulkan1 libvulkan1:i386


Finally, download the official Steam package and install it:

steam-ubuntu # wget -O ~/steam.deb http://media.steampowered.com/client/installer/steam.deb && apt install ~/steam.deb && rm ~/steam.deb

Before launching Steam, we need to disable the PulseAudio client's shared memory, so we force it to only use the socket:

steam-ubuntu # sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf

The installation is now done. Exit from the container:

steam-ubuntu # exit

Launching Steam

Before launching Steam for the first time, it's a good idea to restart the container to make sure all changes are applied properly:

root # lxc restart steam-ubuntu

Then, we can launch Steam with the following command:

root # lxc exec steam-ubuntu -- bash -c "su ubuntu -c steam"

You're now ready to log in and play!