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

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 container 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 [Howto] 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

1 Like

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.

1 Like

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.