Steam for Linux

Steam for Linux

63 人が評価
Headless In-Home Steam Stream Server on Linux - HOW TO
作者: Dr. Zee
A detailed HOW-TO guide on setting up a Headless In-Home streaming Steam Server on Arch Linux. It should be possible to do this on other Linux flavours as well if you can find the right packages to install - which is essentially the only Arch Linux specific part of this guide.
2
   
アワード
お気に入り
お気に入り
お気に入りから削除
Background
I have been running a small home server for years. Initially it was only doing basic file sharing and other minor stuff to support my home network.

I primarily only use laptops as my "workstations" (with external dual screens and keyboard) as I do not like to have big machines sitting under or around my desk producing noise and heat. Both laptops and servers are running pure Linux - if I need Windows once in a while I crank up a Virtual one ...

The laptops are not powerful enough to effectively run most of the later games on Steam supporting Linux (Prison Architect, Kerbal Space, XCOM 2 - to just name a few). Being tired of that and seeing that In-Home Streaming appears mature now I though I take a stab at upgrading my server and make it an Headless In-Home Steam Stream server.

Note, that I am using Arch Linux - not that, pr. say, I dislike Ubuntu or the other flavours I just got tired of constant "release updating" and liked the idea of rolling updates in Arch Linux. So far I had remarkably few problems with that.

If you have a little experience with Linux and not afraid of the command line I suggest you give Arch Linux a stab.

Well back to the Headless In-Home Steam stream server .....
Pre-requisites and Hardware
The guide assumes that you have your basic server up and running already with, at minimum, the SSH daemon running and configured correctly for remote login.

Also assume that you know how to use the 'sudo' command to elevate the user you use for the install and configuration to root status. Basic command line editing in 'vi', 'nano' or any other editor you may be using is also required. You should also be familiar with the concept of mounting disks and other basic Linux operation.

Most standard hardware you can buy around works quiet well with Linux. Some however requires most recent kernel - which is another reason for using Arch Linux as it always uses the newest kernel.

It is important that the Kernel supports your Network Card and Graphic Card. In particular the Network Card needs to be able to run 1 Gbit (and obviously your entire home network must support this too) as the bandwidth required for the streaming is substantial.

If you use NVIDIA/ATI cards this also most likely only works with the original manufacturer drivers. If you want to use the open-source drivers you do so at your own risk.

For reference here the hardware I used:
  • Motherboard: Gigabyte GA-Z170X-UD5 (has two nice 1 Gbit Ethernet ports)
  • CPU: Intel Core I7 6700 8M Skylake (water cooled with a Corsair H60 Cooler)
  • Graphics: EVGA GTX 960 4GB
  • Memory: 16 GB (2x8 GB)
  • For Disks:
    • 1x120 GB SSD for the boot/home volume
    • 2x2 TB HDD in RAID1 for the file shares
    • 1x256 GB SSD disk to hold all the Games Data from Steam

The separate drive for steam game data is not strictly necessary - I just didn't want to fill up the boot/home volume or the file sharing disks with the Game Data so I elected to have one.
Setup
All the below commands etc. are completed through a SSH connection to the server unless specified explicitly.

Since I am writing this off notes I took while experimenting and making the set-up, there may be one or two things that 'got lost in translation'. If someone does this from scratch and find something I missed please let me know in the comments.

