Running HassOS as an LXD/LXC virtual machine

Try adding your usb device like this:

lxc config device add homeassistant ttyusb unix-char path=/dev/ttyACM0

Figured its much simplier to just run Hass OS ā€¦ and the Portainer Addon for my purposes.

Whenever I need anything I can simply pull the Image from Dockerhub and create an Container easily besides Homeassistant on the same Host.

Messing with LXD was a nice try but far from stable / complete ā€¦ Homeassistant is moving much to fast for that so itā€™s best to stick as close to their supported installations I guess.

Iā€™d use their VM-Images next time instead If Iā€™d want to run it on something more powerfull.

I got Home Assistant OS running in LXD without too much difficulty, and wrote up my notes here:

Hopefully thatā€™s of help to anyone who finds this thread looking for a guide.

2 Likes

Very nice! I actually asked about this a month back and @tteck (famous for his proxmox setup repo) told me it was technically impossible, so I gave up and put HASS in a VM. I donā€™t see why LXD would be materially different than Proxmoxā€™s implementation of base lxc.

You didnā€™t set that stuff up, but I see no reason why USB passthrough and nested docker (HASS OS ā€œaddonsā€ are actually docker containers) wouldnā€™t work too.

Edit: Nevermind, youā€™re running a VM, not a container. Womp womp.

1 Like

Iā€™ve updated the title of the blog post to hopefully avoid future container vs VM confusion.

1 Like

Totally my fault, you did say VM. I keep forgetting LXD does both lxc and VMs now. Used to run it myself before I moved to proxmox.

hey!
I am begginer in System Containers world and coming here with concept that I believe many of you been already thinking about, this is:

  • would make it sens to run HAOS inside LXC (System Container)? or it is even not possible/highly not recommended?

Simple saying, I like characteristic that LXC does require less resourcess.

This worked really well for me, despite my having no lxd experience.

My challenge now is that HA only has a bridged (NAT) network connection, and lxd wonā€™t allow port forwarding to VMs.

Does anyone have any suggestions? I feel like Iā€™m missing something.

Do you mean you want to forward a port from your router to HA for external access? If so, all I think you need is for the HA VM to have its own IP address on your LAN, and the rest is a question of configuring your router. If the HA VM has a bridged-mode network connection, then it should have received its own IP address. I understand bridged-mode and NAT as being mutually exclusive - you are using either one or the other, not both.

Thanks Sean, I wasnā€™t at all clear enough in my question.

What I meant is that I want my lxd vm of haos to be visibly externally on the network so I can get to the web page from other machines, and I suspect it will help with device discovery.

Currently my VM has network access but only through the lxd bridge which does NAT to get out onto the network. It thus has an IP address that falls within the range allocated to the lxd controlled network, but is not visible outside the host it is running on.

The way Iā€™d imagined making my haos VM visible on the network was to port forward the host machine ports to haos instance, but this apparently isnā€™t possible because the instance is a VM. This seems to be a limitation of lxd.

I suspect now my options are

  1. to use macvlan to give one of my hostā€™s network adapters 2 IP addresses, but this requires the rest of the network equipment to accept promiscuousness.
  2. to dedicate the wifi device to the haos instance

Iā€™m hoping thereā€™s a better option though, and imagined that someone else may have solved this problem already.

Thanks again for your help, and for the great instructions for getting this far.

I donā€™t think we are on the same page regarding bridge mode vs NAT. I have HAOS running in an LXD VM that has got a real LAN IP address (10.0.0.206 as you can see in the screenshot in my blog post) via DHCP from my router. I did this by configuring bridge mode networking. There is no NAT happening in LXD or on the server itā€™s running on, i.e., every container and VM gets its own IP address on the LAN.

I split out the steps I took to get bridge mode networking set up into its own blog post. Thereā€™s a link in the blog post above, but hereā€™s the direct link:

The first part covers covers configuring bridge networking as an alternative to macvlan.

Is that of any help?

Thanks Sean. I think youā€™re right, thereā€™s something Iā€™m not understanding about the lxd networking process, as my VM is only getting internal (lxd managed) IP addresses, and isnā€™t visible to my router. Iā€™ll have a look at the link you sent.

Much appreciated