Running virtual machines with LXD 4.0

Neither one of these will work on Ubuntu server because they are a graphical programs, cant view a windows desktop on the terminal! (unless your server has a GUI, in which case either one will do.).

You could also install the suggested viewers on windows and use it remotely but I have no experience with this.

Advertising If your open to using a web interface, which can be installed on your Ubuntu server and then accessed from your windows machine you could use my software LxdMosaic which can connect in the same way those apps would, the edge snap supports a better environment for opening large resolution windows so you could install using snap install lxdmosaic --edge or if your not using snap you can follow the link & install in a container. Playing AAA games is unlikely but click & type server software should be fine.

1 Like

I figured as much, I’m down to remote in but I cant set an IP on my Virtual Machine for some reason but all my containers have ips.

If you open the link on a Windows machine it will give you the MS Tool. You can trick it by using Chrome so you get to download the ISO directly. Here is a good example of doing that:

For anyone that didn’t know yet:

If you’re installing this on a server with no good access to display, you can get VNC access by adding the -vnc 0.0.0.0:0 option to raw.qemu like so:

  • echo -n ' -vnc 0.0.0.0:0 -drive file=/home/USER/Downloads/Win10_1909_English_x64.iso,index=0,media=cdrom,if=ide -drive file=/home/USER/Downloads/virtio-win-0.1.173.iso,index=1,media=cdrom,if=ide' | lxc config set win10 raw.qemu -

NOTE: VNC will only work after you do the part with pressing ESC and booting from the disk (and don’t forget the server firewall, VNC is TCP 5900)

Right, that still works on some distro but it’s dependent on whether VNC support is built into QEMU.

In general the recommendation is to use lxc console from a remote system which then uses the LXD API and SPICE to attach to the console. This can be done from any Linux, Windows or macOS client after adding the remote server as a remote in the client.

Take a look here, stgraber provides another way to connect to the virtual machine.

I summarized the part from this thread on launching Windows VM at the following post,

In my case,

  1. I could not access the Windows VM IP from the host or other containers. I used ping to check, and also portscanning. The Windows VM got an IP from the lxdbr0 interface as expected, though.
  2. The VM did not have soundcard support, so no audio. I suppose this is a distrobuilder issue?
  3. I tried to setup macvlan (apply macvlan profile after the Windows VM was created but was obviously stopped). The Windows VM could not start due to an error. Could start if I removed the macvlan profile.

Having said that, it was an easy and painless process to setup a Windows VM through LXD.

1 Like
  1. Windows firewall usually prevents pinging and incoming access by default.
  2. There is no virtio-snd is still in its early stages and isn’t part of LXD VMs yet. Given that there isn’t a good VGA driver either, it’s recommended that folks connect over RDP post installation, RDP allows for sound passthrough.
  3. That’s odd, what was the error?

It’s the following.

$ lxc start win10 --console=vga
Error: Failed to start device "eth0": Failed to run: ip link add dev maca2b0d635 link enp3s0 type macvtap mode bridge: RTNETLINK answers: Device or resource busy
Try `lxc info --show-log win10` for more info
$ lxc info --show-log win10
Name: win10
Location: none
Remote: unix://
Architecture: x86_64
Created: 2021/02/27 17:50 UTC
Status: Stopped
Type: virtual-machine
Profiles: default, macvlan
Error: open /var/snap/lxd/common/lxd/logs/win10/qemu.log: no such file or directory

Ah, okay, so it’s looking like some kind of compatibility issue with macvlan/macvtap and your network driver.

Hi all;

I tested Windows vm in LXC on Ubuntu 18.04 and its worked.

Note: remmina (for slice) or virt-viewer can connect vga.

apt install -yqq remmina-plugin-spice virt-viewer

snap install distrobuilder --classic --edge
apt install -y libguestfs-tools wimtools
distrobuilder repack-windows /home/muslu/win10.iso /home/muslu/win10_distrobuilder.iso
lxc init win10 --empty --vm -c security.secureboot=false
lxc config device override win10 root size=50GiB
lxc config device add win10 iso disk source=/home/muslu/win10_distrobuilder.iso boot.priority=10
lxc start win10 --console=vga

