Configure where Multipass stores external data
This document demonstrates how to configure the location where Multipass stores instances, caches images, and other data. Configuring a new storage location can be useful, for example, if you need to free up storage space on your boot partition.
Configuring a new storage location
Caveats:
- Multipass will not migrate your existing data; this article explains how to do it manually. If you do not transfer the data, you will have to re-download any Ubuntu images and reinitialize any instances that you need.
- When uninstalling Multipass, the uninstaller will not remove data stored in custom locations, so you’ll have to deleted it manually.
First, stop the Multipass daemon:
sudo snap stop multipass
Since Multipass is installed using a strictly confined snap, it is limited on what it can do or access on your host. Depending on where the new storage directory is located, you will need to connect the respective interface to the Multipass snap. Because of snap confinement, this directory needs to be located in either /home
(connected by default) or one of the removable mounts points (/mnt
or /media
). To connect the removable mount points, use the command:
sudo snap connect multipass:removable-media
Create the new directory in which Multipass will store its data:
mkdir -p <path>
sudo chown root <path>
After that, create the override config file, replacing <path>
with the absolute path of the directory created above.
sudo mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/
sudo tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf <<EOF
[Service]
Environment=MULTIPASS_STORAGE=<path>
EOF
The output at this point will be:
[Service]
Environment=MULTIPASS_STORAGE=<path>
Then, instruct systemd
to reload the daemon configuration files:
sudo systemctl daemon-reload
Now you can transfer the data from its original location to the new location:
sudo cp -r /var/snap/multipass/common/data/multipassd <path>/data
sudo cp -r /var/snap/multipass/common/cache/multipassd <path>/cache
You also need to edit the following configuration files so that the specified paths point to the new Multipass storage directory, otherwise your instances will fail to start:
multipass-vm-instances.json
: Update the absolute path of the instance images in the “arguments” key for each instance.vault/multipassd-instance-image-records.json
: Update the “path” key for each instance.
Finally, start the Multipass daemon:
sudo snap start multipass
You can delete the original data at your discretion, to free up space:
sudo rm -rf /var/snap/multipass/common/data/multipassd
sudo rm -rf /var/snap/multipass/common/cache/multipassd
Reverting back to the default location
Stop the Multipass daemon:
sudo snap stop multipass
Although not required, to make sure that Multipass does not have access to directories that it shouldn’t, you can disconnect the respective interface depending on where the custom storage location was set (see Configuring a new storage location above). For example, to disconnect the removable mounts points (/mnt
or /media
), run:
sudo snap disconnect multipass:removable-media
Then, remove the override config file:
sudo rm /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf
sudo systemctl daemon-reload
Now you can transfer your data from the custom location back to its original location:
sudo cp -r <path>/data /var/snap/multipass/common/data/multipassd
sudo cp -r <path>/cache /var/snap/multipass/common/cache/multipassd
Finally, start the Multipass daemon:
sudo snap start multipass
You can delete the data from the custom location at your discretion, to free up space:
sudo rm -rf <path>
Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.