Jump to content

HomeAssistant on EISY will not run


Recommended Posts

Hello.

After multiple attempts I still can not get HA to run on NVMe.

If I try to start HA I get an error saying:  ! guest appears to be running already.

IF I try to stop it I get /usr/local/sbin/vm: WARNING: unable to locate process id for homeassistant

Can someone please help.

 

image.jpeg

start homeassistant.jpg

stop homeassistant.jpg

Link to comment

My latest attempt was with script created by @apnar

Quote
#!/bin/sh

# Where do we want to storge VM resources (ZFS pool name and mount path)
VMFILESET="storage/vms"
VMDIR="/storage/vms"

# Home Assistant VM name and how much resources to allocate
HA_VM_NAME="homeassistant"
HA_VM_CPU="2"
HA_VM_MEM="1G"
HA_VM_DISC="32G"

# specify network interface - by default it's Ethernet re0
INTERFACE="re0"

if [ $(id -u) != "0" ]
  then echo "Must be run with sudo"
  exit
fi

# Automatically pick the latest release from https://github.com/home-assistant/operating-system/releases/
HA_IMAGE_URL=$(curl -sL https://api.github.com/repos/home-assistant/operating-system/releases/latest | \
	grep "browser_download_url.*haos_ova.*qcow2.xz" | sed -e 's/.*: "\(.*\)"/\1/')

# Internal variables
TMPDIR=`mktemp -d`
IMAGE_NAME="${TMPDIR}/haos_ova-x86-64.img"
VM_CONF=${VMDIR}/${HA_VM_NAME}/${HA_VM_NAME}.conf

# make sure ifconfig_DEFAULT is not set as it causes tap0 interface issues
# ensure re0 is set to DHCP
sysrc -x ifconfig_DEFAULT
sysrc ifconfig_re0="DHCP"

echo "Make sure necessary packages are installed"
pkg install -y vm-bhyve edk2-bhyve wget qemu-tools

echo "Prepare /etc/rc.conf"
sysrc vm_enable="YES"
sysrc vm_dir="zfs:${VMFILESET}"

# this makes Home Assistant VM start up automatically on boot, comment out if this is not desired
sysrc vm_list=${HA_VM_NAME}

