lima: chown/chmod on mounted directory: Permission denied
Hey, I really like lima so far and wish I could use it for development, but unfortunately I’ve come across a workflow-breaking issue.
My docker image copies files into a mounted directory and changes their ownership to the custom user 1000. The copying works just fine, but the chown fails with Permission denied.
This issue can be confirmed in a shell; chmod fails in the same way.
root@wiki:/# chown 1000 /app/
root@wiki:/# chown 1000 /usr/
root@wiki:/# chmod 777 /app/
root@wiki:/# chmod 777 /usr/
root@wiki:/# chown 1000 /config/
chown: changing ownership of '/config/': Permission denied
root@wiki:/# chmod 777 /config/
chmod: changing permissions of '/config/': Permission denied
It’s the same for a custom mount inside of $HOME and a directory in /tmp/lima.
The files end up with
drwxrwxrwx 1 nobody nobody 128 Sep 9 13:17 php
Manually touched files get
-rw-r--r-- 1 nobody nobody 0 Sep 9 13:22 test
I’m on an M1 Macbook Pro with macOS 12 and installed QEMU using the provided shell file. The same setup just works with Docker Desktop.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 7
- Comments: 28 (4 by maintainers)
Commits related to this issue
- fix: mountしたディレクトリがパーミッションエラー refs. https://github.com/lima-vm/lima/issues/231#issuecomment-1145113879 — committed to saxsir/lima-workspace by saxsir 2 years ago
Sorry, after reading the discussion above I still don’t quite understand…How can I solve this problem when I use sshfs? I installed the latest HEAD branch using brew, but I still get this error… How do I need to adjust the source code to fix this? (I’m just on my own For use on laptops, you don’t need to consider too much security).Sorry, it was my test error. Tips for others who need help:
brew install lima --HEADbrew install qemu(orbrew upgrade qemu)9pas mount driver in config file:mountType: 9pwritable: true9pcache type to mmap:cache: "mmap"Finally it may be necessary to remove the previous mounted directory, eg
./data:/var/lib/mysql-->rm -rf ./dataNow recreate the lima vm, there is no more permission problem.
This is a known limitation of the current sshfs server, which works without the root privilege.
@nulllpoint In a recent release, the
securityModeloption changed its default value; you may need to specify it manually formapped-xattr.Any updates or ideas on a plan to solve this?
chown/chmodon mounted files is pretty commonly needed and likely a blocker for a fair number of folks.Is there any way forward here? I get similar “permission denied” errors and it’s not clear whether it can be fixed in current setup at all.
I am using lima with docker and regardless on whether I use rootless docker or rootful docker + sudo - I still get permission denied errors. Is it an sshfs limitation? or can we expect it to work in the future (ignoring 9p work).
As a followup, the latest version of the 9p patch is https://gitlab.com/wwcohen/qemu/-/tree/9p-darwin and that’s where the in-progress work will go as it progresses towards resubmission upstream. Any comments on how to improve would be GREATLY welcomed before I submit again.
If we could get https://github.com/afbjorklund/qemu/commits/9p-darwin merged into the upstream, we will be able to store the file owner info into xattr (or a separate file). https://wiki.qemu.org/Documentation/9psetup (
mapped-xattr,mapped-file)I’m not sure we will use 9p by default, though, due to a performance issue.
@mritd Thank you for your advice. Currently, I use lima
.lima/_config/override.yamlfile to override volume settings. I’m not familiar with lima nor colima. Since colima is a out of box plan, I prefer using colima now. Maybe try native lima later.I use podman by lima-vm, container is mysql/mysql-server, it need
chown mysql:mysql xxx, but when use -v mapping host’s dir , propmptchown: changing ownership of 'xxx': Operation not permittedmacos version: 12.6 lima version: 0.13.0 qemu version: 7.1.0 lima’s yaml config:The plan is to use
mapped-xattrormapped-fileof virtio 9P, but the patch is not merged for macOS hosts yet, and seems to need more testers: https://github.com/NixOS/nixpkgs/pull/122420There is nothing special to take into account and you do not need to re-create the vm, it should just work like the binary you downloaded on github.
Volumes are mounted on startup, all you need to do is shutdown, and start the vm (using your custom build).
ahh this is how I confused you. I found this issue after looking for issues regarding “incorrect” host mount permissions. My suggestion was merely about fixing permissions for host mounted dirs for non-root users in a container.
Would that solve it?
Sorry for the confusion.
These flags have nothing to do with allowing chown/chmod.
It should actually be
lima sudo nerdctl compose up?Thanks for the info! Is it going to be resolved when VirtFS is built in? Is running rootfully a workaround and is it documented somewhere? Starting a rootful VM works, but
sudo lima nerdctl compose upfails withFATA[0000] must not run as the root.