lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.23k stars 600 forks source link

Home directory doesn't get mounted again on reboot #2186

Open thatportugueseguy opened 8 months ago

thatportugueseguy commented 8 months ago

Description

When rebooting, we lose access to the mount of the host machine home directory (/Users/<user>).

Stopping and starting the vm again seems to fix the issue, it's probably because rebooting skips a few steps that starting and stopping does not, namely:

INFO[0007] [hostagent] Mounting "/Users/ze" on "/Users/ze"

Minimal repro:

INFO[0007] READY. Run `limactl shell debian` to open the shell.

$ limactl shell debian  
ze@lima-debian:/Users/ze/Projects$ sudo reboot

$ limactl shell debian 
bash: line 1: cd: /Users/ze/Projects: No such file or directory
ze@lima-debian:/Users/ze$

Using debian-11 template.

jandubois commented 8 months ago

You can reboot the VM in the provisioning phase, but afterwards stoping/starting needs to be done via limactl and not just the VM itself.

I don't think there is anything that can be done about this, so I would prefer to close this issue. Thoughts @lima-vm/maintainers ?

afbjorklund commented 8 months ago

Wonder if limactl restart would help ?

Otherwise it would require generating the proper mount command for the new filesystems, and adopt to systemd or openrc or what have you. Might not even be possible, for some drivers. Why do we need the reboot? Muscle memory?

afbjorklund commented 8 months ago

On a side note, systemctl reboot?

jandubois commented 8 months ago

The hostagent would have to detect the reboot, and then go through the whole "requirements" processing again once it gets an ssh connections again etc. Seems like a lot of work for something that doesn't seem to have a solid use-case.

Wonder if limactl restart would help ?

I've wanted this a couple of times already, even though I feel it is somewhat redundant.

thatportugueseguy commented 8 months ago

Why do we need the reboot? Muscle memory?

yeah, on my part it was just bad form and muscle memory. Looking back at it, it makes sense to use reboot only on provisioning, though i'd say it's not super obvious for newcomers and might lead to situations where it's unclear what the problem is.

AkihiroSuda commented 8 months ago

Is this about reverse-sshfs? virtiofs? 9p?

jandubois commented 8 months ago

Is this about reverse-sshfs?

It is definitely a problem with reverse-sshfs because the mounting is done by the guest-agent. The other 2 are probably fine.