Home Assistant Community

Set up Hass.io on top of a virtual machine

#1

The images for the Raspberry Pi family and the Intel NUC are an easy way to get started with Hass.io. For a test or if you have a system which is already hosting virtual machines then the Hass.io installer is an option to use Hass.io in a virtualized environment. In this guide the host is a Fedora 27 system with libvirt support and the guest will be running Debian 9. Hass.io will be installed on the guest.

Assuming that you already have setup libvirtd. You might need to install virt-builder and virt-viewer additionally.

$ sudo dnf -y install libguestfs-tools-c virt-install virt-viewer

We will create a virtual machine with Debian 9 and a 10 GB disk image in the QCOW format. Use $ virt-builder --list to get an overview about what’s operating systems are available if you prefer to use a different system.

$ sudo virt-builder debian-9 \
    --output /var/lib/libvirt/images/hassio.img \
    --format qcow2 \
    --size 10G \
    --root-password password:test123 \
    --hostname hassio \
    --firstboot-command "dpkg-reconfigure openssh-server"
[...]
[ 147.6] Finishing off
                   Output file: /var/lib/libvirt/images/hassio.img
                   Output size: 10.0G
                 Output format: qcow2
            Total usable space: 9.3G
                    Free space: 8.1G (87%)

Now, we are making our new virtual machine available for libvirtd. If you get an error that the OS is unknown, use $ osinfo-query os to get the name to use with --os-variant. To access the virtual machine is connected to the bridge bridge0.

$ sudo virt-install --name hassio --import --ram 1024 \
     --os-variant debian9 -w bridge=bridge0 \
     --autostart --disk /var/lib/libvirt/images/hassio.img

Hass.io virtual machine in Virtual Machine Manager

Depending on your preferences you can use the Virtual Machine Manager (virt-manager) or virsh to manage the created virtual machine. Log in and create an user with # useradd ha and set a password with # passwd ha. We will need that user to make a SSH connection to the virtual machine.

Log in as ha with the given password. If your are using the default network of libvirtd then the DHCP range is defined in /var/lib/libvirt/dnsmasq/default.conf. In this guide the virtual machine is present at 192.168.0.109.

Install the requirements after you switch the user to root.

We want the latest Docker release. This requires additional steps to set it up as unlike other distributions Debian is lacking behind with current packages.

Now, it’s possible to install a current release of Docker.

Start docker and enable it.

An installation script will take care about the setup of all moving parts.

[email protected]:/home/ha# curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -
[INFO] Install supervisor docker
[INFO] Install generic HostControl
[INFO] Install startup scripts
[INFO] Init systemd
Created symlink /etc/systemd/system/multi-user.target.wants/hassio-supervisor.service → /etc/systemd/system/hassio-supervisor.service.
[INFO] Start services

If it’s done, then there will be two new containers.

[email protected]:/home/ha# docker ps
CONTAINER ID        IMAGE                                    COMMAND                  CREATED             STATUS              PORTS               NAMES
ada5bbfc74f0        homeassistant/qemux86-64-homeassistant   "/usr/bin/entry.sh..."   4 minutes ago       Up 4 minutes                            homeassistant
5954ac452ffc        homeassistant/amd64-hassio-supervisor    "/usr/bin/entry.sh..."   7 minutes ago       Up 7 minutes                            hassio_supervisor

After a connection to the container which is containing Home Assistant is made, you will see the log output.

[email protected]:/home/ha# docker attach --sig-proxy=false ada5bbfc74f0
2017-11-28 19:24:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sun.sun, old_state=<state sun.sun=below_horizon; next_dawn=2017-11-29T06:17:58+00:00,...

For further details about the container, inspect can help.

[email protected]:/home/ha# docker inspect bb32b525d1ad
[...]
            "OnBuild": null,
            "Labels": {
                "io.hass.arch": "amd64",
                "io.hass.machine": "qemux86-64",
                "io.hass.type": "homeassistant",
                "io.hass.version": "0.58.1"
            }
[...]

Hass.io is now ready. The frontend is available at http://192.168.0.109:8123. Yes, the IP address is the one of the guest.

Hass.io overview

Keep in mind that there are limitations with this approach. Not all add-ons will work and some don’t make sense to use as the hardware is not present. E.g., use the SSH community add-on instead of the default SSH add-on.


This is a companion discussion topic for the original entry at https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/
0 Likes

#2

Hello,

If we have installed via this method, what is the best way to update the instance?

0 Likes

#3

Use the hassio menu?

0 Likes

#4

Hey Falmingm0e,

I have tried to press the update buttons a few times:

but it never seems to update. The circle keeps going around changing colour when I press update, the page looses connection to the home assistant server/service and then when it comes back, it is still the old version.

Maybe my internet is unstable and doesn’t download the update properly.

0 Likes

#5

Did you check the system log? It’s likely had an error updating and automatically rolled back.

0 Likes

#6

Hey David,

Found the issue, looks like the download got slightly interrupted as it was downloading the update. Used a different data connection and downloaded the update. It now works.

1 Like

#7

I’d like to move from my rpi3+ to a vm. How complicated is it get the vm to see and communicate with the Zwave usb stick if it inserted into the usb port of the vm’s host machine? I also have a zigbee2mqtt usb stick.

0 Likes

#8

That’s something you can easily configure.
I am running Esxi and use an USB stick for Rfxcom, Zigbee2MQTT and Zwave. In the Esxi settings you just configure the USB port to the VM.

1 Like

#9

So what hardware can I get by with for a reliable Esxi system without breaking the bank?

0 Likes

#10

It will already work fine on a cheap NUC, check the forum for more info.
For example this topic Need NUC advice (migrating from Pi3B.

1 Like

#11

How do I install the HassOS VM on ESXi running on a NUC? I downloaded the VMDK file but couldn’t get it to load into ESXi. I tried to bring it up in VMWare Workstation and use VCenter Converter to migrate it to my ESXi server but it wouldn’t even boot up in Workstation. What am I missing here?

0 Likes

#12

You need to switch the bios mode in your host you create on esxi, then just load the vmdk file as a disk…
Remember to increase disk size before the first power on, I though 6 gb was default, it’s maybe to small

0 Likes