Skip to content

Instantly share code, notes, and snippets.

@janAkali
Last active January 1, 2026 07:02
Show Gist options
  • Select an option

  • Save janAkali/7152382e7b0cd581d9cebb72ed07438e to your computer and use it in GitHub Desktop.

Select an option

Save janAkali/7152382e7b0cd581d9cebb72ed07438e to your computer and use it in GitHub Desktop.
Guide for installing Steam in chroot in Void Linux
  1. create chroot with xvoidstrap (see https://docs.voidlinux.org/config/containers-and-vms/chroot.html)

  2. enter chroot with xchroot

  3. install steam and all extra 32-bit dependencies and drivers (see /usr/share/doc/steam/README.voidlinux inside chroot after installing steam)

  4. Since we're already in a separate namespace, bwrap cannot create another namespace, which causes it to fail, so we must make bwrap binary inside chroot setuid:

    chmod u+s /bin/bwrap
    
  5. create new user in chroot:

    useradd -m -G audio,video gamer
    
  6. exit chroot, e.g. with Ctrl+D

  7. steam won't launch if we don't do 2 extra things:

    • make chroot dir itself a mount point: mount --bind $CHROOT $CHROOT
    • enter our chroot with unshare: unshare -m chroot $CHROOT

    Source: Gentoo wiki

    Explanation: With bare chroot, the Steam client does not run, complaining "Steam now requires user namespaces to be enabled." For this Steam tests if bwrap --bind / / true succeeds. (This requires bwrap is set setuid.) Internally bwrap calls pivot_root (2), of which conditions with "/" are not met under systemd. With unshare the namespace gets separated, and things work.

    So I've copied xchroot script from my system and changed 3 lines total (see comments): Save this script as xchroot-steam and use it in the next steps:

     #!/bin/sh -e
     # xchroot DIR [CMD...] - chroot into a Void (or other Linux) installation
    
     fail() {
     	printf '%s\n' "$1" >&2
     	exit 1
     }
    
     if [ "$(id -u)" -ne 0 ]; then
     	fail 'xchroot needs to run as root'
     fi
    
     CHROOT=$1; shift
    
     [ -d "$CHROOT" ] || fail 'not a directory'
     [ -d "$CHROOT/dev" ] || fail 'no /dev in chroot'
     [ -d "$CHROOT/proc" ] || fail 'no /proc in chroot'
     [ -d "$CHROOT/sys" ] || fail 'no /sys in chroot'
    
     mount --bind "$CHROOT" "$CHROOT" # ADDED: mount chroot dir onto itself
     for _fs in dev proc sys; do
     	mount --rbind "/$_fs" "$CHROOT/$_fs"
     	mount --make-rslave "$CHROOT/$_fs"
     done
    
     touch "$CHROOT/etc/resolv.conf"
     mount --bind /etc/resolv.conf "$CHROOT/etc/resolv.conf"
    
     cleanup() {
     	umount -R "$CHROOT/dev" "$CHROOT/proc" "$CHROOT/sys" "$CHROOT/etc/resolv.conf"
     	umount -l $CHROOT # ADDED: unmount chroot dir
     }
    
     trap cleanup EXIT INT
    
     if [ -x "$CHROOT/$SHELL" ]; then
     	INNER_SHELL="$SHELL"
     elif [ -x "$CHROOT/bin/bash" ]; then
     	INNER_SHELL="/bin/bash"
     else
     	INNER_SHELL="/bin/sh"
     fi
    
     printf "\033[1m=> Entering chroot $CHROOT\033[m\n"
     export PS1="[xchroot $CHROOT] $PS1"
     unshare -m chroot "$CHROOT" "${@:-$INNER_SHELL}" # CHANGED: use unshare for chroot
     STATUS=$?
     if [ $STATUS -ne 0 ]; then
     	printf "\033[1m=> Exited chroot $CHROOT\033[m\n"
     else
     	printf "\033[1m=> Exited chroot $CHROOT with status $STATUS\033[m\n"
     fi
     exit $STATUS
    
  8. allow local connections to X server, by running this command in host system:

     xhost +localhost
    

    This is a potential security risk as any user could access the X server without authentication. To revoke access run xhost -localhost

  9. launch steam with your new user:

    sudo bash ./xchroot-steam <chroot_dir> su -c 'steam' gamer
    
  10. Repeat steps 8-9 to launch steam any time again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment