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

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

Hi There,

I am not an expert on the topic as well, but recently I have digged down into the topic. I would also be happy to have Hassio with supervisor under WSL on my Win 11 home pc As I am using it for several other functions switched on 24/7.

I have find HASSWP as a partial solution (GitHub - AlexxIT/HassWP: Portable version of Home Assistant for Windows (no need to install)), but beside it runs smooth it has its limitations and difficulties (eg,presence sensing does not works properly and has no supervisor, etc…)

I just find this project recently which may allow to pull HA from docker to WSL (GitHub - redcode-labs/easyWSL: Use Docker Containers as WSL Distros) - or am I wrong with this ?

I do beleive many more user can be easily pulled under Hassio if it can run “natively” on WSL as a simplesolution. An expert comment would be warmly welcomed on the above.

1 Like

I actually tried easywsl just because “why not” right? (and it was really easy to use btw)
i chose a docker with homeassistant os for linux(x86/64).

and although it creates the wsl instance fine, and i can start it without any errors, it doesn’t seem to start correctly. debugging that isn’t exactly easy as i get no real info in the console

This setup work nicely, the only problem is AppArmor… WSL2 dosn’t start it…


4a52f322d5fe1582aa5795e2ad3f917b0cefb483

Did you install this using the guide ”supervised on linux” or did you start with an image or docker container?

I tried the installation like 2 years+ later and I see that, despite is still working it’s asking for a lot of things regarding GRUB that you have not covered in this guide.

I did install grub2-common in a WSL2 machine which makes 0 sense, and then it worked fine. I’m not certain why anyone encountered this issue before.

I recently used my own guide and verified everything is still working and had nothing to do with grub so I’m unsure why you encountered that problem.

1 Like

I must have done something different at some point (maybe the Ubuntu installation) because I also had to install OS Agent which is not in the guide neither.

1 Like

Could this not be related to the newly released Home assistant OS v8? I see the changelog makes mentions of grub: Home Assistant OS Release 8 - Home Assistant

Maybe. This could make sense on what happened. I simply install grub common and it workd but it was pretty strange because I was not going to do use of it.

1 Like

I am already using WSL2 on Win11
Ubuntu 20.04.4 LTS
I have a working Docker Container as you can see below

root@Office-PC-wsl:/home/moistdreams# sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

I got as far as installing Home Assistant OS and ran into the same issue when running

dpkg -i homeassistant-supervised.deb

Which just spits out

root@Office-PC-wsl:/home/moistdreams# dpkg -i homeassistant-supervised.deb
(Reading database ... 40027 files and directories currently installed.)
Preparing to unpack homeassistant-supervised.deb ...
[warn]
[warn] If you want more control over your own system, run
[warn] Home Assistant as a VM or run Home Assistant Core
[warn] via a Docker container.
[warn]
[warn] ModemManager service is enabled. This might cause issue when using serial devices.
Leaving 'diversion of /etc/NetworkManager/NetworkManager.conf to /etc/NetworkManager/NetworkManager.conf.real by homeassistant-supervised'
Leaving 'diversion of /etc/NetworkManager/system-connections/default to /etc/NetworkManager/system-connections/default.real by homeassistant-supervised'
Leaving 'diversion of /etc/docker/daemon.json to /etc/docker/daemon.json.real by homeassistant-supervised'
Leaving 'diversion of /etc/network/interfaces to /etc/network/interfaces.real by homeassistant-supervised'
Unpacking homeassistant-supervised (1.2.0) over (1.2.0) ...
dpkg: dependency problems prevent configuration of homeassistant-supervised:
 homeassistant-supervised depends on os-agent; however:
  Package os-agent is not installed.

