lima
lima copied to clipboard
Add abstraction for the default `/tmp/lima` directory ?
Description
It doesn't work so great in a multi-user environment, and doesn't work on Windows (compared with e.g. C:\TEMP)
i.e. when several users are sharing a server, they will see the files from the other users in the shared /tmp/lima
Hosts based on Fedora put /tmp in RAM, so you need to use /var/tmp if you want to use a normal disk directory.
Should we have some placeholder value for the default.yaml, instead of the "/tmp/lima"? Similar to LIMA_HOME.
- https://github.com/lima-vm/lima/pull/2337#issuecomment-2106195608
One possible solution is that "/tmp/lima" is the placeholder, and replace it with $TMPDIR/lima.
i.e. something like filepath.Join(os.TempDir(), "lima"), so that it works also on Windows
systemd would try to use some complex scheme:
https://systemd.io/TEMPORARY_DIRECTORIES/
But it should be optional (opt-in), since it breaks things.
https://0pointer.de/blog/projects/tmp.html re: /tmp
Using TMPDIR will break under macOS, with the default setup and the default mounts.
Since it is generated under /var/folders by default, but that location is not mounted...
Side note: /tmp is a symlink to /private/tmp
But /tmp/lima still works, because of symlink.
It would to use something like $LIMA_TEMP.
https://lima-vm.io/docs/dev/internals/
Then you could set LIMA_TEMP=$TMPDIR/lima
i.e. similar to overriding LIMA_HOME=$HOME/.lima
I'm not a fan of making /tmp/lima "magical" and replacing it with a different location at VM start. I would rather add support for templating, so you could write something like this:
- location: "{{.Temp}}/lima"
mountPoint: /tmp/lima
create: true
writable: true
Where {{.Temp}} would be os.TempDir() evaluated at the start of the instance.
The create property would tell Lima to create the location if it doesn't exist. Maybe we don't need it, and we should always create non-existing locations, but having a separate setting feels safer. That way we can just drop mounts whose locations don't exist on the host. We should already be doing that, but I haven't checked.
I don't know what other template variables would make sense; we can add {{.Home}}, but it would be redundant with the special handling of ~ that already exists. Maybe {{.Cache}} and {{.Config}} for os.UserCacheDir() and os.UserConfigDir()?
We could add access to the host environment with something like {{.Env.LIMA_TEMP}}, but I would wait until we have an actual use-case.
I don't see a need for LIMA_TEMP; you can just set TMPDIR or TEMP before calling limactl and get the same effect.
Using TMPDIR will break under macOS, with the default setup and the default mounts.
Since it is generated under
/var/foldersby default, but that location is not mounted...
I'm not sure what point you are trying to make. If you use it as the location for the /tmp/lima mount point, then it will be mounted for you...
Or are you saying that you can't mount paths under $TMPDIR into containers running inside an instance because the directory isn't mounted. That is true; the user would need to add that mount point themselves.
FWIW, Rancher Desktop mounts /private/var/folders into the instance for this reason.
Side note:
/tmpis a symlink to /private/tmp
/var is also a symlink to /private/var...
The mounts should be OK, it was a reflection on the TMPDIR (like that issue about it being not absolute in Windows)
Will leave /tmp/lima, and see if something can be templates instead.