This is a summary of how I set up a chroot for use with steam on Gentoo.
My reasoning for this approach to installing steam is as follows
- Certain games do not want to work with the flatpak distribution, and flatpak is not pleasant to troubleshoot in this case
- Installing steam on the host system would require I pull in several 32-bit packages, which I don't want to do
- Installing steam in a chroot gives me the ability to fine-tune the environment that steam lives in without breaking my host system
There isn't much to do here. Make sure you have schroot installed by running emerge schroot.
schroot is a tool used primarily by the debian project for packaging operations. It allows for straightforward user access to chroots without the need to authenticate, as well as several handy facilities for replicating nss databases and managing bind mounts.
This makes it far more pleasant to set up and work with than a chroot wrapper script.
schroot configuration is stored in /etc/schroot/schroot.conf, a typical INI file.
You'll want to add a section roughly similar to this to that configuration:
[steam]
profile=steam
type=directory
description=Multilib Gentoo installation for Steam
directory=/srv/chroot/steam
users=roman
root-users=roman
root-groups=root
shell=/bin/bash
preserve-environment=trueThe defined values mean the following
profiletells schroot what profile we'll be using (more on this in a moment)typetells schroot how the chroot directory is set up,directoryis a normal chrootdescriptionis a description of the chroot.directoryis the path to the chroot directory. This tutorial will use/srv/chroot/steamhere, but you can use whatever directory you please. It is advisable that the directory not be in a home directory.usersusers that are permitted to access the chroot, separated by comma (,)root-usersusers that are permitted to access the chroot as root (schroot -c steam -u root)root-groupsgroups that are permitted to access the chroot as rootshellpermitted login shells (you typically don't need to set this)preserve-environmentwhether the shell environment should be copied from the invoking process into the spawned process
In this case, I have set shell because my fish configuration will produce lots of noise if installed in the chroot.
If you would like to permit a group of users regular access to the chroot, you may use groups.
For more information, refer to schroot.conf(5).
schroot profiles describe certain actions that schroot will take to ensure that the chroot functions as desired.
Profiles are referenced relative to /etc/schroot. So, profile=steam will refer to the profile /etc/schroot/steam.
Create the profile directory (as root)
mkdir /etc/schroot/steamAnd populate the following named files as described -
Mountpoints are described in /etc/schroot/steam/fstab. This file is in fstab(5) format.
Mountpoint destinations (not sources) are relativized to the chroot directory by schroot. You need not fully qualify them yourself.
# fstab: static file system information for chroots.
# Note that the mount point will be prefixed by the chroot path
#
# (CHROOT_PATH)
#
# <file system> <mount point> <type> <options> <dump> <pass>
/proc /proc none rw,bind 0 0
/sys /sys none rw,bind 0 0
/dev /dev none rw,bind 0 0
/dev/pts /dev/pts none rw,bind 0 0
/home /home none rw,bind 0 0
/tmp /tmp none rw,bind 0 0
/var/lib/dbus /var/lib/dbus none rw,bind 0 0
/var/db/repos /var/db/repos none ro,bind 0 0
/run /run none rw,bind 0 0
/dev/shm /dev/shm none rw,bind 0 0
Depending on how /run/user/... is handled on your system, you may need to do as follows for each user that will require access
/run/user/1000 /run/user/1000 none rw,bind 0 0
If /run/user/$(id -u) is not accessible, steam will behave in strange and unusual ways.
If /run is not accessible, steam will behave in even stranger and more unusual ways.
If you make any changes to this file, schroot will apply them the next time you interact with schroot(1).
schroot will also copy your user, group, password, and other important databases into the chroot.
You'll need to tell it which files to copy using the /etc/schroot/steam/nssdatabases file.
It should look something like this -
passwd
shadow
group
services
protocols
networks
hosts
Any other files that need to be copied may be listed in /etc/schroot/steam/copyfiles.
You'll at least want to copy resolv.conf.
/etc/resolv.conf
Additional files may be specified as a source and then an optional space followed by the destination.
Having configured schroot, you will now need to prepare the chroot. To do this, you will need to retrieve and unpack a stage3 (or 4) tarball into the chroot directory.
Current stage3 tarballs may be found at the Oregon State University OSL.
This document was written having used stage3-amd64-systemd-20201206T214503Z.tar.xz.
Having downloaded the tarball, create the chroot directory (as root)
mkdir -p /srv/chroot/steamEnter the directory and unpack the tarball (as root)
cd /srv/chroot/steam
tar xpvf stage3.tar.xz --xattrs-include='*.*' --numeric-ownerWith the above having been done, you should be ready to enter the chroot (as root).
You can do this either by running schroot -c steam as root, or by running schroot -c steam -u root.
One of the first things you'll probably want to do is to set up your make.conf.
Make any changes you please, and be sure to set VIDEO_CARDS to match your host make.conf.
You'll probably also want to add elogind to USE.
For reference, I made the following changes, but you shouldn't copy them without checking your own configuration.
COMMON_FLAGS="-O2 -pipe -march=znver1"
MAKEOPTS="-j56"
ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*" # only in this chroot, if you prefer to whitelist you'll need to add 'ValveSteamLicense'
VIDEO_CARDS="amdgpu"
CPU_FLAGS="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3"
USE="elogind"Yes, -j56. I have a CPU with 64 logical cores.
Go ahead do a --changed-use rebuild -
emerge --changed-use --deep @worldAnd then rebuild openssl to clear +bindist (this can pose issues later)
emerge opensslFinally, go ahead and update @world
emerge --update --deep --with-bdeps=y @world --askYou'll need to set the appropriate USE flag for Mesa so as to build the DRI interface for your graphics card.
In my case, I have a Radeon VII which requires that I add the video_cards_radeonsi flag to Mesa, and
video_cards_radeon to libdrm. Since you'll probably want Vulkan support, you'll need to add the vulkan flag
to Mesa, and the X flag to vulkan-loader. You might stick the following in package.use/
media-libs/mesa video_cards_radeonsi vulkan
media-libs/vulkan-loader X
x11-libs/libdrm video_cards_radeon
Next, you'll need to add layman and the steam-overlay overlay.
emerge layman
layman -f
layman -a steam-overlayFollowing this, install steam-launcher and handle any necessary use changes
emerge --ask steam-launcher
Once you've dealt with use changes and installed steam-launcher, you'll have steam on the path.
You can start steam by running schroot -c steam steam.
If you would like a wrapper script to start steam, you can drop the following somewhere in your path.
#!/bin/bash
if [ "x$SCHROOT_CHROOT_NAME" != "x" ]; then
/usr/bin/steam "$@"
else
schroot -c steam -- steam "$@"
fi