Install Ubuntu Core on a VM

You can try Ubuntu Core without any specific hardware from within a virtual machine using Multipass on Windows, Mac and Linux. Multipass has integrated support for the latest Ubuntu Core images and can launch and run virtual machines from a single command.

If you need to test your own Ubuntu Core images, see Test Ubuntu Core with QEMU. QEMU, is more configurable than Multipass and can boot either a supported image or a custom image, with or without TPM emulation and full disk encryption.

Boot Ubuntu Core with Multipass

If you donā€™t yet have Multipass installed, see Install Multipass. If itā€™s installed, the following command will output its current state:

multipass info

List available images

To list which images Multipass currently has available, type multipass find.

The output will include Ubuntu Core images alongside standard Ubuntu images:

Image       Aliases           Version          Description
core20                        20230119         Ubuntu Core 20
core22                        20230717         Ubuntu Core 22
20.04        ocal             20240129.1       Ubuntu 20.04 LTS
22.04        ammy,lts         20240126         Ubuntu 22.04 LTS
daily:24.04  noble,devel      20240129         Ubuntu 24.04 LTS

Ubuntu Core 24: Multipass images for Ubuntu Core 24 are currently being tested. They are available from the edge version of the Multipass snap (snap refresh multipass --edge) and theyā€™ll become available from all stable releases shortly.

Launch an image

To create a new instance and boot your choice of Ubuntu Core image, type:

multipass launch <image-name> -n <instance-name>

For example, the following command will launch and boot core22 with an instance name of mycore22:

multipass launch core22 -n mycore22

The image is downloaded and locally cached when itā€™s launched for the first time.

Access a running instance

You can connect to a running instance of Ubuntu Core by opening a shell environment on that running instance:

multipass shell mycore22

You are now operating within the Ubuntu Core environment. See First steps with Ubuntu Core for suggestions on what to try.

4 Likes

I see that the ā€œInstall Multipassā€ links point to the ā€œInstallā€ page on the website, not sure if in the context of this guide it would make more sense to link the actual documentation page: How to install Multipass, or if itā€™s best to keep it light and high-level as in the currently linked page.

1 Like

Thank you for the suggestion! I think youā€™re right - the page you suggest is a better cross-platform fit.

The new version of multipass (1.14.0) supports deploying Core22 and Core24. Although, GUI support on Hypver-V has been lacking. Good News! The updated kernels used by Core24 contain a new display driver hyperv_drm that works with ubuntu-frame. To use this new display driver, you must blacklist hyperv_fb.

# /etc/modprobe.d/blacklist-hyperv-fb.conf
# Force the use of hyperv_drm for ubuntu-core wayland support
blacklist hyperv_fb

I use a custom cloud-config to apply the change through the multipass --cloud-init option.

#cloud-config
write_files:
## Blacklist hyperv_fb to force hyperv-drm
- path: /etc/modprobe.d/blacklist-hyperv-fb.conf
permissions: ā€˜0644ā€™
content: |
# Force the use of hyperv_drm for ubuntu-core wayland support
blacklist hyperv_fb

Thanks so much for letting us know. Iā€™ll update the doc to incorporate this, and to show ubuntu-frame running. Thanks!

Hello,

I think it could be beneficial to add some documentation about installing a custom Ubuntu Core in LXD - similar to the multipass instructions that are here.

Itā€™s a bit of overhead but not too much of a hassle and would be useful for those more familiar with the LXD interface. For example, after building a core image with ubuntu-image with:

ubuntu-image snap -O img my-model.model

It can be converted for LXD usage in a couple commands.

First extract and convert the image to qcow2 format

qemu-img convert img/pc.img -p -f raw -O qcow2 core.qcow2

Then write the image metadata to a yaml and create a compressed tar

cat > metadata.yaml <<EOF
architecture: x86_64
creation_date: $(date +%s)
properties:
  description: core
  os: Ubuntu Core
  release: <Ubuntu-image-codename> <Ubuntu-version-number>
EOF

tar cJf metadata.tar.xz metadata.yaml

Finally, import it into LXD

lxc image import metadata.tar.xz core.qcow2 [--alias <alias-name>]

From there onward it can be interacted with as any other lxc image:

lxc launch --vm <alias-name> [<vm-name>]

which powers on the UC VM that can subsequently be accessed by ssh, as normal for UC

Let me know your thoughts! Thanks

1 Like

This is fantastic, thank you so much! Iā€™m going to use this as the basis for a separate section on building images for LXD.