A friend of mine asked if I wanted to play Heroes of the storm with him. But then I found out that the creators were blizzard, and they are known to hate Linux. But often you can emulate windows games, and heroes of the storm should be no difference right?
In this post I will show how to install Heroes of the storm though wine in a container.
Table of Content
- Introduction
- Step 0 Install lxc
- Step 1 Install missing package
- Step 2 Fix the gui
- Step 3 Graphics
- Step 4 Wine
- Step 5 Heroes of the storm
- Step 6 Further
Introduction
These days steam are making games more common for Linux ( well, ubuntu at least) but it’s always been the downside of Linux. The solution for this has in many cases been to use a windows emulator called Wine. My experience with OS emulators (like cygwin) are that they tend to make a mess of your installation. For the last few years containers has been hot stuff with Linux. It’s a semi VM, it actually runs on your hosts kernel (protected by namespaces) and it is really useful for just this kind of situation when you don’t want to install a horde of compatible libraries on your machine.
Is it possible to combine containers and wine? Well yes!
Step 0 Install lxc
Containers are easy to create, but they can really put your linux knowledge to test when you want to modify them and grant permissions. I recommend you to read Stéphane Graber posts at https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/ before you try what I do in this post. A lot of the graphics is taken from his post about gui.
Install lxc
# apt-get install lxc
Then let’s create a container called wine
lxc-create -t download -n wine
You will have to select distro, version and architecture.
- Distro: I picked ubuntu and for two good reasons. 1: My host is ubuntu making it easier to compare with the guest (especially for fixing the gl drivers) 2: a lot of programs are made for ubuntu making installation less of a hazzle.
- Version. I picked same as my host: wily. Much for the same reason as mentioned in 1 above.
- Architecture: I found the i386 being slightly easier to install than amd64, but I prefer having 64-bit.
There are some difference in the error output you get when using 32 respectively 64-bit architecture. I’ll post both output, but keep in mind that it might differ depending on architecture.
Start it and log in to make sure everything went ok.
$ lxc-start -n wine
$ lxc-attach -n wine
update
# apt-get update;apt-get upgrade
tips: to log out you can send EOF with ctrl+D
Step 1 Install missing package
Log in to your guest. First of all, if you use any other locale than US you should install the correct language package to avoid the annoying error message:
perl: warning: Setting locale failed.
I’m using Swedish:
2016/05/heroes-of-the-storm-for-linux# apt-get language-pack-sv
Next you want to add auto completion:
# apt-get install bash-completion
start it by: . /etc/bash_completion
If you use the terminal a lot it can be a good idea to put it in .bashrc
Step 2 Fix the gui
Next thing we should install some GUI application . Install chromium, it will be used later in the tutorial anyway (and in heroes of the storm when it want to show a web page from battle.net)
# apt-get install chromium-browser
(500 Mb!)
Try to start it.
Gtk: cannot open display: :0
Problem with open the display. That’s not so strange. The container is minimum installation of ubuntu, no desktop environment and no xorg.
Let’s use the hosts xorg by mounting it to the guest. Add following section in .local/share/lxc/wine/config
#mounts
lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir
I also had to allow connection by: xhost +
This is probably not good for security to allow anyone to connect. I haven’t tried but you can probably tweak it and use localhost for allowed IP addresses.
Stop the container and restart it.
Chromium will now complain that you are using root — as it should. Surfing from root is a really really bad idea.
lxc created a user “ubuntu” in my guest tat is user 1000. If you do not have one then create one with adduser and make sure it is uid 1000. Switch to the user.
# su – ubuntu
Now chromium should work!
Try to use the unprivileged user as much as possible. Obviously you need to be root to install packages, but don’t run wine and other programs as root.
If you get the error:
[0520/102117:ERROR:nss_util.cc(98)] Failed to create /home/ubuntu/.pki/nssdb directory.
[0520/102118:ERROR:nss_util.cc(98)] Failed to create /home/ubuntu/.pki/nssdb directory.
[0520/102118:FATAL:chrome_main_delegate.cc(411)] Check failed: process_type.empty(). Unable to get the user data directory for process type: zygote
Then you need to map the guest user with a host owner that got permission to write to hosts: .local/share/lxc/wine/rootfs/home/ubuntu
This is done in the end of next step.
Step 3 Graphics
This was by far the toughest part to fix. I use ATI/AMD while most guides online use Nvidia. Those did not work very well for me, and I expect if you got another manufacture you probably have to do it different, but I will try to write how to troubleshoot and find what libraries you need.
Install opengl utils
# apt-get install mesa-utils
start glxgears
$ glxgears
ibGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
That’s bad news. Let’s see what glxinfo says:
$ LIBGL_DEBUG=verbose glxinfo
name of display: :0
libGL: screen 0 does not appear to be DRI2 capable
libGL: OpenDriver: trying /usr/lib/fglrx/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/fglrx/dri/swrast_dri.so
libGL: dlopen /usr/lib/fglrx/dri/swrast_dri.so failed (/usr/lib/fglrx/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
libGL: Can’t open configuration file /home/zabbat/.drirc: No such file or directory.
libGL: Can’t open configuration file /home/zabbat/.drirc: No such file or directory.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
display: :0 screen: 0
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)
This basically means that it’s not possible to use hardware and you will make your CPU render. Also as we scroll through the text we can see that the gl version is really low (mine was 1.4).
How does it look like on the host side?
$ LIBGL_DEBUG=verbose glxinfo
name of display: :0
display: :0 screen: 0
direct rendering: Yes
….
libGL: OpenDriver: trying /usr/lib/dri/fglrx_dri.so
ukiDynamicMajor: found major device number 243
ukiDynamicMajor: found major device number 243
ukiDynamicMajor: found major device number 243
ukiOpenDevice: node name is /dev/ati/card0
The driver it is using is fglrx. Let’s install this on the guest too.
# apt-get install fglrx
(Almost 500Mb!)
reboot and run glxinfo again.
name of display: :0
libGL: AtiGetClientDriverName: 15.20.3 fglrx (screen 0)
libGL: OpenDriver: trying /usr/lib/fglrx/dri/fglrx_dri.so
libGL error: OpenDriver: failed to open /usr/lib/fglrx/dri/fglrx_dri.so, error[/usr/lib/fglrx/dri/fglrx_dri.so: cannot open shared object file: No such file or directory]
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
libGL error: OpenDriver: failed to open /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so, error[/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so: cannot open shared object file: No such file or directory]
libGL: OpenDriver: trying /usr/lib/dri/fglrx_dri.so
ukiDynamicMajor: found major device number 243
ukiOpenDevice: node name is /dev/ati/card0
Error: No root privilege. Please check with the system-admin.
…
Better!
The gl version is higher but still low:
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: AMD Radeon R9 200 Series
OpenGL version string: 2.1 (4.5.13399 Compatibility Profile Context 15.201.1151)
let’s try glxgears again:
open uki failed (Operation not permitted)
libGL error: reverting to (slow) indirect rendering
“ukiOpenDevice: node name is /dev/ati/card0
Error: No root privilege. Please check with the system-admin.”
and
“Operation not permitted”
tells us that accessing the driver is not going well.
To fix this we should mount the driver. Add
lxc.mount.entry = /dev/ati/card0 dev/ati/card0 none bind,optional,create=file
in the config file. Containers still don’t like any user to have permission to mess with device drivers, so we should add it as an exception. We are using /dev/ati/card0, let’s check the device version numbers for it. On the host:
$ ll /dev/ati
crw-rw-rw- 1 root root 243, 0 maj 15 19:48 card0
Add the permision for the device in the config file:
# groups
lxc.cgroup.devices.allow = c 243:* rwm
restart the container and try gears again. It should work.
glxinfo gives:
ukiOpenDevice: node name is /dev/ati/card0
ukiOpenDevice: open result is 4, (OK)
ukiGetBusid returned ‘PCI:1:0:0’
It could be useful to add mappings from you container to your host so that you user has same permissions. I’m not sure if you need this, but if you get any problem add:
lxc.id_map = u 0 100000 1000
lxc.id_map = g 0 100000 1000
lxc.id_map = u 1000 1000 1
lxc.id_map = g 1000 1000 1
lxc.id_map = u 1001 101001 64535
lxc.id_map = g 1001 101001 64535
in your config ( remove any other default mapping).
Step 4 Wine
The current supported wine version in ubuntu is 1.6 and that does not work very well with Heroes of the new earth. Install a newer version, I used the latest (1.9.9) staging. Newer version usually got much better performance and when using 1.6 the game would freeze.
# apt-get install software-properties-common
For i386:
# add-apt-repository ppa:wine/wine-builds
# apt-get update
# apt-get install –install-recommends wine-staging
# apt-get install winehq-staging
https://github.com/wine-compholio/wine-staging/wiki/Installation#-ubuntulinux-mint
If you are on 64-bit then:
# add-apt-repository ppa:wine/wine-builds
# apt-get update
# apt-get install –install-recommends wine-staging-amd64
trying to install:
# apt-get install winehq-staging
will give you:
The following packages have unmet dependencies:
winehq-staging : Depends: wine-staging (= 1.9.10~ubuntu15.10.1) but it is not going to be installed
you must add multi arch:
# sudo dpkg –add-architecture i386
Step 5 Heroes of the storm
Open chromium and download the installer:
https://us.battle.net/account/download/
once downloaded start it. Remember to not be root when you shouldn’t.
wine installer.exe
(or wine64)
I had problems that when there were an update I would get an error message :
“To install this game, please run the Blizzard Setup program while logged in to this computer as an administrator.
Errors: BLZBNTBTS00000023, BLZBNTBTS00000024, BLZBNTBTS0000H”
I solved this problem by removing white space in the installation path:
c:\program_files\heroes_of_the_storm\
Note that blizzard will automatically install it to a folder with white space “Heroes of the storm”, but you can rename it afterwards and then go to settings and change the installation folder.
Step 6 Further
In this post I have not added sound.
https://www.stgraber.org/2014/02/09/lxc-1-0-gui-in-containers/ should give you the needed information.
The game works well in minimal graphics settings (35~40 fps in game), thought I’ve notice my ping can be high some times. I suspect the performance depends quite heavily on wine. It would be nice to see how much different the game would be if it was installed on my host, and on real Windows on my machine.
I am considering to add this as a docker. It could be a future project.
GL HF noob.