3

I have a virtualbox VM with arch Linux running on my windows PC (which I unfortunately have to use for work). I use this to work on my windows PC with a Linux environment as an alternative to Cygwin.

I have set up a Virtualbox shared folder which shares my C:\ drive with my Linux VM but I seem to be unable to change the file permissions within any of the folders. This is a problem as now git thinks all of my files permissions have changed.

» ll README.txt
-rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt
» chmod 644 README.txt
» ll README.txt
-rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt
» sudo chmod 644 README.txt
» ll README.txt
-rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt
» git diff README.txt | cat
diff --git a/README.txt b/README.txt
old mode 100644
new mode 100755

How do I fix this?

The folder was mounted using Automount from the VirtualBox Manager on windows.

Mike H-R
  • 259
  • 3
  • 12

2 Answers2

3

This will not work as it unlikely that your hosts mapped in filesystem (i.e. Windows C: drive, so most likely NTFS) supports the full range of permission bits that Linux git expects.

In a similar situation I have exported a Linux directory via Samba and used that from Windows and Linux without problems. This however has the disadvantage that you cannot access the data when the VM is not running.

Anthon
  • 79,293
  • hmmm... that is very annoying. do you have any idea why, when I edit a file in the VM and save it, the permissions in cygwin have changed to 755 (from the previous 644)? surely NTFS must support filesystem permissions to the point where it will modify it, which is what I need? – Mike H-R Oct 28 '14 at 12:03
  • @MikeH-R AFAIK NTFS has only a subset, but I don't know exactly which. – Anthon Oct 28 '14 at 12:05
  • hmmm... so no idea on how to get virtualbox to save to a different member of the subset? – Mike H-R Oct 28 '14 at 12:06
  • @MikeH-R Sorry, no. If you don't want or cannot go the Samba route I suggested, you should bite the bullet and tell git these are the new file permissions, and handle resetting them during installation if necessary. – Anthon Oct 28 '14 at 12:11
  • I was afraid that might be the only option. I guess samba is probably the way to go. I don't suppose you have a link to any documentation on setting up samba between a guest linux OS and windows host? (or anything similar) – Mike H-R Oct 28 '14 at 12:13
  • I have setup a samba share on my virtual OS but neither loading the files from windows nor loading the files from linux onto windows fixes the file permissions problem – Mike H-R Oct 28 '14 at 14:40
  • @MikeH-R you mean on your VM you have the same chmod 644 not catching on problem, or that GIT complains about the now incorrect file permissions? How did you get those files there? A new git clone from remote? – Anthon Oct 28 '14 at 14:43
  • hmm... reading now I may have configured samba incorrectly without acl or something. It's my understanding that if I look at a windows shared folder from my linux vm or look at my vm shared folder from my cygwin on linux the file permissions should be correct (the same in both cases). – Mike H-R Oct 28 '14 at 14:54
  • @MikeH-R you should not have cygwin on Linux, you don't need ACLs. Windows and Linux don't have the same permission perception, they cannot look the same. – Anthon Oct 28 '14 at 15:03
  • You're right, I don't have cygwin on linux, i have cygwin on windows, setting the posix permissions through cygwin is translated into windows acl's as far as i know. Also from what I've read samba should translate (a subset of) the windows permissions to posix permissions on connecting to the shared folder. Or rather that's how I've been understanding it. On looking at the windows permissions in properties they correspond to the POSIX permissions. – Mike H-R Oct 28 '14 at 15:13
  • also reading around POSIX filesystem permissions are a subset of windows ACL permissions so it should be possible to map the windows ones to the posix ones (then again, it's probably wishful thinking on my part). I don't suppose you have any idea how that might work? – Mike H-R Oct 28 '14 at 15:19
  • An answer to my questions about acl's and the solution that I took is available here – Mike H-R Oct 29 '14 at 11:08
  • @MikeH-R Am I right that means the files are hosted on the windows native partition, not on the disc in the VM? That would be completely different from what I suggested and would explain the difficulties. I am glad you found a working solution. – Anthon Oct 29 '14 at 11:15
  • yes, you are correct. I tried hosting the files on the samba partition but couldn't build the solution on windows (a requirement). Might've forgotten to mention that as I was iterating on my solutions though I do remember. Thanks again for your help. – Mike H-R Oct 29 '14 at 11:22
2

To Linux, the file system mounted to the host is to a foreign machine, so it does not have any control over the permissions of the files in that system. That control belongs to the host. So you need to adjust the permissions in a part of the drive that you can constrol.

I link my Virtual Box to a subdirectory of my Documents folder. That way I can open up the permissions without worrying about hurting the host systems OS files.