How to share data with an instance

See also: Instance

This document demonstrates how to share data between your host and an instance. There are two ways to accomplish this, via the mount command or via the transfer command.

Contents:

Using mount

See also: mount, umount

The recommended way to share data between your host and an instance with Multipass is the mount command:

$ multipass mount $HOME keen-yak
$ multipass info keen-yak
…
Mounts:         /home/michal => /home/michal

From this point on /home/michal will be available inside the instance.

You can also specify the path inside the instance in which to mount the local path:

$ multipass mount $HOME keen-yak:/some/path

Mounts can also be specified as an option to the launch command:

multipass launch --mount /some/local/path:/some/instance/path

To unmount the mounted paths, use the umount command. You can either specify the desired path to unmount or unmount all of them by not specifying any:

$ multipass umount keen-yak
$ multipass info keen-yak                
…
Mounts:         --

Using transfer

See also: transfer

You can also use transfer to just copy files around. If a file is inside an instance, prefix its path with <instance name>:.

$ multipass transfer keen-yak:/etc/crontab keen-yak:/etc/fstab /home/michal
$ ls -l /home/michal/crontab /home/michal/fstab
-rw-r--r-- 1 michal michal 722 Oct 18 12:13 /home/michal/crontab
-rw-r--r-- 1 michal michal  82 Oct 18 12:13 /home/michal/fstab
$ multipass transfer /home/michal/crontab /home/michal/fstab keen-yak:
$ multipass exec keen-yak -- ls -l crontab fstab
-rw-rw-r-- 1 ubuntu ubuntu 722 Oct 18 12:14 crontab
-rw-rw-r-- 1 ubuntu ubuntu  82 Oct 18 12:14 fstab
1 Like

I have to report that when using transfer i get a corrupted file, but using mount it works fine. The file in question is of type .img containing a disk image.

Hi, @grootwitbaas! Indeed, there is currently a bug related to transferring non-text files. It has been addressed and should be fixed in the next release! :slightly_smiling_face: