0

I have two machines A and B on my local network (both Ubuntu 21.10).

On machine A I have a drive only for data (music, photos, films, documents, etc) mounted on /media/data. Every user (there are 2) on the machine can read/write drive content.

I need to be able to do the same from my machine B (where there is only one user), meaning read/write access.

In this case what is the appropriate method in order to achieve that ? considering that :

  • I need user from machine B to not create permissions issues to users of machine A
  • I need my programs from machine B to have correct permissions to read/write to the drive

Those two needs have not been quite met with the previous setup that I have tried. This is why I specify this. Though they might have not been met because my setup was not correct... I don't know. I've been learning and trying things out for the past year.

So here is what I have already tried :

  • sharing via Samba local network share --> access to files (playing music for example) was slow

  • sshfs :

    • I never managed to set it up correctly to automount on startup
    • I have permissions problems. For example : when using beets (to manage my music library), beets creates folders/files which are owned (on machine B) by a user listed as #user 1001. This user is unknown from the system but it is the uid of the user I ssh with on machine A (and it is different from my uid on machine B) and I don't have permissions to modify anything (ownership, delete file, etc). I didn't manage to solve this so the sshfs solution is not acceptable as is for my use.
  • NFS : I just tried out today and didn't manage to pass a mount.nfs: access denied by server while mounting (null) error

So now I decided to stop trying things because I'm a bit lost and don't really know what I should actually try : better understand sshfs to solve permission problems ? make NFS work ?... and decided to ask for help :)

Until now using sshfs has been the best solution for me (access to files is fast and stable) but without solving these permission problems it's not good enough, and also if I could correctly set up automount on startup it would be even better...

Thanks for your help !

Edit

Concerning NFS this is what I did :

  • install nfs-kernel-server on machine A
  • install nfs-common on machine B
  • added line /media/data 00.00.00.00(rw,sync,no_subtree_check) (with the IP address of machine B) in /etc/exportfs of machine A
  • ran sudo exportfs -a
  • I checked the modification with sudo exportfs
  • I allowed nfs in the firewall (ufw)
  • I checked that I could see the export from machine B with showmount and I could see it
  • When trying to mount the folder with sudo mount 00.00.00.00:/media/data ~/data (with IP address of machine A) it returns mount.nfs: access denied by server while mounting (null)
raph
  • 78
  • It’s interesting that you say Samba was slow. This is what I use on my home network and can consistently move data at several hundred megabytes per second. Could you elaborate on the issues with Samba? – matigo Mar 19 '22 at 11:23
  • I use Samba to interlace 6 machines and a NAS sharing files and I have never had any slow down and get the full speed the wire supports. So like matigo said – David Mar 19 '22 at 11:25
  • For your sshfs permission problem, see https://unix.stackexchange.com/questions/81707/how-to-map-users-and-group-with-sshfs. For sshfs automount see https://askubuntu.com/questions/43363/how-to-auto-mount-using-sshfs – user535733 Mar 19 '22 at 11:28
  • 2
    NFS is the standard tool for this. Can you tell us how you tried it so we can help you out? I wouldn't recommend samba since that is primarily a tool for interacting with Windows systems, for a Linux-only setup NFS should be much better. – terdon Mar 19 '22 at 11:58
  • Thanks for your comments. Since from my other readings I also understand that Samba was designed to interact with Windows (this is not my case), and that NFS is supposed to do exactly that, I will probably try this way (@terdon I added information about what I did with NFS). I will also read more about sshfs, thanks for the links. – raph Mar 19 '22 at 13:19
  • 1
    I have an Ubuntu 20.04 server and two Arch Linux clients. I found the Arch Linux wiki very helpful for setting up NFS. Whilst the package names are different in Ubuntu the configuration was the same. Note that your machine A needs to be set up as a server while machine B is a client. https://wiki.archlinux.org/title/NFS The Arch Linux wiki is very helpful for lots of topics – PonJar Mar 19 '22 at 13:34
  • Thanks @PonJar, following the arch linux guide I managed to mount using NFS. I will make some tests of this solution and edit question/answer if this solves my problem. – raph Mar 22 '22 at 10:19

1 Answers1

0

So I opted for the NFS method and made it work nicely thanks to the Arch Linux wiki link posted by @PonJar in the comments above : https://wiki.archlinux.org/title/NFS The main difference is that you need packages nfs-kernel-server for the server machine and nfs-common for the client machine.

What I did differently from what is exposed in my Edit about NFS in the question is mainly that :

  • I created a nfs folder and data subfolder to share in /srv/nfs/data
  • I binded the /srv/nfs/data folder to the one I wanted to export which was /media/data

Otherwise I checked that the export was correct and that I could see it from my client machine (note : showmount does not work when the firewall is active on the server machine, so check before setting it up) and I opened ports for nfs in the ufw firewall.

I then mounted successfully the drive with sudo mount -t nfs -v 192.168.1.108:/srv/nfs/data ~/data

Finally I added the following line in /etc/fstab : 192.168.1.108:/srv/nfs/data /home/myuser/data nfs defaults,_netdev 0 0 and the folder is now automatically mounted at boot.

This method seems to solve the permission issues that I ran into sometimes.

raph
  • 78