Note for new Users:
Instead of using an .iso file, you can also use the official images by LXD.
Windows VM:
Take a look at: Running virtual machines with LXD 4.0
or:
How to run a Windows virtual machine on LXD on Linux
Linux VM:
-
Start an empty VM with:
Note: ChangeVM-name
to a custom name you choose.lxc init VM-name --empty --vm
Note: In some cases it might be required to disable SecureBoot, when it blocks the .iso file (Recommendation: Disable only when necessary!).
You can do this, either by adding-c security.secureboot=false
to the init/launch command
or by modifying the config key of an existing VM with:lxc config set VM-name security.secureboot=false
. -
Grow the VMs filesystem size:
The default size is mostly too small.
You can choose what size you think is reasonable, in this example I use 15 Gigabyte (GB).lxc config device override VM-name root size=15GB
-
Add the .iso file to the VM via a disk device:
Note: Adjust the values accordingly.lxc config device add VM-name custom-device-name disk source=/home/user/pathtoiso/isoname.iso
-
Start the VM with GUI:
lxc start VM-name --console=vga
--console=vga
will open a VGA console.(Note: You maybe need to install additional software for this, see GUI in Virtual Machines/VMs)
-
Remove disk device:
After installation you can remove the disk device, with:
lxc config device remove VM-name device-name
-
(optional) Convert your VM to an image:
So you can use it in the future.lxc publish VM-name --alias custom-image-name
Sources: