Install any OS via ISO in a Virtual machine/VM

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:

  1. Start an empty VM with:
    Note: Change VM-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.

  2. 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

  3. 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

  4. 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)

  5. Remove disk device:
    After installation you can remove the disk device, with:
    lxc config device remove VM-name device-name

  6. (optional) Convert your VM to an image:
    So you can use it in the future.

    lxc publish VM-name --alias custom-image-name


Sources:

@stgraber

6 Likes

Unless you’re installing Windows, you can usually just attach the ISO image as a disk device, which doesn’t require any of the hacks above.

2 Likes

Interesting.

But what about the usual permission problems?
If I remember correctly, using disk devices without shiftfs results in them being read-only.

Regarding the update below, I assume the windows installer wants to have write and lock permissions?
While Linux installers are happy with read-only?

Update:
Seems someone recently tried it sucessfully: Proxmox installation fails

So I changed the instructions accordingly.

And how will this work exactly?

  1. I create an empty VM
  2. Apply a disk device with an .iso file to it
    and then it will detect and use the .iso automatically upon start-up?

@stgraber @tomp If you approve of this, could you put it in the tutorial section as well? :slight_smile:

Also I hope you are not annoyed by me essentially copying your instructions :smile:, I just want to achieve better visibility.

1 Like

security.secureboot=false should only really be used when absolutely required.
That’s the case for Windows due to the virtio scsi driver not being signed, but for most Linux distributions at least, they have properly signed binaries and won’t need it.

Yes that makes sense.
I will edit it.

I tried to install from a LinuxMint iso, and there were some problems booting from the iso.
I had to follow these instructions to make it work: OVMF/UEFI Boot Entries - Proxmox VE

@stgraber I assume what @dashohoxha mentioned, is related to disabling secure boot?

Sounds like it

Unfortunately, no, it is not related to that. It happens in both cases (secure boot enabled or disabled). It happens with a Debian iso as well. The error message looks like this:

BdsDxe: faled to load Boot0002 "UEFI QEMU QEMU HARDDISK " from PciRoot (0x0) /Pci (0x1,0x1) /Pci (0x0,0x0) /Scsi (0x0,0x1) : Not Found

>>Start PXE over IPv4.
  PXE-E16: No valid offer received.
... some failure message similar to the above...

>>Start PXE over IPv6.
  PXE-E16: No valid offer received.
... some failure message similar to the above...

>>Start HTTP boot over IPv4.....
  Error: Could not retrieve NBP file etc.

>>Start HTTP boot over IPv6.....

Finally it boots from the iso.

It seems to be a boot order problem, but I don’t know how to specify booting directly from the iso, instead of trying the other options.

1 Like

I found this: Running virtual machines with LXD 4.0 - #113 by tomp
It seems that the option boot.priority=2 makes things better:

lxc config device add VM-name cdrom \
    disk source=/home/user/pathtoiso/isoname.iso boot.priority=2

But still, the text installer of Debian does not seem to work.
The graphical installer seems to work correctly.

3 Likes

Nice article! For standardisation, I suggest to replace the word “container” to “VM” in point3.

1 Like

Hi everyone. I recently started using lxc containers as isolated dev envs and I was surprised how easy and efficient everything is, I thoroughly enjoyed it. I was trying to create a vm in the past hours to install a linux distro from ISO that is not amongst the images. I was following this article right here :slight_smile: after getting through the spam esc and which image to boot from manuver I managed to get graphical console and the gui installation of the distro was almost smooth, apart from one thing. I’m stuck trying to make my vm have internet access. I can ping the vm just fine from the host, but no internet connection in the vm. I was going through reddit and the instance config part of the docs but I just can’t comprehend it. I installed lxd snap. Lxd version is 5.0.0,the host is running Pop!_OS and the vm is running Ubuntu Budgie 22.04. Any steps helping to troubleshoot, maybe solve the situation would be highly appreciated. Thank you

1 Like