canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.76k stars 642 forks source link

Enable support for image launching on macOS and Windows #1260

Open moondev opened 4 years ago

moondev commented 4 years ago

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"
Saviq commented 4 years ago

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!

moondev commented 4 years ago

@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!

alexellis commented 4 years ago

Would qemu work as an alternative with its hardware acceleration?

Saviq commented 4 years ago

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

alexellis commented 4 years ago

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

jasonmccallister commented 4 years ago

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)

Saviq commented 2 years ago

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.

madalinignisca commented 2 years ago

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?

z0mbix commented 2 years ago

Hi, do you have any update on this problem?

mkhon commented 2 years ago

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>

2) download CentOS cloud image (I used this one: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2c)

3) 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"

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

5) 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
townsend2010 commented 2 years ago

Hey @mkhon,

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

goofrider commented 1 year ago

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

BurlyLuo commented 1 year ago

+1

BurlyLuo commented 1 year ago

Do we have a plan to support CentOS?

atomlab commented 11 months ago

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

underrun commented 6 months ago

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.

OhMyMndy commented 6 months ago

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.

madalinignisca commented 4 months ago

Thank you!

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.

emakarov commented 1 month ago

currently i was exploring the flow of creating a packer image from our production docker image and then launch it with multipass on Mac. and also stucked with the same limitation. Not sure if any other way to do this exists. While workaround exists, it looks like a very strange limitation, especially if workaround really works (in progress of checking this) In regards to things like Lima, @OhMyMndy by any chance if you know, does it work with rosetta mode on Mac M1/M2?

Fred78290 commented 6 days ago

@townsend2010 @Saviq

Bump up the issue. After reading code, no reason that multipass limit custom image on linux only because qemu is used on macos.