How to manage Multipass on Windows

Set the driver to VirtualBox

If you want to (or have to), you can change the hypervisor that Multipass uses to VirtualBox. To that end, install VirtualBox, if you haven’t yet. You may find that you need to run the VirtualBox installer as administrator. You can then tell Multipass to use it (also with Administrator privileges):

PS> multipass set local.driver=virtualbox

From then on, all instances started with multipass launch will use VirtualBox behind the scenes.

Contents:

Finding Multipass instances in VirtualBox

Multipass runs as the System account, so to see the instances in VirtualBox, or through the VBoxManage command, you have to run those as that user via PsExec -s. Download and unpack PSTools.zip in your Downloads folder, and in an administrative PowerShell, run:

PS> & $env:USERPROFILE\Downloads\PSTools\PsExec.exe -s -i $env:VBOX_MSI_INSTALL_PATH\VirtualBox.exe

To list the instances on the command line:

PS> & $env:USERPROFILE\Downloads\PSTools\PsExec.exe -s $env:VBOX_MSI_INSTALL_PATH\VBoxManage.exe list vms
"primary" {05a04fa0-8caf-4c35-9d21-ceddfe031e6f}

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

Port forwarding

To expose a service running inside the instance on your host, you can use VirtualBox’s port forwarding feature, for example:

PS> & $env:USERPROFILE\Downloads\PSTools\PsExec.exe -s $env:VBOX_MSI_INSTALL_PATH\VBoxManage.exe controlvm "primary" natpf1 "myservice,tcp,,8080,,8081"

You can then open, say, http://localhost:8081/, and the service running inside the instance on port 8080 will be exposed.


If you want to switch back to the default driver:

PS> multipass set local.driver=hyperv

Instances created with VirtualBox don’t get transferred, but you can always come back to them.

Change the daemon settings

On Windows you’d need to edit/recreate the service definition, and that’s non-trivial (if you do, remember to pass /svc as the first argument to the multipassd.exe binary, and that we currently use the LocalService account)…

As a one-time thing you can use the Start parameters field in the Services panel after stopping the service:

Improve mount performance

Share a folder with SMB

First, optionally and to increase speed, we can enable RDMA on the SMB server built into Windows. In the control panel, we can find the Turn Windows Features on or off icon. On that window, we need to enable SMB Direct. Windows may require a restart.

Then, to share a folder we can use PowerShell. Issuing the command

New-SmbShare -Name "share_name" -Path "C:\my_path"

will create a share named \\hostname\share_name in the host. The command New-SmbShare has multiple options to control access and encryption, but these are not the topic of this document.

NFS not available on Windows

Get stand-alone windows with X11

The problem is that Windows knows nothing about X. We need to install then an X server. We will use here VcXsrv, which can be found here. Other options would be Xming (however, newest versions are paid but older versions can still be downloaded for free from their SourceForge site) or installing an X server in Cygwin.

The first step would be thus to install VcXsrv and run the X server through the newly created start menu entry “XLaunch”. Some options will be displayed. In the first screen, we should choose “Multiple windows” and set the display number; leaving it in -1 is a safe option. The “Next” button brings us to the “Client startup” window, on which we should choose “Start no client”. “Next” will show us the “Extra settings”, and there we should activate the option “Disable access control”. Pressing “Next” will give us then the option to save the settings, and finally we can start the X server. An icon will show up in the dock: we are done with the X server.

To configure the client (that is, the Multipass instance) we will need first the host IP address, which can be obtained with the console command ipconfig. Then start the instance and set the DISPLAY environment variable to the server display on the host IP:

export DISPLAY=xx.xx.xx.xx:0.0

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

To test the setting, we can run in the host some simple program:

sudo apt install x11-apps
xlogo &

A small window containing the X logo must show up. Done!

Access logs

On Windows, the Event system is used, and Event Viewer lets you access them. Our logs are currently under “Windows Logs/Application”, where you can filter by “Multipass” Event source. You can then export the selected events to a file.

Troubleshoot networking

Contents:

Architecture

Multipass uses the native “Hyper-V” hypervisor on Windows, along with the “Default Switch” created for it. That, in turn, uses the “Internet Sharing” functionality, providing DHCP (IP addresses) and DNS (domain name resolution) to the instances.

Known issues

Default Switch going awry

Unfortunately the Default Switch is known to be quirky and Windows updates often put it in a weird state. This may result in new instances failing to launch, and existing ones timing out to start.

The broken state also persists over reboots. The one approach that has helped is removing the network sharing from the default switch and rebooting:

PS> Get-HNSNetwork | ? Name -Like "Default Switch" | Remove-HNSNetwork
PS> Restart-Computer

Hyper-V will recreate it on next boot.

Stale Internet Connection Sharing lease

Another reason for instance timeouts may be that a “stale” IP address for a particular instance name is stored in the Internet Connection Sharing hosts file.

Using Administrator privileges, edit C:\WINDOWS\System32\drivers\etc\hosts.ics and look for any entries that have your instance name in it. If there is more than 1 entry, remove any of them except for the first listed. Save the file and try again.

Anti-virus / security software blocking instances

Anti-virus and network security software are not necessarily virtualization-aware. If you’re having issues with connectivity, temporarily disabling this software to test can result in a positive outcome. Examples of this software are Symantec, ESET, Kaspersky, and Malware Bytes.

1 Like