Linux mounts NFS with a specific user

I searched the watch on the Internet, but for this particular problem I could not find a solution.

1: I have Xubuntu Linux on my PC. I use it in a medium way: browsing the Internet, watching videos, etc. And also it gives home my PHPStorm application, but not project files. This is HOST. It has a host-only network: 192.168.56.1

2: I have a VirtualBox Debian Linux system (no GUI). This meant to be a version of my real web server. It has all the project files. This virtual machine is located on an external drive, so I can take it everywhere (for example, to the office). 192.168.56.101 . This is a GUEST.

3: in HOST, I use dnsmasq so that every * .dev domain is redirected to GUEST. Therefore, I can easily test my projects.

4: in GUEST, I exported the /var/www folder to /etc/exports :

 /var/www 192.168.56.1(rw,sync,no_root_squash,no_subtree_check) 

Problem: I want to use PHPStorm in HOST to edit files in GUEST "locally". But I can not install GUEST /var/www in the HOST /home/gabor/Projects folder with full permissions. I tried using the following:

 $> sudo mount 192.168.56.101:/var/www /home/gabor/Projects 

This looks fine the first time, but the folder is mounted using nobody:nogoup , and I do not have permission to edit it.

I want /home/gabor/Projects have the owner gabor:gabor , and everything I create in this folder should have the owner www-data:www-data on the Debian side. But to install NFS, I can not specify the user.

 $> sudo mount -o umask=0022,gid=1000,uid=1000 192.168.56.101:/var/www /home/gabor/Projects mount.nfs: an incorrect mount option was specified 

I also could not mount --bind /var/www with another user (must be nobody:nogroup ) on Debian so that I can export this ...

How can I solve this problem? Please help me. Thanks.

+5
source share
2 answers

Well, I found a solution that exactly does what I want.

Install sshfs first:

 $> sudo apt-get install sshfs 

Then mount the remote /var/www :

 $> sshfs -o uid=33,gid=33 root@192.168.56.101 :/var/www /home/gabor/Projects 

And it's all!

 $> ls -la /home/gabor | grep Projects drwxr-xr-x 1 www-data www-data 4096 Okt 14 21:10 Projects 
0
source

NFS v2 and v3 do not support uid / gid.

on ubuntu man nfs

0
source

Source: https://habr.com/ru/post/1204503/


All Articles