dpkg: error processing package homeassistant-supervised (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 homeassistant-supervised

This is directly related to a missing os-agent and I am now trying to figure out how to install that.

Doing some inspection I can verify that everything else exists dependency wise

root@Office-PC-wsl:/home/moistdreams# sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 homeassistant-supervised : Depends: os-agent but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
root@Office-PC-wsl:/home/moistdreams# sudo apt update
Hit:1 https://arkane-systems.github.io/wsl-transdebian/apt focal InRelease
Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
Hit:3 https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
root@Office-PC-wsl:/home/moistdreams#

Something tells me I need this package Screenshot 2022-06-02 231614|260x35

as my system is AMD Ryzen 5900X Windows obviously WLS2. I decided to go the supervised route for my first-time test of home assistant because I don’t want to load and run Hyper-V and I already have WSL2 Ubuntu so may as well just run the OS in that right natively.

In future, I will be installing to a raspi4 or a dedicated PC/ server but for now, I am just using my production machine because it’s beefy enough to run this in the background easy.

EDIT
Okay I think I may be progressing -

root@Office-PC-wsl:/home/moistdreams# sudo dpkg -i os-agent_1.2.2_linux_x86_64.deb
Selecting previously unselected package os-agent.
(Reading database ... 40027 files and directories currently installed.)
Preparing to unpack os-agent_1.2.2_linux_x86_64.deb ...
Unpacking os-agent (1.2.2) ...
Setting up os-agent (1.2.2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/haos-agent.service → /lib/systemd/system/haos-agent.service.
Processing triggers for dbus (1.12.16-2ubuntu2.2) ...
root@Office-PC-wsl:/home/moistdreams#

For those wondering you will need to actually put your package where it can be loaded -


Where Moistdreams is replaced by your own Linux User. Then you run the instructions from the github to install package.

Alright that seemed to work the os-agent is now installed
Awesome I fixed it

root@Office-PC-wsl:/home/moistdreams# genie -b
inside
root@Office-PC-wsl:/home/moistdreams# dpkg -i homeassistant-supervised.deb
(Reading database ... 40030 files and directories currently installed.)
Preparing to unpack homeassistant-supervised.deb ...
[warn]
[warn] If you want more control over your own system, run
[warn] Home Assistant as a VM or run Home Assistant Core
[warn] via a Docker container.
[warn]
[warn] ModemManager service is enabled. This might cause issue when using serial devices.
Leaving 'diversion of /etc/NetworkManager/NetworkManager.conf to /etc/NetworkManager/NetworkManager.conf.real by homeassistant-supervised'
Leaving 'diversion of /etc/NetworkManager/system-connections/default to /etc/NetworkManager/system-connections/default.real by homeassistant-supervised'
Leaving 'diversion of /etc/docker/daemon.json to /etc/docker/daemon.json.real by homeassistant-supervised'
Leaving 'diversion of /etc/network/interfaces to /etc/network/interfaces.real by homeassistant-supervised'
Unpacking homeassistant-supervised (1.2.0) over (1.2.0) ...
Setting up homeassistant-supervised (1.2.0) ...
[info] Restarting NetworkManager
[info] Restarting docker service
PING version.home-assistant.io (172.67.68.90) 56(84) bytes of data.
64 bytes from 172.67.68.90: icmp_seq=1 ttl=59 time=23.3 ms

--- version.home-assistant.io ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 23.286/23.286/23.286/0.000 ms
[info] Install supervisor startup scripts
[info] Install AppArmor scripts
[info] Start Home Assistant Supervised
[info] Installing the 'ha' cli
[warn] Could not find /etc/default/grub or /boot/cmdline.txt failed to switch to cgroup v1
[info] Within a few minutes you will be able to reach Home Assistant at:
[info] http://homeassistant.local:8123 or using the IP address of your
[info] machine: http://172.25.255.44:8123
[warn] A reboot is required to apply changes to grub.
root@Office-PC-wsl:/home/moistdreams#

However, it appears to not be running I got as far as making the ps1 script and made the task scheduler to work out accessing outside of local systems.

However, I cannot even access the front-end on the localhost.
Within a few minutes, you’ll be able to access HA on localhost:8123 does not do anything and just tells unable to resolve the address when trying to load it in Microsoft Edge.

moistdreams@Office-PC-wsl:~$ sudo docker container ls
CONTAINER ID   IMAGE                                                   COMMAND   CREATED          STATUS          PORTS     NAMES
58807066af82   ghcr.io/home-assistant/amd64-hassio-supervisor:latest   "/init"   53 minutes ago   Up 29 minutes             hassio_supervisor

For reference, you can now Bridge WSL2 to your primary network no more port forwarding needed.

As a note some hiccups i ran into.

  1. Make sure your running windows insider preview as you need WSL 0.60+ I believe
  2. Use WSL-Preview from the store.
  3. Install ubuntu from the WSL not the store (I kept installing from the store and it kept not passing traffic to the bridge, I used WSL --install Ubuntu-20.04 and that worked great)

Regards,
Chris

Cheers for the guide @nirkons

I managed to get it going on my ancient i7

Installed Ubunto-20.04 LTS from WSL directly

Ubuntu-20.04 --> uname -srvmpio ---> Linux 5.10.102.1-microsoft-standard-WSL2 #1 
SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Early Generation i7 CPU (No Win 11)
Edition	Windows 10 Home
Version	21H2
Installed on	‎13/‎09/‎2020
OS build	19044.1865
powershell wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2

Windows Subsystem for Linux was last updated on 26/03/2022
WSL automatic updates are on.

Kernel version: 5.10.102.1

Guide updates below

I got stuck a few times so ended up switching between versions of Ubunto and Unbunto-20.04 either from the store or directly from WSL. I ended up with Ubunto-20.04, but Ubunto probably would have worked if I had ran your script from post one.

I also tried Debian… It worked up until docker-ce installation. Not sure why docker-ce was having a fit, but I couldn’t get it to start or stay started it was stuck 33% install. your guide works well enough for a Debian install. you just need the Debian dotnet

Genio install is the same for Deb or Ubuntu

OS-Agent is mentioned about halfway through this topic. It is missing part of the explanation.

OS-agent – inside genie while sudo su

wget https://github.com/home-assistant/os-agent/releases/download/1.2.2/os-agent_1.2.2_linux_x86_64.deb

sudo dpkg -i os-agent_1.2.2_linux_x86_64.deb

sudo apt-get install grub2-common 

It will still complain about the missing grub conf, but starts anyway.

Troubleshooting tips for

systemd is in degraded state —
I was having mount issues in particular after terminating Ubunto via WSLfor restarts.

needs to be
genio --login + sudo
systemctl --failed <--- to check what has failed

systemctl reset-failed <---- to reset what has failed

systemctl set-default multi-user.target <— this didn’t hurt
genie multi-user.target FAQ

Regarding the powershell script and my biggest issue was DNS.
My HA install was stopping right after dpkg -i homeassistant-supervised.deb
and the network-manager wasn’t DNS resolving. Supervisor was just re-attempting downloads( I had portainer logs of supervisor). I could still ping IP google, but not ping www.google.com.

It’s not clear to me if the static IP 0.0.0.0 part is needed or which IP it should be in the script
Does it it get auto filled or ignored if it remains 0.0.0.0?
I ended up filling it with the WSL IP. Although I don’t know if thats what fixed my issue or if it was just a coincidence or running the script directly through ADMIN powershell ./hassWSL.ps1. I had it in running in task scheduler the entire time. I am not sure if it actually ever triggered(I use simple logon for windows)

Anyway on to USB on win 10 home hopefully I can figure that out. The Post just before mine has Win 11 limitations for USB

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
$ports=@(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";
}
1 Like

Here is an up to date guide I created for myself to get Home Assistant up and running on a Windows Machine with WSL2, because I sometimes found information from previous posts outdated, too cumbersome, too poorly explained or overly complicated.

UPDATE: this is apparently not Supervised, so you cannot add add-ons.
If anyone knows if its possible to install Home Assistant Supervised simply via snap install then please let me know, because I find that the easiest way to install. But the part in this guide to have systemd / apparmor running in wsl2 and the part to reach your home assistant from other devices in your network are valid for any version of Home Assistant via wsl2.

  • Make sure Windows Subsystem for Linux is enabled on your windows machine.
  • Download and install latest Ubuntu from the Microsoft Store. In my case at time of writing that was not ‘Ubuntu’ but instead ‘Ubuntu 22.04.1 LTS’
  • Make sure your WSL version is 0.67.6 or higher. Check your version with (via command prompt or powershell):
wsl --version`

you could update your wsl version with (via command prompt or powershell):

wsl --update

If your version is high enough, I think you also need “Windows Subsystem for Linux Preview” which you can find in the Microsoft store.

If your ubuntu is installed, you can open it as a program: Click the Start button and start typing ‘ubuntu’ and open the ‘ubuntu’ app.
You are now in a terminal window inside your ubuntu distro

Now we will enable systemd first. In the ubuntu terminal, type:

sudo nano /etc/wsl.conf

Its probably empty, paste these 2 lines of code in there:

[boot]
systemd=true

Save with CTRL+O, exit with CTRL+X

close your ubuntu window

Inside windows: close wsl via this command in PowerShell:

wsl.exe --shutdown

Then open your uvuntu again. Type this command in the terminal:

systemctl list-unit-files --type=service

You should see the services like AppArmor and Snap working now, which we will need for a good working installation of home assistant.
Close the information with ‘:’ and then ‘q’

In the ubuntu terminal we can now easily install Home Assistant via the command:

sudo snap install home-assistant-snap

HOME ASSISTANT INSTALLATION DONE !

in your windows you should be able to access your Home Assistant via:

http://localhost:8123/

To connect via the IP address of your Windows pc from other devices in your network to home assistant:
Open the ubuntu terminal and type this command to see ubuntu’s IP address:

cat /etc/resolv.conf

Copy that IP address, we will need it.

In your windows, in powershell enter this command:

netsh interface portproxy add v4tov4 listenport=8123 listenaddress=0.0.0.0 connectport=8123 connectaddress=YOUR.UBUNTU.IP.ADDRESS

Now enter this command:

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8123 connectaddress=localhost connectport=8123

Now enter this command to add a firewall rule:

netsh advfirewall firewall add rule name= "Open Port 8123" dir=in action=allow protocol=TCP localport=8123

HOME ASSISTANT REMOTE ACCESS DONE (via local network)

Now you should be able to connect via other computers on your network to the windows computer that has wsl2/home assistant via the windows computers ip address:

http://your.windows.ip.address:8123