[Guide] Hass.IO on Windows 10 WSL2 (No more VMs!)

Is there any news to this working with USB devices?

@MongooseMan I have and I fixed it. This, unfortunately, won’t be fixed by the community as WLS2 is not supported. You need to take care of it yourself. Let me know if you want detailed instruction on how to fix it.

@aryankids , thanks, I’d appreciate that.

@MongooseMan The problem resides at this specific IF in a shell script:

       if [[ -d "${directory}" ]]; then
           return "${__BASHIO_EXIT_OK}"
       fi

As you can see the ‘if’ tries to determine whether the ‘directory’ exists or not. However, as you rightly mentioned above on WSL2 (or better said Ubuntu) the /dev/shm is NOT a directory and is a symlink thus the above if fails and causes the issue. Whilst expanding the IF above can fix the issue, as WSL2, and in particular, Ubuntu is not supported by HA, we cannot expect the support team to do that for us hence the commands below.

We need to change that symlink in the filesystem as follows.
N.B. These commands executed on Ubuntu 20.04:

#let’s find out how the directory linked 
cd /dev
ls -la  s*
lrwxrwxrwx 1 root root     8 Feb 10 23:10 /dev/shm -> /run/shm
lrwxrwxrwx 1 root root    15 Feb 10 23:10 /dev/stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root    15 Feb 10 23:10 /dev/stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root    15 Feb 10 23:10 /dev/stdout -> /proc/self/fd/1

In our case the /dev/shm is linked to /run/shm
so let’s see what we have got there:

ls -la  /run/shm 

drwxrwxrwt  3 root root  60 Feb 10 23:10 .
drwxr-xr-x 28 root root 920 Feb 13 08:53 ..
drwx------  4 root root 100 Feb 11 15:00 multipath

in my case I have only one directory there (multipath), you might have more, make sure to note them all.

# You need to run these commands as root so be ultra_careful
# rename the symlink 
sudo mv shm shm..hold

#  create a proper directory and give it proper rights
sudo mkdir shm
sudo chmod 777 shm
cd shm

# create the symlink for the directory within the shm (repeat the command for all directors you have noted above in /run/shm (if there are more ))

sudo ln -fs /run/shm/multipath /dev/shm/multipath
sudo ln -fs /run/shm/THE_SECOND_DIRECTORY /dev/shm/THE_SECOND_DIRECTORY

and that would be it. Now the /dev/shm is a proper directory, its integrity within the OS remained the same and should pass the ‘if’ above in that shell script. All your add-ons should upgrade now.

1 Like

Look
At
That
:slight_smile:

Thanks! Worked like a charm

1 Like

Where USB serial on WSL 2 is concerned, it is possible, but only via a moderately bizarre workaround.

You can’t share USB serial devices into WSL as devices currently, since the WSL pseudo-VM doesn’t support that. But what you can do is make use of a rather obscure service called USB/IP, which lets you connect to remote USB devices over an IP network as if they were local USB devices, and you can get IP into and out of WSL, obviously.

The first step is the bit I haven’t done, because I was using a remote Linux machine when I did this - but there’s no technical reason why you couldn’t share a USB device from the Windows host. There’s a Windows USB/IP server and instructions on how to set it up and share a device here:

cezanne/usbip-win: USB/IP for Windows (github.com)

Then you need a WSL 2 kernel that includes the USB/IP driver or loadable modules (for most serial widgets like Zigbee transceivers, those would be “usb_common”, “usbcore”, “usbip_core”, “usbserial”, and “ftdi_sio”. This means compiling yourself a custom kernel, or if you don’t want to do that and don’t care that it also has lots of extra stuff too, you can always grab mine. (Don’t forget that just installing the packages just sets it up in Linux; you’ll still need to copy it somewhere Windows can see it and edit .wslconfig!)

Having done all of that, set up the Windows server, started WSL running with your new kernel, and sudo modprobed in the modules you need, you should be able to install the usbip tools (using your distro’s package manager), and then run:

usbip list -r <server>

where server is the IP address of the Windows host, and get a list of the exported USB devices by bus ID, and then use:

usbip attach -r <server> -b <bus id>

to connect to them.

At which point you should be able to do whatever you wanted the USB device for in the first place!

(And pour yourself a drink. If you got here, you probably deserve it.)

2 Likes

can’t connect to Homkit. anyone knows?
maybe it needs -net=host option when starting docker image… but how i can do it?

  • solved: it was only a low memory problem. Setting 3GB to WSL (changing /.wslconfig) did the trick
    Hi, I was able to install HA in WSL2 and I played with it for some days. Now it seems broken and I got “Unable to connect to Home Assistant.”. No errors on logs (either ha core logs and ha supervisor log). What it seems changed is that previously ifconfig showed some vethXXXXXX: entry, now none.
    dmesg says
[31105.099892] device vethcb6e9a7 entered promiscuous mode
[31105.829342] eth0: renamed from vethc264c92
[31105.829787] IPv6: ADDRCONF(NETDEV_CHANGE): vethcb6e9a7: link becomes ready
[31105.829870] hassio: port 5(vethcb6e9a7) entered blocking state
[31105.829873] hassio: port 5(vethcb6e9a7) entered forwarding state

I tried to clear docker packages and reinstall all. Any idea on how to troubleshoot this? Thanks in advance!

Just a note for anyone trying to use knx virtual with HA.Install HA core on windows (no vm, no wsl) just straight Python. Configure KNX using 127.0.0.1. It works, some knx timeout errors on log is normal. Obviously you cannot use addons, so when you’re done with your testing, go back to HASS.IO.

The link to the translinux script doesn’t work anymore (https://packagecloud.io/install/repositories/arkane-systems/wsl-translinux/script.deb.sh). Can you update the guide? I’m anxious to get started.

I was able to install Genie using the guides in GitHub. However bash installer.sh gives me an error: missing: network-manager docker jq

Hi MichaH77!

I was wondering what you did to get genie installed from github and if you ever found the resolution for the installer.sh? I’m on the step you must posted.

curl -s https://packagecloud.io/install/repositories/arkane-systems/wsl-translinux/script.deb.sh | sudo bash
bash: line 1: syntax error near unexpected token newline' bash: line 1:

Hey guys,
I’ll be updating this guide in the coming days (hopefully tomorrow) and make sure everything here works properly.

Tested and updated the guide, everything should be working now.

1 Like

The setup script https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh doesn’t seem to be available anymore. Is there a new location to get the installer script?

It is replaced by a .deb file.

I’m guessing this is the replacement installer step?


wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb

1 Like

Yup
Updated the guide and added hyperlink to the official installation page as well

Hey @cerebrate hope I’m not too late to the party on this one.

I am trying to access a Wyze Sense dongle in WLS, but don’t seem to be able to do so. Would it be possible for you to help with more precise instructions on how to compile your kernel?

I would really like to get this up and running on my server PC so I can finally retire my NUC running Ubuntu server.

Currently I can see the device on /dev/ttyS2 using usbipd, but I don’t seem to have serial hidraw access as I would on Ubuntu server.

If there is a way I can contact you for help I’d really appreciate it - perhaps I could help write an article to help other in the future as well.

Hi everyone,
I’ve been poking around with WSL2 since it’s release and i’m not sure why it’s not possible to just load Home assistant OS as a linux distro in WSL.

Someone (smarter than me) would even be able to list Home assistant in the microsoft store just as the existing linux distros. Unless there is some obvious limitation that i don’t know about?

USB passthrough works, networking works although a bit hacky.

but allinall it seems to me that hassos on wsl2 would be the easiest way to enable the HA recommended install version on windows.
Maybe provide a suitable .tar that noobs like me could import and get running with some googling…

what am i missing?
i’lll try to just make a TAR backup of my current virtualbox’ed HASSOS and wsl --import it to see what happens. but it feels like i’ve missed some major hurdle in doing so

1 Like