Skip to content

multipass umount a folder within VM "home" #4595

@finalyards

Description

@finalyards

Problem

While it's easy to mount a folder to Multipass VM default user's home, it's not as easy to umount it.

How I initially experienced this was an "asymmetry" in the UX. If I don't need to specify /home/ubuntu when mounting a folder there, why do I need to specify it for umounting said folder.

$ multipass mount --type=native abc rust:

..but:

$ multipass umount rust:/home/ubuntu/abc

I needed to rewrite the issue 3 times, learning more while testing things out. So bare with me, and let's see if you agree something could be improved... :)

Prelude

There are three ways a folder can be mounted, in Multipass:

command VM target
default multipass mount abc rust: /home/ubuntu/abc
relative multipass mount def rust:def (/home/ubuntu/)def
absolute multipass mount fgh rust:/fgh /fgh

Note: Calling these ”default”, ”relative” and ”absolute” are just terms I coughed up.

$ mp info rust
[…]
Mounts:         /Users/xxx/Git/abc => /home/ubuntu/abc
                    UID map: 501:default
                    GID map: 20:default
                /Users/xxx/Git/def => def
                    UID map: 501:default
                    GID map: 20:default
                /Users/xxx/Git/fgh => /fgh
                    UID map: 501:default
                    GID map: 20:default

If the "default" mount were the same as "relative" (currently it's "absolute"), I could:

$ multipass umount rust:abc

..this issue would never have arisen!

Note: This alone would be a breaking change. Scripts might make multipass umount /home/ubuntu/abc, which no longer works (Multipass currently treats "relative" and "absolute" mount completely separate; we'll come to that). But if these were also fused together (a good thing), there would be no breakage.

Side quest

What I'm really trying to do is reduce the surprises in Multipass CLI work.

Unfortunately, I stumbled on another one, which researching this. Seems I can:

$ multipass mount --type native abc rust:abc
$ multipass mount --type native abc2 rust:/home/ubuntu/abc

Both the VM targets are obviously the same, only provided in different ways. If you otherwise try to mount to an already mounted target, it fails:

$ mp mount --type native klm rust:/home/ubuntu/abc
mount failed: The following errors occurred:
"/home/ubuntu/abc" is already mounted in 'rust'

I think the same error should occur, also above (always testing "relative" mount as /home/ubuntu/{..path..}).

Suggestions

1. Change "default" mount to be "relative"

$ mp mount type native abc rust:

When I do this, it should be listed as:

- Mounts:         /Users/xxx/Git/abc => /home/ubuntu/abc
+ Mounts:         /Users/xxx/Git/abc => abc

2. Fuse checks of "relative" and "absolute" mounts together

This means e.g. that:

  • mounting as /home/ubuntu/abc, then umounting as mere abc would work (currently does not)
  • double mounting would no longer be possible (see above)

Note: This becomes the real thing of the PR, leaving "1" (above) to be merely a cosmetic thing about the mount listing printout.

One could argue that, for consistency, any folder mounted within the VM home folder (/home/ubuntu) could be listed in the "short format". Or... the opposite: mounts would always be listed with their absolute path.

Whichever way this goes, I think the Multipass mount system would be less surprising, if such changes to it are made.

Work-around

I might, with a sigh, stop using the multipass mount [...] abc rust: short-hand, and always append the target folder name. This way, I don't need to remember to add the full path when umounting.


macOS 15.7.3 (Intel)
Multipass 1.16.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions