NFS oddity. It works, but it doesn't work

Hi,

This is a strange issue I’ve encountered trying to get an NFS share set up between two desktop PCs I have. I’m sure it’s something I’m doing that’s off, but I can’t quite figure out what that is.

Both PCs are running Manjaro. The Server is an old AMD 6-Core from like 2010 with a bunch of HDD storage. The Client is my current production machine - an AMD Ryzen 3900x. Let’s call them Zero and One. Because that’s what they’re called.

I’ve more or less followed this tutorial, modifying it slightly to suit my use case.

On the server (zero), I have two folders I’m trying to share with the client via NFS.
The first is the contents of a 3TB HDD with just a few different folders in it (Storage), which has a permanent mount point via fstab.
The second is a single folder (Videos) that contains four different mounted HDDs (Movies 1 & 2; TV 1 & 2), each with their own mount point within that folder set in fstab.

zero:/etc/fstab (this is just what using the gui in the gnome disks utility gave me)

/dev/disk/by-uuid/76d31525-0484-4678-a193-7846fa49eb8c /srv/nfs/Videos/TV auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/disk/by-uuid/7e50b2fd-f76c-4063-a323-c28a072aa6af /srv/nfs/Storage auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/disk/by-uuid/900dfc5d-63cf-4ca7-bd9c-7108e23013b1 /srv/nfs/Videos/Movies2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/disk/by-uuid/1755aee9-6201-4627-a343-b293c7ce51e8 /srv/nfs/Videos/TV2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/disk/by-uuid/99734e42-5010-4603-b559-5cb414df920f /srv/nfs/Videos/Movies auto nosuid,nodev,nofail,x-gvfs-show 0 0
# NFS Binding
/home/zero/Videos	/srv/nfs/Videos		none	bind	0 0
#/home/zero/Videos/Movies       /srv/nfs/Videos/Movies         none    bind    0 0
#/home/zero/Videos/Movies2       /srv/nfs/Videos/Movies2         none    bind    0 0
#/home/zero/Videos/TV       /srv/nfs/Videos/TV         none    bind    0 0
#/home/zero/Videos/TV2       /srv/nfs/Videos/TV2         none    bind    0 0
/home/zero/Storage	/srv/nfs/Storage	none	bind	0 0

zero:/etc/exports

/srv/nfs 192.168.88.0/24(rw,sync,crossmnt,subtree_check,fsid=0)
/srv/nfs/Videos/ 192.168.XXX.XXX(rw,sync,subtree_check)
/srv/nfs/Storage 192.168.XXX.XXX(rw,sync,subtree_check)

On the client (one), I have mount points set up for those exports.
one:/etc/fstab

zero-desktop:/srv/nfs /srv/nfs nfs rw,sync 0 0
zero-desktop:/srv/nfs/Videos /srv/nfs/Videos nfs rw,sync 0 0
zero-desktop:/srv/nfs/Storage /srv/nfs/Storage nfs rw,sync 0 0

Basically, per the tutorial, I’ve created my shared filesystem in /srv/nfs/, exported it from one to the other, and used symbolic links in the home folders on both PCs to link to those shared resources.

Here’s my problem:
The Storage folder works (flawlessly) on the client machine, but the Videos folder doesn’t.
On the server side, I can navigate (in terminal or nautilus) to the shared locations in /srv/nfs/ and navigate all of the folders fine. But in trying to mount them on the client, the folders are there, but they read empty.

I’ve also tried exporting/mounting the folders individually (i.e., separate mount points for Movies 1 & 2 and for TV 1 & 2) on both client and server, as shown commented out above, but it behaves the same.

