1

I have Windows 10 running on a laptop that runs VirtualBox that runs a Linux guest.

I do a lot of programming for the Linux environment and am working with sourcecode repositories sitting in an FS / directory tree shared between the Windows host and Linux guest, e.g. editing with SublimeText running under Windows, but doing compiling, testing, version control etc in a terminal connected to the Linux guest.

For various reasons I need the directories hosting the sourcecode repositories to allow full unix semantics, i.e. be able to set uid/gid for owner, permission bits, create fifos, symlinks, etc. etc.

I don't care if these features aren't meaningfully shared between Windows and Linux. I only need these things to be well-defined on the Linux-side. On the Windows-side, I just need to be able to read/write the file contents.

I want the files to be hosted on the Windows/host-side, not the Linux guest, as I don't want to have to fire up the Linux guest for the files to become visible/accessible on Windows.

How can I set such a thing up?

I've tried various things.

It seems, vboxsf offers only a small subset of unix features. Please correct me if I'm wrong.

I've tried posixovl on top of a vboxsf mount, but I can't seem to be able to get it to support a simple operation like "mkdir mydir; rm -rf mydir". Such an operation would fail with "rm: cannot remove 'mydir': Directory not empty". My diagnosis of the problem with that is that it'll create a file "somedir/.pxovl" to keep somedir's permission bits and stuff like that on the lower FS. On the upper FS that file is not visible, so "rm -rf" can't get rid of the file. When "rm -rf" tries to "rmdir mydir" on the upper FS, that will trigger an attempt to do so on the lower FS which fails because the file ".pxovl" is still there. Please do correct me if there is a solution to that, but it's driving me crazy.

I've tried setting up a directory as a network share on the windows side, then mounting via mount.cifs on linux. It seems that such a mount doesn't properly offer unix features either, and in that sense has limitations similar to vboxsf, and I can't find any options that would allow for any kind of emulation or anything like that.

It has occurred to me that maybe there might be programs that can be set up on the Windows host side that offer real unix semantics and do some kind of emulation of unix features like an NFS server or other kind of server for network shared filesystems, but I can't seem to find any.

It has also occurred to me that overlay filesystems might be a useful tool to bring such a solution about but can't really conceptualize what such a solution might look like.

Any ideas?

2 Answers 2

1

It turned out that I could get close to what I wanted through a combination of

  • WSL using the new drvfs features where certain aspects of unix semantics are emulated under WSL (metadata option to the drvfs mount);
  • sshd running on that WSL on the windows host;
  • sshfs running on the VirtualBox guest under Linux.

The solution was:

  • Installing Ubuntu for Windows (WSL).
  • Enabling passwordless sudo under WSL using the line %sudo ALL=(ALL:ALL) NOPASSWD: ALL in /etc/sudoers on WSL.
  • Putting the command "bash -c 'sudo /etc/init.d/ssh start'" on autostart under windows using the registry so that the WSL-based OpenSSH server starts automatically as soon as I log in.
  • Configuring the Windows Defender firewall so as to allow connections to port 22.
  • Setting up SSH keys so as to allow for passwordless login from the linux guest to the WSL-based SSH server.
  • Using wsl.conf to inject the options metadata,umask=0002,fmask=0113 when mounting drvfs on WSL.
  • On the linux guest, putting user_allow_other in /etc/fuse.conf
  • On the linux guest, putting sudo -u myuser sshfs -o allow_other myuser@windowshost:/mnt/c /mnt/c to share the C-Drive.
  • Making sure the UID for myuser are the same between WSL and Linux.

RESULT: This makes it so that filenames and file contents are shared between Windows, WSL and Linux on the guest VM, that additional unix capabilities such as permission-bits and links are emulated, and that those emulated features are shared between WSL and Linux. But:

  • LIMITATION: When I create a file, even through a user other than myuser on the Linux guest, it will end up being owned by myuser.
  • LIMITATION: fifos are not supported.
  • I can live with those limitations, since I don't need fifos, and really only care about what happens to file that I work with under the one user that I use for software development on my laptop.
0

Unfortunately Windows doesn't consider files to have the same metadata that Linux/Unix systems do - this leads to the headache that you're currently experiencing.

My solution (unfortunately for you) would be to hold the files on the Linux VM, and use CIFS / Samba to share them with the Windows host - I do this often.

I'm not aware of any way to achieve the transparency and reliability that you're after, while hosting the files on a Windows (non-Unix) filesystem.


It might be worth digging into Windows Subsystem for Linux. They've been making strides recently (e.g: Chmod/Chown WSL Improvements), so you might be able to install an NFS server or something under WSL to achieve what you're after, but given where NFS is implemented on Linux (in the kernel), this is likely out of the question.

1
  • Thanks for the hint on WSL. I am using WSL already, but didn't realize that it now had this feature to emulate unix filesystem semantics on shared folders. I guess that's one step in the right direction, if only i can figure out a way to host a fileserver in WSL now. It doesn't need to be a traditional fileserver, I guess, with things like SSHFS being in existence. I'll do some more digging/experimenting in that direction.
    – R Bergmair
    Jul 3, 2018 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.