Lets get to it:
  1. SSH to the server in question

  2. Arch is using systemd - so assume that is what we have. We dont want the server to pr. default boot into X or start the Display Manager so we force the boot target to boot into the command line:
    sudo systemctl set-default -f multi-user.target

  3. Install some packages we need (hope I didn't forgot one let me know in the comments if):
    sudo pacman -S nvidia lib32-nvidia-libgl nvidia-libgl xf86-input-libinput xorg-server xorg-server-utils xorg-xinit linux-headers ttf-liberation lib32-alsa-plugins nvidia-settings lib32-curl pulseaudio pulseaudio-alsa pamixer xfwm4 xfce4-session xfdesktop
    • Nvidia packages are the Nvidia drivers
    • Xorg/xf86 packages for the base X-Server
    • PulseAudio we need to have audio available for Steam (otherwise the streaming will be without sound)
    • Header and TTF fornt packages are needed for Nvidia/Steam programs
    • The Steam Client is 32bit and needs some 32bit Libs to work properly - hence the lib32 packages
    • Some games require a proper window manager to work. I use XFWM/XFCE4 packages as they are the most lightweight ones and can limit what to install. Others should work too.

  4. Reboot to load the Nvidia Drivers properly into the Kernel (Think there is way to do this without - was just too lazy to find out. Rebooting was quicker.)

  5. SSH back into the server and open in a editor (I use 'vi' below - you may use something else)
    sudo vi /etc/X11/Xwrapper.config
    and either add the below line or enter it as the only line in the file:
    allowed_users=anybody
    This will allow X to be started from a SSH Shell

  6. Create a new user just for steam and steam games:
    sudo useradd -m -g users -G video,storage,power -s /bin/bash -d /mnt/games/steamuser steamuser
    Note that:
    • -G video,storage,power are a number of groups the user should to be a member of - this may be different if you are not using Arch Linux
    • /mnt/games/steamuser is where the users home directory is going to be. If you omit this the system will create the home directory in the default location, typically /home/. As mentioned earlier, I do this, to put the steam game data on a different disk that is mounted at /mnt/games
    Set the password for the user
    passwd steamuser

  7. Install steam
    sudo pacman -S steam

  8. For some of the initial configuration steps and to set-up the Steam Client (there is verification process) it is necessary temporarily to connect a monitor/keyboard and mouse to the server.

    Connect screen, keyboard and mouse and run:
    sudo nvidia-xconfig
    which will generate the xorg.conf file we need for the initial X Server run.

  9. Change to the user created earlier
    sudo su - steamuser

  10. We now create some basic files that help us making it easier to start steam on the headless machine in the future.

    First we create an auto-start entry that will automatically start the Steam Client when XFCE4 starts:
    mkdir .config/autostart vi .config/autostart/steamheadless.desktop
    and enter the following:
    [Desktop Entry] Version=1.0 Encoding=UTF-8 Name=Script Type=Application Exec=steam -login <steam account name> <steam account password> Icon= Terminal=false StartupNotify=false Hidden=false GenericName= GenericName[en_US]=
    Make the file read only by the steamuser to protect the steam account password in it.
    chmod 600 .config/autostart/steamheadless.desktop
    Create a a small shell script that start steam and all that is needed
    vi startsteam.sh
    And enter the following:
    #!/bin/bash pulseaudio --start pamixer -u pamixer --set-volume 90 startxfce4 > /dev/null killall -u steamuser gpg-agent
    Note that:
    • pulseaudio and pamixer are used to setup pulseaudio, sometimes pulseaudio sets the volume to 'mute' and you don't get any sound in the stream. So we make sure its turned up.
    • /dev/null is needed to suppress output from Steam. Otherwise your Steam username/password is shown in clear text in the console. If you however need to debug Steam you can remove it to see what error Steam shows.

    Make the file executable:
    chmod +x startsteam.sh

  11. Start Steam for the first time
    ./startsteam.sh

  12. You should now see the desktop and Steam lunch on the screen you attached directly to the server. The attached keyboard and mouse should also work.

    You now need to go through the Steam validation process, accept the license and login for the first time.

    When you done, exit Steam clicking Steam->Exit from the top menu.

  13. Launch the nvidia-settings program - on XFCE4 desktop you can do that by right clicking anywhere and selecting Applications->Other->NVIDIA X Server Settings from the menu. Then:
    • Under GPU 0 (assuming you only have one NVIDIA Graphics card installed) write down the connected display number (usually starts with DFP-x) e.g. DFP-1
    • Select the display and click Aquire EDID.
    • Select EDID File Format to ASCII and save the file in the home folder of the steamuser - name the file edid.txt
    • Exit nvidia-settings program

  14. Shutdown the Xwindows Session - easiest by pressing Ctrl-C in the SSH window from where it was launched. Then exit from the steamuser account (type exit).

  15. We now modify the xorg.conf file to allow the X Windows to start without screen attached in headless mode.
    sudo vi /etc/X11/xorg.conf
    Under Section "Device" insert:
    Option "ConnectedMonitor" "<display>" Option "CustomEDID" "<display>:<path>/edid.txt"
    Remember to replace <display> with the display number from previous steps. Also replace <path> with the full path of where the file edid.txt is.

    You can use the below EDID information for a monitor with 1920x1080 resolution if you can not generate you own one:
    00 ff ff ff ff ff ff 00 1e 6d 39 58 37 f4 05 00 0c 15 01 03 80 30 1b 78 ea 33 31 a3 54 51 9e 27 11 50 54 a5 4b 00 71 4f 81 80 81 8f b3 00 01 01 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c 45 00 dd 0c 11 00 00 1e 00 00 00 fd 00 38 4b 1e 53 0f 00 0a 20 20 20 20 20 20 00 00 00 fc 00 45 32 32 31 31 0a 20 20 20 20 20 20 20 00 00 00 ff 00 31 31 32 4e 44 56 57 42 47 31 39 39 0a 00 38

    If you don't want to run at full resolution (to reduce network demand for the streaming) you can use below to emulate a 1440x900 monitor:
    00 ff ff ff ff ff ff 00 30 ae 36 40 00 00 00 00 00 13 01 03 80 1e 13 78 ea e5 95 93 56 4f 90 28 28 50 54 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 8e 2c a0 5c 52 84 1e 30 30 20 36 00 2f be 10 00 00 19 8e 2c a0 fc 52 84 87 30 30 20 36 00 2f be 10 00 00 19 00 00 00 0f 00 95 0a 32 95 0a 28 16 09 00 4c a3 42 54 00 00 00 fe 00 4c 54 4e 31 34 31 42 54 30 39 30 30 31 00 f0

  16. You can now disconnect the monitor/keyboard/mouse from the server - they should no longer be needed

  17. The basic set-up is now done. You can exit the SSH session to the server.
Running the Steam on the server
To run the Steam client on the server and connect to it from the Steam client running on you laptop/desktop workstation use the following:
  1. Start the Steam Client on your laptop/desktop workstation and login
  2. SSH to the server
  3. Run the command that switches to the Steam user:
    sudo su - steamuser
  4. Launch X and the Steam Client
    ./startsteam.sh
  5. On your laptop/desktop workstation you should see a message notifying that the In-House Steam Stream server now is available
  6. Start playing :)
Note:
  • In the laptop/desktop workstation Stem Client you can under Steam->Settings->In-Home Streaming->Advanced Client Options play with the settings to improve performance if you have network issues or reduce the resolution - useful if you want to run the streamed games in a window on you laptop/desktop workstation instead of full screen.
  • To switch from full screen to windowed mode you can press Alt-Enter after the streaming starts.
  • If the Steam Client needs to download/install updates start-up on the server may take longer than usual - up a minute or more. If the Client on your laptop/desktop workstation updates then its a good indicator that the client on the server also needs updating and you should expect the start-up on the server to be delayed.

Thats it - hope this helps some one out there to get this up running too.

I have happily been playing XCOM 2 on a 4 year old Lenovo T420 laptop, with dual-screens and cabled Gbit network connection in windowed mode, for hours using this set-up, streaming at 1920x1080, without any problems. The game has been running at full detail level without any issue for hours.

By the way - XCOM 2 complains about the NVIDIA driver being Unsupported, this may be due to the fact that Arch Linux always uses the very latest driver and that the game does not recognize it correctly. It however works without any issue and the game works perfectly.

Happy playing!
14 件のコメント
Cy 2021年7月17日 11時50分 
Anyone cares to dockerize it so it would run in the background on my main Manjaro machine and I could play another game while my gf streams The Sims 4 to her laptop?
djbon2112 2021年6月25日 13時56分 
Thank you for this, it works wonderfully!

