注意:

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

Steam/LXD

From Funtoo
< Steam
Revision as of 14:56, November 21, 2021 by Invakid404 (talk | contribs) (Note that host preparation is a one-time process)
Jump to navigation Jump to search

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. These commands only need to be run once to set up your host installation and not before creating a container in general. Running them multiple times may mess things up (especially the pulseaudio sed command)! 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 Hirsute Hippo container, which will be called 'steam-ubuntu':

root # lxc launch images:ubuntu/hirsute 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!