multipass icon indicating copy to clipboard operation
multipass copied to clipboard

Enable support for image launching on macOS and Windows

Open moondev opened this issue 5 years ago • 20 comments

Is it possible to directly launch a qcow2/img cloud-init enabled image on macOS? This works great on Linux. Is this due to differences between qemu and hyperkit image format?

Test image used: https://download.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2

works on linux

multipass launch -n fedora https://download.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2

fails on macos

returns "http and file based images are not supported"

moondev avatar Dec 19 '19 21:12 moondev

Hi @moondev yeah, we currently have to pass kernel + initrd directly to hyperkit (no bootloader), so we can't really support images that we can't be sure will work with the kernels we use…

We're working on it, though!

Saviq avatar Dec 19 '19 22:12 Saviq

@Saviq Thanks for the details! Very interesting as well as clever way to leverage hyperkit for cloud-init.

Looking forward to a future update to support this. I suppose using an alternative hypervisor could be an option but then you would need to install it first which is no fun. Congrats on the 1.0.0 launch and keep up the great work!

moondev avatar Dec 20 '19 00:12 moondev

Would qemu work as an alternative with its hardware acceleration?

alexellis avatar Dec 29 '19 16:12 alexellis

Hi @alexellis we'll be evaluating qemu for that reason (and more) in the near future.

Saviq avatar Jan 07 '20 17:01 Saviq

How are you planning on dealing with networking? I had issues getting any examples for qemu on MacOS to work for port mapping.

alexellis avatar Jan 26 '20 22:01 alexellis

Ideally I would love to be able to build a custom pre-built Ubuntu image and download them from the launch command. We have a hefty cloud-config setup right now that would reduce our setup by just downloading an image instead.

(I know this is on the roadmap, just excited to see the progress being made)

jasonmccallister avatar Feb 28 '20 18:02 jasonmccallister

Since this runs on QEMU and not hyperkit, any chance we could get image launching support for the Apple Silicon release? #1260

Originally posted by @m-bers in https://github.com/canonical/multipass/issues/1857#issuecomment-950114617

@m-bers, all, it would be near impossible for us to ensure the user experience with custom images. There are certain requirements of the image to be compatible with Multipass. Those of you requesting it would probably be fine with it, but others may be surprised and frustrated that "random" images downloaded from the Internet don't work.

Apart from --cloud-init to bootstrap, we've now launched support for workflows, which can solve some of your use cases. Hopefully snapshots (#208) would solve even more.

Saviq avatar Oct 25 '21 07:10 Saviq

Wouldn't it be easy to add a parameter flag to enable "experiment" mode and allow it in Windows/MacOS, and we users would be responsible if the image would work or not? I don't understand at all the reason to forbid Windows and MacOS users to have this feature even if they explicitly would accept it as experimental and unsupported.

To give an example: This blocks me right now to do a large demo of something that works really nice on my personal laptop with Ubuntu as main host, but can't run it on my work laptop with Windows, and my company forbids to use another device for the demo purely of some company policies. Are you considering that with this kind of things you are blocking us developers and engineers to convince our companies for (more) adoption of Ubuntu and Canonical products and services?

madalinignisca avatar Dec 23 '21 09:12 madalinignisca

Hi, do you have any update on this problem?

z0mbix avatar Mar 17 '22 13:03 z0mbix

I succeeded substituting Ubuntu 20 disk image with CentOS 7 cloud image on macOS:

  1. create Ubuntu 20 multipass VM, then stop it
multipass launch -n <name>
multipass stop <name>
  1. download CentOS cloud image (I used this one: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2c)

  2. convert the image and store into instance vault:

"/Library/Application Support/com.canonical.multipass/bin/qemu-img-hyperkit" convert -O qcow2 CentOS-7-x86_64-GenericCloud-2009.qcow2c "/var/root/Library/Application Support/multipassd/vault/instances/<name>/CentOS-7-x86_64-GenericCloud-2009.qcow2"
  1. move out existing disk image and make a symlink:
mv ubuntu-20.04-server-cloudimg-amd64.img ubuntu-20.04-server-cloudimg-amd64.img~
ln -s CentOS-7-x86_64-GenericCloud-2009.qcow2 ubuntu-20.04-server-cloudimg-amd64.img