What am I missing? Is it because each of those folders is its own HDD? Is it because I’m mounting/exporting directly from /srv/nfs/*? But if that’s the case, why does Storage work and not the others?

Kind of lost here, and I’m a little rusty with all this.

Thanks for any help.

I would check the folder permissions for the Videos folder on the server. Since the Storage folder works, Id make sure the Videos folder has the same permissions, owner, and group.

Confirmed.

But I do see that root owns all the subfolders (Movies 1 & 2, etc), and when I try to change those ownerships/permissions, I get denied - whether using sudo or directly as su. Let me try stopping the nfs service and trying again.

It should work with user ‘one’, right? Or do I have to create user ‘zero’ on the client?

The UIDs/GIDs need to match on the server and client. E.g, 1000, 1001, 1002, etc.

Think of NFS as a really long SATA cable to connect a drive that is far away from your computer. Permissions on the client machine are treated the same way. Just like if you attached a USB drive formatted in Ext4, the UID/GID on the external drive needs to match those of the current live system.

You can view the UIDs for each username under /etc/passwd


The reason “Storage” seems to be working is because is has full read-exec-write permission for “everybody”.


EDIT: I bet “zero” and “one” are both UID of 1000.

So basically, you need to change the ownership to 1000:1000, aka “zero:zero” (on the server) for the parent folders. Currently they are owned by root.

The parent folders being “Movies”, “Movies2”, “TV”, and “TV2”.

Now on the client, as the user “one”, you will be able to create folders and files within these parent folders.

I see. So, yes, that would be uid/gid 1000/1000, as is standard. I’ve never changed it on either system, anyway.
Interesting catch with the permissions, though. I’m pretty sure I’ve done a chown and chmod to those folders at some point, but I’ve changed things and restarted from scratch so many times now, it’s easy to miss a step on any given iteration of the process.

Your server - the zero engine

  1. Unmount all your devices
    sudo umount /home/zero/Storage
    sudo umount /home/zero/Videos
    sudo umount /srv/nfs/Videos/TV
    sudo umount /srv/nfs/Storage
    sudo umount /srv/nfs/Videos/Movies2
    sudo umount /srv/nfs/Videos/TV2
    sudo umount /srv/nfs/Videos/Movies
    
  2. don’t mount your disks in the srv structure - mount in dedicated structure
    sudo mkdir -p /data/Movies
    sudo mkdir -p /data/Movies2
    sudo mkdir -p /data/Storage
    sudo mkdir -p /data/TV
    sudo mkdir -p /data/TV2
    
  3. ensure rw permissions for everyone on the mount points
    sudo chmod ugo+rw /data -R
    
  4. Your folder structure in /srv
    sudo mkdir -p /srv/nfs/Videos/Movies
    sudo mkdir -p /srv/nfs/Videos/Movies2
    sudo mkdir -p /srv/nfs/Storage
    sudo mkdir -p /srv/nfs/Videos/TV
    sudo mkdir -p /srv/nfs/Videos/TV2
    
  5. Then in your fstab
    /dev/disk/by-uuid/76d31525-0484-4678-a193-7846fa49eb8c /data/TV auto nosuid,nodev,nofail,x-gvfs-show 0 0
    /dev/disk/by-uuid/7e50b2fd-f76c-4063-a323-c28a072aa6af /data/Storage auto nosuid,nodev,nofail,x-gvfs-show 0 0
    /dev/disk/by-uuid/900dfc5d-63cf-4ca7-bd9c-7108e23013b1 /data/Movies2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
    /dev/disk/by-uuid/1755aee9-6201-4627-a343-b293c7ce51e8 /data/TV2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
    /dev/disk/by-uuid/99734e42-5010-4603-b559-5cb414df920f /data/Movies auto nosuid,nodev,nofail,x-gvfs-show 0 0
    
  6. Then your bind mount in /etc/fstab
    /data/Movies  /srv/nfs/Videos/Movies none bind 0 0
    /data/Movies2 /srv/nfs/Videos/Movies2 none bind 0 0
    /data/Storage /srv/nfs/Storage none bind 0 0
    /data/TV      /srv/nfs/Videos/TV none bind 0 0
    /data/TV2     /srv/nfs/Videos/TV2 none bind 0 0
    
  7. If you want to access the files from the users home on zero you symlink the data location into home
    ln -s /data/Movies ~/Movies
    ln -s /data/Movies2 ~/Movies2
    ln -s /data/Storage ~/Storage
    ln -s /data/TV ~/TV
    ln -s /data/TV2 ~/TV2
    
  8. /etc/exports
    /srv/nfs 192.168.88.0/24(rw,sync,crossmnt,subtree_check,fsid=0)
    /srv/nfs/Videos 192.168.88.0/24(rw,sync,subtree_check)
    /srv/nfs/Storage 192.168.88.0/24(rw,sync,subtree_check)
    
  9. reboot your zero engine
    reboot
    

On your client - the one engine

Create a data structure for your mountpoints

sudo mkdir /data/Videos
sudo mkdir /data/Storage

Ensure rw permissions for everyone

sudo chmod ugo+rw /data -R

Switch to root context and enter the folder /etc/systemd/system

su -l root
cd /etc/systemd/system

Create a mount unit for the Videos share

cat <<EOF >> data-Videos.mount
[Unit]
Description=Videos NFS

[Mount]
What=zero-desktop:/srv/nfs/Videos
Where=/data/Videos
Type=nfs
Options=_netdev,auto

[Install]
WantedBy=multi-user.target
EOF

Create an automount unit for the Videos share

cat <<EOF >> data-Videos.automount
[Unit]
Description=Videos NFS

[Automount]
Where=/data/Videos
TimeoutIdleSec=300

[Install]
WantedBy=multi-user.target
EOF

Create a mount unit for the Storage share

cat <<EOF >> data-Storage.mount
[Unit]
Description=Storage NFS

[Mount]
What=zero-desktop:/srv/nfs/Storage
Where=/data/Storage
Type=nfs
Options=_netdev,auto

[Install]
WantedBy=multi-user.target
EOF

Create an automount unit for the Storage share

cat <<EOF >> data-Storage.automount
[Unit]
Description=Storage NFS

[Automount]
Where=/data/Storage
TimeoutIdleSec=300

[Install]
WantedBy=multi-user.target
EOF

Enable and start the automount units

systemctl enable --now data-Videos.automount data-Storage.automount

Exit root context

exit

Browse the folder /data/Videos and /data/Storage - and note how they mount on access

1 Like

Thank you, all, for your help. It ended up being a combination of permissions on both computers.

On the server side, it was a matter of not having rw permissions for the Videos sub-folder’s mounting locations. Then, on the client side, I not only didn’t have rw permission but also ended up not owning the mounting locations.

It seems that since I hadn’t created the sub-folders to mount to on the client, root was doing it in the sudo mount -a process, which left me not owning the folders and not being able to read/write. Then, while everything’s mounted, not even root can change the ownership/permissions.

So, @linux-aarhus, yours is basically the process I ended up bumbling through until the wee hours. I did end up leaving the /srv/nfs structure in place, though, since that’s what worked when it finally worked. I’ll try correcting that issue one day when I have six or seven hours to kill.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.