VM from disk Image

Oh all I had to do is to convert the raw image to qcow2

qemu-img convert -f raw -O qcow2 <raw-image.img> <converted-image.qcow2>

Wasn’t so lucky, doing an lxc console in the vm I realize that the vm did not start properly, prompt takes me straight to Shell>

That’s either because you’re missing a security.secureboot=false with an image that doesn’t have a properly signed bootloader or because your VM image isn’t compatible with UEFI (uses old legacy BIOS).

1 Like

i am also trying to solve the home assistant in lxd vm. i have been communicating on irc but it might get move visibility here for others now and in the future.

i cant seem to get the port proxy working but works fine on other containers. i have set the vm to have a static ip of the one that was initially supplied to it.

i ran lxc config device add hass httpProxy proxy listen=tcp:10.194.232.54:4333 connect=tcp:10.194.232.54:8123 nat=true to proxy the virtual machine so i can access it from outside the host but am unable to connect. from inside the vm it says its fine. i also tried listening on 127.0.0.1, lxdbr0: 10.194.232.1, and 0.0.0.0 which obviously wouldnt work, but to no avail.

here is the vm config:

$ lxc config show hass -e                                       
architecture: x86_64
config:         
  image.description: Home Assistant Image
  image.os: Debian
  image.release: bullseye 11.1
  security.secureboot: "false"
  volatile.base_image: 28b62ec10068140a97eee322922c568b33780785856e9c0c86b34f354db416dc
  volatile.eth0.host_name: tap70cafdcf
  volatile.eth0.hwaddr: 00:16:3e:36:9e:ff
  volatile.last_state.power: RUNNING
  volatile.uuid: aff69c89-5a0d-47a5-ba66-77d897e51d0c
  volatile.vsock_id: "9"
devices:
  eth0:
    ipv4.address: 10.194.232.54
    name: eth0
    network: lxdbr0
    type: nic
  httpProxy:
    connect: tcp:10.194.232.54:8123 
    listen: tcp:10.194.232.54:4333
    nat: "true"
    type: proxy
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

the ha command output while consoled into the vm:

$ ha network info
docker:                                                                                                                                       
  address: 172.30.32.0/23                                                                                                                     
  dns: 172.30.32.3
  gateway: 172.30.32.1
  interface: hassio
host_internet: true
interfaces:
- connected: true
  enabled: true
  interface: enp5s0
  ipv4:
    address:
    - 10.194.232.54/24
    gateway: 10.194.232.1
    method: auto
    nameservers:
    - 10.194.232.1
  ipv6:
    address:
    - fe80::f314:77d7:fc44:3fca/64
    gateway: null
    method: auto
    nameservers: []
  primary: true
  type: ethernet
  vlan: null
  wifi: null

strangely, if i add my hosts ssh pub key to an authorized_keys in the vm im able to connect to it via ssh root@10.194.232.54 -p 22222 but still cant connect via the mapped proxy i setup for it. im also not able to curl the website it should be publishing from inside the vm :man_shrugging:

# ha banner

| |  | |                          /\           (_)   | |            | |  
| |__| | ___  _ __ ___   ___     /  \   ___ ___ _ ___| |_ __ _ _ __ | |_ 
|  __  |/ _ \| '_ \ _ \ / _ \   / /\ \ / __/ __| / __| __/ _\ | '_ \| __|
| |  | | (_) | | | | | |  __/  / ____ \\__ \__ \ \__ \ || (_| | | | | |_ 
|_|  |_|\___/|_| |_| |_|\___| /_/    \_\___/___/_|___/\__\__,_|_| |_|\__|

Welcome to the Home Assistant command line.

System information
  IPv4 addresses for enp5s0: 10.194.232.54/24
  IPv6 addresses for enp5s0: fe80::f314:77d7:fc44:3fca/64

  OS Version:               Home Assistant OS 6.6
  Home Assistant Core:      2021.11.5

  Home Assistant URL:       http://homeassistant.local:8123
  Observer URL:             http://homeassistant.local:4357
# curl http://homeassistant.local:8123
curl: (6) Could not resolve host: homeassistant.local
# curl http://localhost:8123
# curl http://0.0.0.0:8123
# curl http://127.0.0.1:8123
# curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>