Tux's lil' helper
Joined: 27 Dec 2011
|Posted: Tue Mar 15, 2016 5:33 pm Post subject: Steam in systemd-nspawn container
|Anybody use Steam in a systemd-nspawn container?
I was annoyed with how many packages were re-compiled as 32bit when I installed Steam, so I decided to try to put this in a container. I played with this for hours yesterday and it took me every second of it to finally get it to work. But I have a feeling I didn't do this correctly, and I can't find a guide anywhere of somebody doing this on gentoo. A couple things that I did (which I kind of think defeat the purpose/benefits of using a container) are installing nvidia-drivers in the container, which then required me to have a working kernel .config, so I compiled a kernel in the container as well.
Since I eventually got this to work I'll post the steps of what I did in case it helps somebody else, but I would love to hear advice as to if I did this correctly or could have saved myself some hassle. I think maybe just some extra --bind mounts or something.
1. Create ~/steamcontainer
2. Get the current stage3 amd64 tar.bz2 files and unpack them in ~/steamcontainer
3. sudo systemd-nspawn -D ~/steamcontainer --bind /usr/portage
4. Configure /etc/portage/make.conf
5. Ran emerge -uDavN @world to pull in my configured use flags and to also install systemd so that I have a working init system in the container
6. Install alsa-utils
7. Exit the container
8. On the host, emerge xhost and run "xhost +local:"
9. sudo systemd-nspawn -b -D ~/steamcontainer --bind /usr/portage --bind /dev/snd (the last bind mount is needed for alsa, that took me forever to figure out)
10. Get a working .config file for your kernel (copy it from the host machine if you want) and install your drivers (in my case nvidia-drivers)
11. run "export DISPLAY=:0"
12. Followed this guide: https://wiki.gentoo.org/wiki/Steam to create the steam set, use flags, running emerge @steam, fetching and extracting the steam installer, and running the steam installer
13. Launched steam with this script:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib32/opengl/$(eselect opengl show)/lib"
exec ~/.local/share/Steam/steam.sh "$@"
After doing all of that steam launches just fine and the performance seems to be the same as before. But what could I do differently? Do I really need to install nvidia-drivers in the container or can I just bind mount a folder for that? If I can avoid having to emerge nvidia-drivers then I think I can avoid having to maintain a kernel in the container.
**edit** after thinking about this more... would bind mounting /usr/lib32/opengl resolve the issue? maybe then i wouldn't need to install nvidia drivers in the container? i'll try this when i get home and post results.