How to manage Multipass on Linux

Set the driver to libvirt

If you want more control over your VMs after they are launched, you can use the experimental libvirt driver:


Switch to the libvirt driver

Make sure you have libvirt installed, as Multipass is using the libvirt daemon running on your host:

# use the equivalent for your distribution
$ sudo apt install libvirt-daemon-system

Allow Multipass to use your local libvirt:

# connect the libvirt interface/plug
$ snap connect multipass:libvirt

You can then switch the driver

# you'll need to stop all the instances first
$ multipass stop --all

# and tell Multipass to use libvirt
$ sudo multipass set local.driver=libvirt

All your existing instances will be migrated and can be used straight away.

NOTE: You can still use the multipass client and the tray icon, and any changes you make to the configuration of the instance in libvirt will be persistent. They may not be represented in Multipass commands such as multipass info, though.

Using virsh

After launching an instance, you can see it show up in virsh (see man virsh for a command reference):

$ virsh list                             
 Id   Name                   State
 1    unaffected-gyrfalcon   running

Using virt-manager

You can also use the graphical virt-manager interface:

Switching back

To switch back to the default, use the qemu driver:

# stop all instances again
$ multipass stop --all

# and switch back to the qemu driver
$ sudo multipass set local.driver=qemu

Here, too, existing instances will be migrated.

NOTE: this will make you lose any customizations you made to the instance in libvirt.

Change the daemon settings

You can systemctl edit snap.multipass.multipassd.service and place content along these lines (replace <hostname> with the hostname or the IP you want it to listen on) in:

ExecStart=/usr/bin/snap run multipass.multipassd --address <hostname>:51005

Restart the service then:

$ snap stop multipass
$ snap start multipass

Improve mounts performance

Share a folder with SMB

In Ubuntu (or any other Debian-based distribution), the package samba-common contains a SMB server. We can install it with the command

sudo apt update && sudo apt install -y samba-common

Then, editing the file /etc/samba/smb.conf lets us add shares, adding entries like the following:

  comment = smb mount test
  path = /my_path/
  read only = no
  browsable = yes
  kernel oplocks = yes

virtio-fs mounts

If using the LXD backend on Linux, we can benefit from a performant file system mount, at the expense of not being able to mount it while the instance is running. A folder is mounted on an instance with the command

lxc --project multipass config device add lxdinstance mount_lxd disk source=/my_path path=//mount_folder

where lxdinstance is the name of the instance, mount_lxd is an arbitrary device name for the mount, source specifies the path to share and path specifies the directory where the source is to be mounted. With only this command, LXD takes care of everything: no need to run commands on the instance.

virtio-fs is also available in qemu and libvirt backends, though at an extra setup cost.

Share a folder with NFS in Linux

In Ubuntu (or any other Debian-based distribution), the package nfs-kernel-server contains the files to use the NFS server included in the kernel. We can install it with the command

sudo apt update && sudo apt install -y nfs-kernel-server

To share a folder, we use the following command:

sudo exportfs *:/my_path

where the * means “export to any host”; we can specify a host name or IP address there.

Get stand-alone windows with X11

Linux and MacOS run X by default, so no extra effort is needed. We have the possibility here to be a bit more secure than we did on Windows, by using authentication in X forwarding. However, we will forward through ssh in order to avoid struggling with xauth stuff. Unfortunately, multipass shell does not let us to pass extra parameters to ssh, so we cannot use the shell through Multipass. We will allow our user in the host to log in to the Multipass instance through ssh, by copying our public key, in file ~/.ssh/ to the list of authorized keys of the instance, in file ~/.ssh/authorized_keys. We can do this with the following command (replace the example instance name with yours):

multipass exec rocking-squirrel -- bash -c "echo `cat ~/.ssh/` >> ~/.ssh/authorized_keys"

Then, check the IP address of the instance, using multipass info rocking-squirrel. Finally, we can log in to the instance using X forwarding doing

ssh -X ubuntu@xx.xx.xx.xx

(replace xx.xx.xx.xx with the IP address obtained above).

We are done, and we can test forwarding using xlogo as we did in the Windows section.

Access logs

We’re using systemd-journald on Linux, integrating with the de-facto standard for this on modern Linux systems.

To access the daemon (and its child processes’) logs:

$ journalctl --unit 'snap.multipass*'
1 Like

Thanks for all the great manuals here.

Actually I’ve got two questions:

  1. What are the pros and cons of the different backend drivers on Linux?
    There are qemu, libvirt and lxd available. From what I can see is, that bridged environment is only available with lxd as backend?
    Does lxd backend driver also run the virtual system as a container or is it a full blown virtualization like qemu and libvirt?

  2. I figured out that after rebooting the host the previously active virtual systems are automatically started as well. How can I control that behavior? I couldn’t find a variable to be set by ‘multipass set…’.