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

Been waiting for this for quite a while so now that I got it working I thought I’d share with you guys if anyone else is interested in doing this.

Basically this is HASS.IO running on Docker in Windows 10 WSL2 (Note that currently you need to be a windows 10 insider, though its estimated that sometime this year WSL2 will be released to the general public)

  • Become a Windows 10 Insider (SLOW RING Recommended):

Open start and search for ‘Windows Insider’ (If you don’t have Diagnostics set to full it will link you to set it first), sign up/link account, restart PC and search for windows updates and let it update to the latest Windows 10 insider build.

Open PowerShell as Administrator and run
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart your computer when prompted.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart computer to apply changes

Open PowerShell as Administrator and run:
wsl --set-default-version 2
Keep PowerShell open

Open the Microsoft Store and install Ubuntu, launch it and let it install, it will prompt to set a username and password.

Verify ubuntu is using WSL2 via the Powershell from before using
wsl --list --verbose or wsl -l -v

Run sudo apt-get update in Ubuntu

For Ubuntu 18.04:

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

For Ubuntu 19.04:

wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

For Ubuntu 20.04 (This appears to be the version that is installed from the store currently for “Ubuntu” but at the time of writing (May 1st,2020) this appears to be broken and will require a workaround)

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

The rest should be the same for all of them

sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-runtime-3.1
curl -s https://packagecloud.io/install/repositories/arkane-systems/wsl-translinux/script.deb.sh | sudo bash
sudo apt install systemd-genie

System restart might be needed, try running genie -s in ubuntu terminal, if you get an error run genie -c bash

Docker CE instructions here: https://docs.docker.com/install/linux/docker-ce/ubuntu/
apt-get install the rest of the dependencies:

bash
jq
curl
avahi-daemon
dbus
apparmor-utils
network-manager

Run as root (sudo su)
curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m qemux86-64

Within a few minutes you’ll be able to access HASS.IO on localhost:8123

  • Networking & Starting with Windows

Unfortunately, WSL2 does not yet support bridged networking

So in order to be able to access HASS from outside the local machine we’ll need to run this workaround script at startup, it will also run HASS with the “genie -i” command.

Save this script somewhere on your PC with a .ps1 ending, note that you can add/remove/edit the ports you want forwarded from WSL

bash.exe -c "genie -i"
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';

if( $found ){
  $remoteport = $matches[0];
} else{
  echo "The Script Exited, the ip address of WSL 2 cannot be found";
  exit;
}

#[Ports]

#All the ports you want to forward separated by coma
[email protected](80,443,8123,1880,1883,1884,8883,8884);


#[Static ip]
#You can change the addr to your ip config to listen to a specific address
$addr='0.0.0.0';
$ports_a = $ports -join ",";


#Remove Firewall Exception Rules
iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' ";

#adding Exception Rules for inbound and outbound Rules
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP";
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP";

for( $i = 0; $i -lt $ports.length; $i++ ){
  $port = $ports[$i];
  iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr";
  iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport";
}

Open Task Scheduler and add click “Create Task”
Under General - “Check run whether user is logged in or not” and “Run with the highest privileges”
Under triggers click New, Begin the task at logon of any user
Under Actions click New, Select Start a program and type in program/script ‘Powershell.exe’
in arguments type ‘-ExecutionPolicy Bypass c:\Users\User\hass.ps1’
(Change the path to your saved script file)

(Optional: Under settings you can check “if the task fails, restart every X minutes” if you’re having issues)

hit OK.

  • Power options - Set sleep to Never
  • If you want your user to autologin -> open start -> Run, type ‘control userpasswords2’ and uncheck “Users must enter a name and password to use this computer”
9 Likes

I’ve been meaning to try this install method. Thanks for the info!

1 Like

I already had Ubuntu 18.04 installed before I followed your directions to get WSL 2 installed. When I check I get this:

PS C:\WINDOWS\system32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         1

So I found out how to “move” Ubuntu onto WSL2:

PS C:\WINDOWS\system32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         1
PS C:\WINDOWS\system32> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)
PS C:\WINDOWS\system32> wsl --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

followed all the instructions and had it up and running without issues. Per your email on reddit, i went into configurator and tried to upload a backup file. Wouldn’t go. I then uploaded the individual files from my main instance and rebooted. Now it hangs. Gets to an Onboarding screen partially but never completely loads. Any ideas?

It takes a while to upload via configurator but works eventually.
but anyway with the latest version of home assistant released today, that should no longer happen to you as it will boot into the new “safe mode”.

The complicated solution would be to check the docker log and then fix your config via shell commands, but the easier way would be just to try to uninstall and reinstall hassio (you can probably search google/these forums on how to reinstall docker hassio)

Thanks for the guide! I’ve installed and started HassIO succesfully.
But unfortunatelly it’s pretty much unusable for me, since I can’t attach my USB-to-Serial and USB-to-Bluetooth adapters I need to read my sensors.
I could not find any method of reaching this. Such a shame, I was really looking to a working solution to have HassIO run under Windows without a VM.

Hey, I’m in the same boat actually.
There is a solution however I did not try it because it seems quite complex and time consuming.

If you want you can give it a try

1 Like

I also saw that, but haven’t got the nerve to try it, for the exact reasons as yours.

For those interested, WSL2 is scheduled to be released in the 2004 update.

I got this far flying blind, mostly, but I need help. “Can’t locate package systmd-genie”

Any help? Thanks

Installed.

Thanks anyway.

How did you solve "“Can’t locate package systmd-genie” as I am stuck :pensive:

Each one of these lines from OP worked for me:

A) wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-
B) sudo dpkg -i packages-microsoft-prod.deb …
C) sudo apt-get update …
D) sudo apt-get install apt-transport-https …
E) sudo apt-get update …
F) sudo apt-get install dotnet-runtime-3.1 …
G) curl -s https://packagecloud.io/install/repositories/arkane-syste
H) sudo apt install systemd-genie …

To answer your question, I couldn’t get “H) sudo apt install systemd-genie” to complete because I forgot to run “G) curl -s https://packagecloud.io/install/repo…” first! Dumb me.

This is as far as I got - A) through h). Had to do some day-job stuff, but I’ll get back to it later today. We can stay in touch. A couple of things:

  1. I tried many times to go through OP’s steps. At one point, I would get “the package has been installed more than one time.” Frustrated, I would clear (erase, remove) the whole installation and start over. If I made a mistake, I would start over again. So …

  2. I had to learn how to reset and start over. But going through all the steps again, well, that took too much work.

  3. I finally learned how to back up and restore so that I can go backwards and start again, >from the last good point<.

  4. FINALLY, most important, I substituted Ubuntu 18.04 for OP’s 19.04.
    Just change 19.04 to 18.04. That solved most problems.

Are you doing all of this in Windows 10 Hypervisor?
I am. I did go to Microsoft Insider, and am running Windows 10 Version 2004.

My next task, according to OP, is to do:
" Run sudo su [install dependencies and HASS.io ] (https://github.com/home-assistant/hassio-installer). Film at 11 as they once said…

Here are steps to backup and restore so that you don’t have to start all over:

In PowerShell:
wsl --export Ubuntu-18.04 ubuntu2020APR27-2206.tar
My file ended up in C:\Windows\System32

To restore, in PowerShell
wsl --import distro_name install_location file_name.tar

I haven’t needed to restore yet because I am good up to the install dependencies thing. But I feel much more secure as I now know how to backup and restore (to last good point).

If you want, I can post a text file with every step done so far with lots of comments and some words of frustration. Just ask.

If readers catch something wrong here, please reply.

Still half a month away of the official release of Windows 2004. I’m waiting…

Hey,

I think its because MS store has two versions (confusing without a doubt)
image
and you selected 18.04 so that’s why, but it should work I guess with the correct packages.

edit: I updated the guide regarding the ubuntu/ubuntu 18.04 mixup

Not that far away :slight_smile:
I’ll update the guide once its released to the public and remove the parts about the insider requirement

Hello Nirkons, thanks for chiming in. I am about to continue downwards in your guide. This is what I need to do next:

     Run  `sudo su`  and [install dependencies and HASS.io ]
        (https://github.com/home-assistant/hassio-installer)

Clicking on the “dependencies” link takes me to >github home-assistant / supervised-installer<

Can you tell me, us exactly what is the command line to do this? Oops, sorry. I went to “files” and see this command line:

‘curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s’

I shall try this command line and see what happens, unless you or somebody stops me from doing this.

OK, >>IF<< the above command line works, the next action is, per your guide:

'Docker CE instructions here: https://docs.docker.com/install/linux/docker-ce/ubuntu/

At https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
I see this action:

$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <[email protected]>
sub   rsa4096 2017-02-22 [S]
Use the following command to set up the  **stable**  repository. ...

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
INSTALL DOCKER ENGINE
Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

 $ sudo apt-get update
 $ sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify that Docker Engine is installed correctly by running the hello-world image.

$ sudo docker run hello-world

OK. IF ALL THIS WORKS, … your next step is:
apt-get install the rest of the dependencies:

bash
jq
curl
avahi-daemon
dbus
apparmor-utils
network-manager

Can you suggest command lines to install the above dependencies? Or suggest a command line to check if I already have these dependencies?

FINALLY, I shall run:
Run as root (sudo su)
curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m qemux86-64

Wish me luck.

I’ve been running Windows !0 Version 2004 without a single problem for three weeks. Everything I had in my previous Windows 10 version EXCEPT “BackBlaze on-line backup” runs the same or faster. But going to 2004 is, of course, a decision others must make.

I think I’ll stop asking you for help and see if I can get Hass.IO running. Thanks for all your help.

Hey,

Maybe my guide is a bit misunderstood but I think the only thing you need from outside this thread is the docker installation, everything else should be on this page.

regarding the dependencies, you can probably run everything as one command with spaces

sudo apt-get install bash jq curl avahi-daemon dbus apparmor-utils network-manager

everything else seems about right, good luck

Not true, I would be nowhere without the guide.
Maybe you can help here. When installing docker, two parts:

Setting up cgroupfs-mount invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel

Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
invoke-rc.d: could not determine current runlevel

I tried to find answers, found an answer that said this is OK

Therefore I continued your guide …

sudo docker run hello-world
Docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
docker --version
Docker version 19.03.8, build afacb8b7f0
sudo service docker status
[sudo] password for mike:

  • Docker is not running
    sudo service docker start
    [ OK ]
    sudo service docker status
  • Docker is running

At this point, I went ahead in did a one line install, as you recommended, of
sudo apt-get install bash jq curl avahi-daemon dbus apparmor-utils network-manager

There was quite a bit of activity, maybe 100+ lines of
Get, Selecting, Preparing, Unpacking, Setting Up, Created,

Until
Setting up avahi-daemon
invoke-rc.d: could not determine current runlevel

  • Reloading system message bus config…
    Failed to open connection to “system” message bus:
    Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    invoke-rc.d: initscript dbus, action “force-reload” failed.

This happened three times.

This is where I am at. I will research these errors, but any help appreciated, Thank you!

Hey,

are you sure you are running everything inside genie like in the guide

system restart might be needed, try running genie -s in ubuntu terminal, if you get an error run genie -c bash`

Also when are you seeing these errors, the docker install is pretty straightforward:

$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

 $ sudo apt-get update
 $ sudo apt-get install docker-ce docker-ce-cli containerd.io