The contents of the instance vault directory should look like:

-rw-r--r--  1 root  wheel  931856384 Jun 10 13:31 CentOS-7-x86_64-GenericCloud-2009.qcow2
-rw-r--r--  1 root  wheel      53248 Jun 10 13:15 cloud-init-config.iso
-rw-r--r--  1 root  wheel         12 Jun 10 13:24 pty
-rw-r--r--  1 root  wheel   27621125 Jun  8 15:50 ubuntu-20.04-server-cloudimg-amd64-initrd-generic
-rw-r--r--  1 root  wheel   13668608 Jun  8 15:50 ubuntu-20.04-server-cloudimg-amd64-vmlinuz-generic
lrwxr-xr-x  1 root  wheel         39 Jun 10 13:23 ubuntu-20.04-server-cloudimg-amd64.img -> CentOS-7-x86_64-GenericCloud-2009.qcow2
  1. start the instance
multipass start <name>

The instance uses Ubuntu 20 kernel and initrd which should be suitable for almost any recent Linux cloud image

Additionally, you may need to copy out /lib/modules from Ubuntu image (e.g. boot Ubuntu instance, copy /lib/modules out, then boot your image, copy /lib/modules back) so that kernel modules in the image match the kernel used by multipass.

Make sure you umount /lib/modules (or /usr/lib/modules) before copying it back because it is mounted (I guess by initird) as tmpfs (copymods):

# umount -l /usr/lib/modules
# systemctl restart systemd-udevd

mkhon avatar Jun 10 '22 10:06 mkhon

Hey @mkhon,

That's quite enterprising to say the least:wink:

townsend2010 avatar Jun 10 '22 11:06 townsend2010

Now that Mac OS version of Multipass is switching to Qemu, would the team consider enabling instance creation from custom URLs/ISOs?

goofrider avatar Jun 14 '23 09:06 goofrider

+1

BurlyLuo avatar Sep 19 '23 11:09 BurlyLuo

Do we have a plan to support CentOS?

BurlyLuo avatar Sep 19 '23 11:09 BurlyLuo

Hello! Where do I need to place the downloaded Debian Cloud image to run it on MacOS with M1 processor? https://cloud.debian.org/images/cloud/bookworm/daily/latest/debian-12-genericcloud-arm64-daily.qcow2

atomlab avatar Oct 24 '23 09:10 atomlab

Since this runs on QEMU and not hyperkit, any chance we could get image launching support for the Apple Silicon release? #1260

Originally posted by @m-bers in #1857 (comment)

@m-bers, all, it would be near impossible for us to ensure the user experience with custom images. There are certain requirements of the image to be compatible with Multipass. Those of you requesting it would probably be fine with it, but others may be surprised and frustrated that "random" images downloaded from the Internet don't work.

@Saviq I don't think this argument holds up while multipass supports launching images from files on linux. If I download some random image from the internet and try to start it on linux, canonical has exactly as much control over the user experience in that situation as it does on macos or windows.

The users of multipass on mac/win are likely mostly developers. The users that even want to try building a qcow2 image out of an iso for some non ubuntu cloud image probably know what they are doing enough to be aware of the pitfalls and debug them. And it's pretty likely those users are trying to use a file based image in multipass to make their lives easier via the really nice ux multipass provides.

In other words, by not supporting file based images on mac/win you are ensuring users will have a much worse experience working with their custom images.

Please address this issue.

underrun avatar Mar 14 '24 17:03 underrun

Since I have been following this thread for over 2 years, I found an alternative solution to run other distro's in the same fashion as Multipass does, with Lima.

After installing Lima, you can create a Debian VM as such: limactl create --name debian-12 https://raw.githubusercontent.com/lima-vm/lima/master/examples/debian-12.yaml or use https://github.com/lima-vm/lima/blob/master/examples/ubuntu-lts.yaml to run Ubuntu.

Start your VM with limactl start debian-12.

And then shell into your vm with limactl shell debian-12.

@canonical, if I violate the terms of service, please just remove my comment.

OhMyMndy avatar Mar 29 '24 14:03 OhMyMndy