echo "Create ZFS fileset for VMs and prepare templates"
zfs create ${VMFILESET}
vm init
cp /usr/local/share/examples/vm-bhyve/*.conf ${VMDIR}/.templates/

# create VM networking (common for all VMs on the system)
vm switch create public
vm switch add public ${INTERFACE}

echo "Downloading image"
wget -O ${IMAGE_NAME}.xz ${HA_IMAGE_URL}
echo "Extracting..."
unxz ${IMAGE_NAME}.xz

echo "Creating a VM"
vm create -t linux-zvol -s ${HA_VM_DISC} ${HA_VM_NAME}

echo "Image info:"
qemu-img info ${IMAGE_NAME}

echo
echo "Copying image... (may take a bit of time)"
qemu-img convert ${IMAGE_NAME} /dev/zvol/${VMFILESET}/${HA_VM_NAME}/disk0
rm -rf ${TMPDIR}


GRAPHICS=0
echo -e "\n\nDo you want to enable unauthenticated VNC access to your Home Assistant virtual machine? (y/N)"
read answer
if [ "$answer" = "Y" ] || [ "$answer" = "y" ]
then
  GRAPHICS=1
  sysrc -f ${VM_CONF} graphics="yes"
fi

## Initial setup
TMPDIR=`mktemp -d`
# set zvol to full so partitions are visable
zfs set volmode=full ${VMFILESET}/${HA_VM_NAME}/disk0
sleep 2

# set baud rate for serial console
mount -t msdosfs /dev/zvol/${VMFILESET}/${HA_VM_NAME}/disk0p1 ${TMPDIR}
# add serial console to linux boot command line
sed -i '' -e 's/console=ttyS0/console=ttyS0,115200/' ${TMPDIR}/cmdline.txt
# umount device
umount ${TMPDIR}

SSH=0
echo -e "\n\nDo you want to enable SSH access to your Home Assistant virtual machine? (y/N)"
read answer
if [ "$answer" = "Y" ] || [ "$answer" = "y" ]
then
  SSH=1
  ## SSH Access
  # install ext4 fuse driver and load it
  pkg install -y fusefs-lkl
  kldload fusefs
  # mount vms /root/.ssh directory
  lklfuse -o type=ext4 /dev/zvol/${VMFILESET}/${HA_VM_NAME}/disk0p7 ${TMPDIR}
  sleep 5
  mkdir -p ${TMPDIR}/root/.ssh
  chmod 700 ${TMPDIR}/root
  chmod 755 ${TMPDIR}/root/.ssh
  # create a new SSH keypair and at it as an authorized key in the VM
  ssh-keygen -t ed25519 -N "" -C "Access Home Assistant running on eisy on port 22222" -f /home/admin/ha-ssh-key
  cp /home/admin/ha-ssh-key.pub ${TMPDIR}/root/.ssh/authorized_keys
  # set perms so admin user can access the ssh keys
  chown admin:admin /home/admin/ha-ssh-key*
  umount ${TMPDIR}
fi

## Clean up
# switch zvol mode back to normal
zfs set volmode=dev ${VMFILESET}/${HA_VM_NAME}/disk0
sleep 5
rmdir ${TMPDIR}

sysrc -f ${VM_CONF} loader="uefi"
sysrc -f ${VM_CONF} cpu=${HA_VM_CPU}
sysrc -f ${VM_CONF} memory=${HA_VM_MEM}

vm start ${HA_VM_NAME}
vm info ${HA_VM_NAME}
vm list

echo -e "\n\n##########################################################################\n"
echo "Please wait about 10 minutes and follow instructions at https://www.home-assistant.io/getting-started/onboarding/ to get your Home Assistant setup"
echo "ISY integration: https://www.home-assistant.io/integrations/isy994/"
echo -e "\nIf you need console access to the HA VM you can run \"sudo vm console ${HA_VM_NAME}\" then log in is as root.  Use \"~~.\" to exit."

if [ "$GRAPHICS" -eq "1" ]; then
  echo -e "\nYou can access your HA VM via VNC on port 5900 at your eisy's IP address."
fi

if [ "$SSH" -eq "1" ]; then
  echo -e "\nYou can access your HA VM via SSH using \"ssh -p22222 -i ha-ssh-key root@{HA VM IP}\""
fi

 

Link to comment
Posted (edited)

@tibbar you seem to be stuck in an odd state, I wonder if there is an old attempt still running in the background.  I'd try starting clean, rebooting, and trying again.

This should get you a close to clean state, run each individually:

sudo vm poweroff -f homeassistant
sudo vm destroy -f homeassistant
sudo vm switch destroy public
sudo zfs destroy storage/vms
sudo shutdown -r now

 

FYI, the script starts the VM.  So just give it some time after running the script then try your access.

Edited by apnar
Link to comment
5 minutes ago, apnar said:

@tibbar you seem to be stuck in an odd state, I wonder if there is an old attempt still running in the background.  I'd try starting clean, rebooting, and trying again.

This should get you a close to clean state, run each individually:

sudo vm poweroff -f homeassistant
sudo vm destroy -f homeassistant
sudo vm switch destroy public
sudo zfs destroy storage/vms
sudo shutdown -r now

 

That is what I tried before running your script. No matter what I could not "destroy" homeassistant  until I did:

bhyvectl --vm=homeassistant --destroy

Link to comment
1 minute ago, tibbar said:

That is what I tried before running your script. No matter what I could not "destroy" homeassistant  until I did:

bhyvectl --vm=homeassistant --destroy

Did you do the reboot?

Link to comment

In all my previous attempts I had same thing happened. Initially right after running a script info homeassistant showed

 it running but after restarting it always says "stopped".

Link to comment

Ok, please give the entire thing a go again (including another reboot) but capture the output of the script running, maybe there is something we can glean from that.

When you say it was initially running, were you able to log in to home assistant?  and when you say "after restarting" do you mean it worked fine until you restarted your eisy?

 

Link to comment
1 minute ago, apnar said:

 

When you say it was initially running, were you able to log in to home assistant?  and when you say "after restarting" do you mean it worked fine until you restarted your eisy?

 

I was not able to log in to HA. "Running" was stated by "info homeassistant" command but it did not show any network info. After rebooting it shows "stopped" like the screen shot above.

Link to comment
8 minutes ago, apnar said:

Ok, please give the entire thing a go again (including another reboot) but capture the output of the script running, maybe there is something we can glean from that.

 

Should I start over?

Link to comment

[admin@eisy ~]$ sudo vm list
Password:
NAME           DATASTORE  LOADER  CPU  MEMORY  VNC           AUTO     STATE
homeassistant  default    uefi    2    2G      0.0.0.0:5900  Yes [1]  Locked (eisy)

Link to comment

Yeah, I'd suggest starting from scratch.  FYI, "vm info" will never show an actual IP address for these VMs.  You can get the IP either from your router or you can connect to the console/vnc and look it up that way.

 

 

Link to comment
2 minutes ago, apnar said:

Yeah, I'd suggest starting from scratch.  FYI, "vm info" will never show an actual IP address for these VMs.  You can get the IP either from your router or you can connect to the console/vnc and look it up that way.

 

 

Router (I,m using pfsense) does not list anything with MAC address of VM. How do you connect to vnc if you do not know IP address?

Link to comment
1 minute ago, tibbar said:

Router (I,m using pfsense) does not list anything with MAC address of VM. How do you connect to vnc if you do not know IP address?

VNC server runs on the EISY itself, so you connect to the eisy IP on port 5900 with something like a RealVNC client.  Think of it as a screen and keyboard connected to the VM as opposed to VNC running within the VM.  Just be sure to answer yes to that question in my script since isn't enabled by default.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...