3

I'm using Virtualbox. I have a NixOS guest on a Windows host. I added the user to the vboxsf group and rebooted the machine.

$ groups                                                                                                                                                                         
users wheel vboxsf                                                                                                                                                                           

I can access the shared folder as root, but not as a non-root user.

$ ls /media/sf_VMShare
ls: cannot access '/media/sf_VMShare': Permission denied                                                                                                                                     
$ sudo ls /media/sf_VMShare                                                                                                                                                      
<directory listing...>

The ownership of the mount point seems to be correct.

$ sudo umount /media/sf_VMShare                                                                                                                                                  
$ sudo ls -l /media
total 4
drwxrwx--- 2 amy vboxsf 4096 Nov 22 17:38 sf_VMShare

I have seen the question Permission denied when accessing VirtualBox shared folder when member of the vboxsf group, and already tried the accepted answer, but no success.

EDIT: With the drive mounted...

$ sudo ls -ld /media/sf_VMShare
drwxrwx--- 1 root vboxsf 0 Nov 21 15:31 /media/sf_VMShare
3
  • Can you try 777 permissions? Commented Nov 29, 2018 at 19:23
  • @KamilMaciorowski drwxrwx--- 1 root vboxsf 0 Nov 21 15:31 /media/sf_VMShare
    – mhwombat
    Commented Dec 5, 2018 at 11:12
  • @AulisRonkainen I tried that, but it made no difference. Then I rebooted to see if that would help, the permissions reverted to what they were before.
    – mhwombat
    Commented Dec 5, 2018 at 11:20

2 Answers 2

0
+50

There is this question on Unix & Linux SE: Do the parent directory's permissions matter when accessing a subdirectory? The answer is yes, they do matter.

The precise rule is: you can traverse a directory if and only if you have execute permission on it.

So for example to access dir/subdir/file, you need execute permission on dir and dir/subdir [...]

My guess is in your case the user probably cannot traverse /media in the first place (or in theory even /, but this would bring other noticeable problems). Existing permissions for /media may be for a reason, so think twice before you change them. An alternative is to mount sf_VMShare elsewhere, if possible.

2

For me is more simple with VirtualBox 6.0

  1. I have added my user to vboxfs group
sudo usermod -aG vboxsf $(whoami)
  1. Restart virtual machine

Test

  • Create a shared of external disk on host over /media/imac
abkrim@imail:~$ ls -lisah /media/
total 12K
8193 4.0K drwxr-xr-x  3 root root   4.0K Aug 23 19:44 .
   2 4.0K drwxr-xr-x 24 root root   4.0K Aug 23 18:42 ..
   1 4.0K drwxrwx---  1 root vboxsf 4.0K Aug 11 11:02 imac
abkrim@imail:~$ ls -lisah /media/imac/
total 374G
   1 4.0K drwxrwx--- 1 root vboxsf 4.0K Aug 11 11:02 .
8193 4.0K drwxr-xr-x 3 root root   4.0K Aug 23 19:44 ..
  17 374G -rwxrwx--- 1 root vboxsf 374G Aug 12 19:00 iMac-2019-05-24-124025.tar.bz2
abkrim@imail:~$ touch /media/imac/deleteme
abkrim@imail:~$ ls -lisah /media/imac/
total 374G
   1 4.0K drwxrwx--- 1 root vboxsf 4.0K Aug 23 19:44 .
8193 4.0K drwxr-xr-x 3 root root   4.0K Aug 23 19:44 ..
  18    0 -rwxrwx--- 1 root vboxsf    0 Aug 23 19:44 deleteme
  17 374G -rwxrwx--- 1 root vboxsf 374G Aug 12 19:00 iMac-2019-05-24-124025.tar.bz2

Work perfectly.

But in my system selinux is disable. In my opinion it does not make much sense a virtual machine that is surely being used for development or internally, having enabled by default selinux. It's something paranoid

abkrim@imail:~$ sestatus
SELinux status:                 disabled

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .