Configure where Multipass stores external data
This document demonstrates how to configure the location where Multipass caches images, stores instances, and other user information. Configuring a new storage location can be useful, for example, if you need to free up storage space on your boot partition.
Contents:
Configuring a new storage location
Caveats:
- Multipass will not migrate your existing data, but 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.
- Subsequently, when uninstalling Multipass, the uninstaller will not remove data stored in custom locations, which must be deleted manually.
Linux
First, stop the Multipass daemon:
$ sudo snap stop multipass
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 located in either /home
or one of the removable mounts points:
$ sudo snap connect multipass:removable-media # for /mnt or /media
$ sudo snap connect multipass:all-home # for /home/*
Then, 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
$ 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
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
macOS
First, become root
:
$ sudo su
Stop the Multipass daemon:
$ launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
Move your current data from its original location to <path>
, replacing <path>
with your custom location of choice:
$ mv /var/root/Library/Application\ Support/multipassd <path>
Make sure the multipassd
directory is moved to <path>
, not inside <path>
.
Make a link from the original location to the absolute path of new location:
$ ln -s <path> /var/root/Library/Application\ Support/multipassd
Finally, start the Multipass daemon:
$ launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
Windows
First, open an administrator privileged PowerShell prompt.
Stop the Multipass daemon:
PS> Stop-Service Multipass
Create and set the new storage location, replacing <path>
with the absolute path of your choice:
PS> mkdir "<path>"
PS> Set-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE -Value "<path>"
Now you can transfer the data from its original location to the new location:
PS> Copy-Item -Path "C:\ProgramData\Multipass\*" -Destination "<path>" -Recurse
It is important to copy any existing data to the new location. This avoids unauthenticated client issues, permission issues, and in general, to have any previously created instances available.
Finally, start the Multipass daemon:
PS> Start-Service Multipass
You can delete the original data at your discretion, to free up space:
PS> Remove-Item -Path "C:\ProgramData\Multipass\*" -Recurse
Reverting back to the default location
Linux
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, disconnect the respective interface depending on where the custom storage location was set:
$ sudo snap disconnect multipass:removable-media # for /mnt or /media
$ sudo snap disconnect multipass:all-home # for /home/*
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>
macOS
First, become root
:
$ sudo su
Stop the Multipass daemon:
$ launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
Remove the link pointing to your custom location:
$ unlink /var/root/Library/Application\ Support/multipassd
Move the data from your custom location back to its original location:
$ mv <path> /var/root/Library/Application\ Support/multipassd
Finally, start the Multipass daemon:
$ launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
Windows
First, open an administrator privileged PowerShell prompt.
Stop the Multipass daemon:
PS> Stop-Service Multipass
Remove the setting for the custom storage location:
PS> Remove-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE
Now you can transfer the data back to its original location:
PS> Copy-Item -Path "<path>\*" -Destination "C:\ProgramData\Multipass" -Recurse
Finally, start the Multipass daemon:
PS> Start-Service Multipass
You can delete the data from the custom location at your discretion, to free up space:
PS> Remove-Item -Path "<path>" -Recurse
Let us know how this worked for you and what you’d like to see next!
Last updated 3 months ago.