If install virt-viewer than vga windows will be open automaticly after lxc start.

2 Likes

thanks Muslu. It’s very helpfull.

@muslu, which executable is provided from the wimtools package that is needed by distrobuilder?

Hi all;

Sorry for delay.

I wanted to test all the options.

When i test first time with my own pc (Ubuntu 18.04), i did get error for win parse and i installed wimtools.

i tested same code on my other pc (Ubuntu 18.04) but i did get more errors.

distrobuilder repack-windows /home/muslu/win10.iso /home/muslu/win10_distrobuilder.iso
2021/03/05 13:26:29 Mounting Windows ISO ...
2021/03/05 13:26:29 Mounting driver ISO ...
2021/03/05 13:26:29 Injecting drivers into boot.wim (index 2)...
2021/03/05 13:26:36 Injecting drivers into install.wim (index 1)...
Error: Failed to modify index 1 of "install.wim": Failed to inject drivers: Failed to edit Windows DRIVERS registry for driver "NetKVM": Failed to run: hivexregedit --merge --prefix='HKEY_LOCAL_MACHINE\DRIVERS' /var/cache/distrobuilder.507518749/wim/Windows/System32/config/DRIVERS: reg_import: cannot create \DriverDatabase\DeviceIds\pci\VEN_1AF4&DEV_1000 since parent \DriverDatabase\DeviceIds\pci\ does not exist at /usr/lib/x86_64-linux-gnu/perl5/5.26/Win/Hivex/Regedit.pm line 341, <FILE> line 5.
    Win::Hivex::Regedit::_merge_node(CODE(0x557773bab150), HASH(0x557773ca8f90), "\DriverDatabase\DeviceIds\pci\VEN_1AF4\x{26}DEV_1000", ARRAY(0x557773d2d190), ARRAY(0x557773d2d148)) called at /usr/lib/x86_64-linux-gnu/perl5/5.26/Win/Hivex/Regedit.pm line 196
    Win::Hivex::Regedit::reg_import(GLOB(0x557773d5d960), CODE(0x557773bab150)) called at /usr/bin/hivexregedit line 331

I will try again and report to you.

Thansk for everyting about lxc/lxd/lxcfs/distrobuilder and etc.

@monstermunchkin

@stgraber How can i limit the bandwidth?

like: lxc config device set VM eth0 limits.ingress 100Mbit

limits.ingress and limits.egress should work as expected, though note that they only work with bridges and cannot work with macvlan, physical or sr-iov.

1 Like

Thanks! Using macvlan.

nvm: works now… using root partition only.

I have a new test server available for LXD.
CPU: Intel Xeon W3520

egrep -c ‘(vmx|svm)’ /proc/cpuinfo
8

kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Server OS: 20.04
2 disks in RAID1 with LVM
The VM starts after the launch (ipv6 only)

lxc launch ubuntu:20.04 test1 --vm
Then the VM stops (after a few seconds) and I can’t start the VM

Error:
Error: open /var/snap/lxd/common/lxd/logs/test1/qemu.log: no such file or directory

lxc info
driver: lxc | qemu
driver_version: 4.0.6 | 5.2.0
firewall: xtables
kernel: Linux
kernel_architecture: x86_64
kernel_features:

Any idea @stgraber

Update: I cant delete or start the VM after this. Reboot required to delete it.

After a long wait… :wink:
user@node:~$ lxc delete test1
Error: Error deleting storage volume: Error removing LVM logical volume: Failed to run: lvremove -f /dev/LXD/virtual-machines_test1.block: Logical volume LXD/virtual-machines_test1.block in use.

lxc start test1
Error: virtiofsd failed to bind socket within 10s
Try lxc info --show-log test1 for more info

Anything scary looking in dmesg? Sounds like that system isn’t having a good day.