I decided to take it one step further, and execute the whole thing from Systemd automatically on my server. This did require a bit of tweaking. Since the output is too long to paste in a comment, I've created a Gist for it:

https://gist.github.com/joshuaboniface/50690ad188df15033c5f04b3cac31845
Johnny Ribbed 2021年5月16日 9時57分 
This looks great. Currently running CentOS on the server, but looking to go Arch after a hardware upgrade anyway, as desktop & laptops are all Arch, or Arch-based (Loving Garuda atm).

Any reason this wouldn't work using a cheap mining card, if the system can be fooled into accepting there is no monitor present, without having to connect one for starters?

Is there any difference to running directly on a desktop? eg, if a Win game fails due to falling over on the DRM, or other issue that makes it incompatible with Wine/Proton, is there any positive/negative that this setup would have?

Magpie Bird 2021年2月8日 16時46分 
How do you download games to server?

Also.
Thank you so much for this guide. This is written wonderfully and suits greatly both as learning material and practical instruction. *And* you somehow managed to hit the spot in use-case, hardware and distro choices for me. Much appreciated.
Kaari ︻デ 一 이드 님 !! 2020年7月17日 5時47分 
@Nicoco:
What you want to do here is for your gpu to render with no monitor attached, that's up to the driver to handle this case (or not, unfortunately), so with different drivers (nvidia, amdgpu...), there will or will not be tricks to make the gpu believes there is a monitor attached, with more or less success (bugs, stability issues...).
There are softwares to emulate a virtual monitor (xf86-video-dummy), but as pie stated, it will not make your gpu do the work, the cpu will take care of it (so don't expect to run games from it).

Your best bet (which will always work 100%, as long as it is of reliable quality) is to BUY a HDMI/DP/DVI (choose your weapon) "dummy plug". Which is basically a plug to connect to your gpu with basic electronic components inside to identify as a monitor with a specific resolution, therefore it IS a monitor from your system point of view, but in reality there is no screen to it, just a plug with an adapter.
nicoco 2020年6月23日 5時40分 
Thanks for the useful tutorial!

Any idea how to setup the CustomEDID thing with a RX 570 and the AMDGPU driver?

I can trick my headless box by plugging a monitor at startup and then unplugging it after steam launches. This way everything works fine. But it doesn't work if X starts with no monitor plugged in.

I tried to add this to xorg.conf

Section "Device"
Identifier "AMDGPU"
Driver "amdgpu"
Option "ConnectedMonitor" "HDMI-1-1"
Option "CustomEDID" "HDMI-1-1:/etc/X11/pseudomonitor.edid.conf"
EndSection

but the logs show:

[] (WW) AMDGPU(0): Option "CustomEDID" is not used

so I'm guessing only nvidia drivers support this option. I could not find a similar option for AMDGPU drivers. Any idea?
bartivs 2020年5月13日 14時00分 
hello, i get chashes when i use remote play, but it runs fine playing locally. My server is running manjaro.. Streams the menu and then when the games starts it freezes.. that can be a configuration issue or a resource problem?

Server config:
FX-4350
gtx-960 2g
8g of ram
boop 2019年2月8日 23時10分 
might want to clarify that unless you have an nvidia gpu, there is no hardware encoding, which will result in terrible performance on the host side as software encoding eats up all of your cpu
Mr NakNak 2018年10月15日 0時43分 
I thought about setting this up on our office deep learning rig when I get around to it. I'm glad to see I'm not the only one with such an idea and appreciate the effort you've put into presenting the steps you took! It will be a great help when I tackle mine.

Also, kudos for the Arch love!
Simon Pit 2018年2月28日 13時42分 
Anyone knows a way to do this on a Debian server ? or any good link ?