Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Multipass): Split how to set up the driver #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions multipass/how-to/how_to_set_up_a_virtualisation_driver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
> See also: [Driver](/t/28410), [`local.driver`](/t/27357)

This document demonstrates how to change to an alternative virtualisation driver and how to switch back to default driver.

Be aware that Multipass already has sensible defaults, so this is an optional step.

To review the default drivers and learn how to choose one, see: [Driver](/t/28410).

## Configure an alternative virtualisation driver

Please note that changing your driver will also change its hypervisor.

[tabs]

[tab version="Linux"]

If you want to (or have to), you can switch to the experimental [libvirt](https://libvirt.org/) instead of using the default hypervisor that Multipass uses.

To install libvirt, run the following command (or use the equivalent for your Linux distribution):

```plain
sudo apt install libvirt-daemon-system
```

Now you can switch the Multipass driver to libvirt. First, enable Multipass to use your local libvirt by connecting to the libvirt interface/plug:

```plain
sudo snap connect multipass:libvirt
```

Then, stop all instances and tell Multipass to use libvirt, running the following commands:

```plain
multipass stop --all
multipass set local.driver=libvirt
```

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

[note type="information"]
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.
[/note]

[/tab]

[tab version="macOS"]

If you want to (or have to), you can switch to VirtualBox instead of using the default hypervisor that Multipass uses.

To switch the Multipass driver to VirtualBox, run this command:

```plain
sudo multipass set local.driver=virtualbox
```

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

[/tab]

[tab version="Windows"]

If you want to (or have to), you can switch to VirtualBox instead of using the default hypervisor that Multipass uses.

To that end, you need to install VirtualBox and to [run the VirtualBox installer as administrator](https://forums.virtualbox.org/viewtopic.php?f=6&t=88405#p423658).

To switch the Multipass driver to VirtualBox (also with Administrator privileges), run this command:

```powershell
multipass set local.driver=virtualbox
```

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

[/tab]

[/tabs]

## Switch back to the default driver

> See also: [`stop`](/t/23951), [`local.driver`](/t/27357)

[tabs]

[tab version="Linux"]

To switch back to the default `qemu` driver, run the following commands:

```plain
multipass stop --all
multipass set local.driver=qemu
```

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

[note type="information"]
This will make you lose any customisations you made to the instance in libvirt.
[/note]

[/tab]

[tab version="macOS"]

If you want to switch back to the default driver, run the following command:

```plain
multipass set local.driver=qemu
```

[note type="information"]
Instances created with VirtualBox don't get transferred, but you can always come back to them.
[/note]

[/tab]

[tab version="Windows"]

If you want to switch back to the default driver, run the following command:

```plain
multipass set local.driver=hyperv
```
[note type="information"]
Instances created with VirtualBox don't get transferred, but you can always come back to them.
[/note]

[/tab]

[/tabs]

---

*Errors or typos? Topics missing? Hard to read? <a href="https://docs.google.com/forms/d/e/1FAIpQLSd0XZDU9sbOCiljceh3rO_rkp6vazy2ZsIWgx4gsvl_Sec4Ig/viewform?usp=pp_url&entry.317501128=https://multipass.run/docs/set-up-the-driver" target="_blank">Let us know</a> or <a href="https://github.com/canonical/multipass/issues/new/choose" target="_blank">open an issue on GitHub</a>.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
> See also: [Driver](/t/28410), [`local.driver`](/t/27357)

This document demonstrates how to set up network bridging for a Multipass instance.

## Use VirtualBox to set up network bridging for a Multipass instance

[tabs]

[tab version="Linux"]

This option only applies to macOS systems.

[/tab]

[tab version="macOS"]

Network bridging lets you add a second network interface to the instance and expose it on your physical network.

First, stop the instance:

```plain
multipass stop primary
```

Now, find the network interface you want to bridge with, running the command:

```plain
VBoxManage list bridgedifs | grep ^Name:
```

You want to find the identifier before the second colon; for example `en0` in the following sample output:

```plain
Name: en0: Ethernet
Name: en1: Wi-Fi (AirPort)
Name: en2: Thunderbolt 1
Name: en3: Thunderbolt 2
...
```

Finally, tell VirtualBox to use it as the "parent" for the second interface (see more info on bridging in [VirtualBox documentation](https://www.virtualbox.org/manual/ch06.html#network_bridged) on this topic):

```plain
sudo VBoxManage modifyvm primary --nic2 bridged --bridgeadapter2 en0
```

[note=caution]
Do not touch --nic1 as that's used by Multipass.
[/note]

You can then start the instance again:

```plain
multipass start primary
```

To find the name of the new interface, run this command:

```plain
multipass exec primary ip link | grep DOWN
```

In the following sample output, the name of the interface that we are looking for is `enp0s8`:

```plain
3: enp0s8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
```

Now, configure that new interface (Ubuntu uses [netplan](https://netplan.io/) for that):

```plain
multipass exec -- primary sudo bash -c "cat > /etc/netplan/60-bridge.yaml" <<EOF
network:
ethernets:
enp0s8: # this is the interface name from above
dhcp4: true
dhcp4-overrides: # this is needed so the default gateway
route-metric: 200 # remains with the first interface
version: 2
EOF

multipass exec primary sudo netplan apply
```

Finally, find the IP of the instance given by your router:

```plain
multipass exec primary ip address show dev enp0s8 up
```

For example:

```plain
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:2a:5f:55 brd ff:ff:ff:ff:ff:ff
inet <b>10.2.0.39</b>/24 brd 10.2.0.255 scope global dynamic enp0s8
valid_lft 86119sec preferred_lft 86119sec
inet6 fe80::a00:27ff:fe2a:5f55/64 scope link
valid_lft forever preferred_lft forever
```

All the services running inside the instance should now be available on your physical network under http://&lt;instance IP&gt;/.

[/tab]

[tab version="Windows"]

This option only applies to macOS systems.

[/tab]

[/tabs]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
> See also: [Driver](/t/28410), [`local.driver`](/t/27357)

This document demonstrates how to set up port forwarding to a Multipass instance.

## Use VirtualBox to set up port forwarding to a Multipass instance

[tabs]

[tab version="Linux"]

This option only applies to macOS and Windows systems.

[/tab]

[tab version="macOS"]

To expose a service running inside the instance on your host, you can use [VirtualBox's port forwarding feature](https://www.virtualbox.org/manual/ch06.html#natforward).

Example:

```plain
sudo VBoxManage 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.

[/tab]

[tab version="Windows"]

To expose a service running inside the instance on your host, you can use [VirtualBox's port forwarding feature](https://www.virtualbox.org/manual/ch06.html#natforward).

Example:

```powershell
& $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.

[/tab]

[/tabs]
Loading