How to process files from a different computer?

I quoted the part…

No… check the UID and change it: id on the client.

The permissions of the folder will not change, but the content of the mountpoint.

Ok I saw it in three parts so I thought only the first part went with the quoted text.

Well I’ve checked the UIDs and they are the same so I’ll be sure never to create another user just so I don’t have to complicate this any further. I don’t understand why it doesn’t just share it with all users instead of having to be checking the user id. As if it wasn’t difficult enough already.

Check: man exports and search for anonuid and anongid. Maybe this is what you want.

server ❯ sudo cat /etc/systemd/system/mnt-V.mount
[Unit]
Description=My shared partition

[Mount]
What=/dev/disk/by-uuid/4435D137344DB3E9
Where=/mnt/V
Type=ntfs
Options=defaults,rw,noatime,uid=1000,gid=1000,dmask=0002,fmask=0113,windows_names,hide_hid_files,hide_dot_files,big_writes

[Install]
WantedBy=multi-user.target

server ❯ sudo umount /mnt/V
server ❯ sudo systemctl start mnt-V.automount
server ❯ ls -l /mnt/V
drwxrwxrwx 1 root root 4096 jun  5 19:49 'System Volume Information'
client ❯ sudo mount -t nfs 192.168.1.122:/V /mnt/V
client ❯ ls -l /mnt/V
total 0

Give you a favor and use a linux filesystem with NFS. Like ext4. NTFS is by all mean not tested with it.

1 Like

I have a hard time understanding why you cannot get it to work - I even began questioning my guide.

Now I can’t have that - so I went over to the guide - the guide I wrote many moons ago - I went through it step by step.

To have something to work with - you gotta love those rpi boards - I created a sdcard with a minimal manjaro arm.

Booted the pi - initial oem setup aside - I took my test USB - created earlier today - NTFS formatted and all.

I followed my guide to the letter

  • setting up a mount unit
  • mounting the usb by uuid
  • checked the mount point - checked it was writable (as it is ntfs there is no point in setting permissions)
  • enable nfs-server.service
  • modify /etc/exports (nfs v4)
  • created a service folder /srv/nfs/ntfs
  • did a bind mount

Over to my workstation

  • enable nfs-client.target
  • create a mount point
  • took a shortcut
  • only manual mount in a temp folder in my home
  • but it worked
  • listed existing files - test I created earlier on the pi
  • created a new file

So I realised - the guide is OK - if you follow it to the letter - it works - and as it is ntfs - which Linux do - permission wise - treat like an exfat system - world read-write - even when shared across computers using NFS.

1 Like

I’ve decided to use an ext4 hard drive so I’ll restart the process in a few weeks. Meanwhile I would like to leave the system as it was. But I’m having trouble: Drive changed name after reverting changes of sharing data using NFS

I’ve retried with an ext4 drive with no luck. The only thing different I’ve done from the guide is that instead of a bind mount I’ve mounted the drive directly to the /srv/nfs location.

s: server, c: client
s ❯ sudo mkdir -p /srv/nfs/V
s ❯ sudo chmod ugo+rwx /srv/nfs/V
s ❯ sudo umount /run/media/user/V
s ❯ lsblk -no UUID /dev/sdd1
61aea4de-aa02-4f6d-b77d-dc0b09eac2ca

s ❯ sudo blkid
/dev/sdd1: LABEL="V" UUID="61aea4de-aa02-4f6d-b77d-dc0b09eac2ca" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="823000c4-e3eb-434a-a5f9-009571ecd1c8"

s ❯ sudo cat /etc/systemd/system/srv-nfs-V.mount
[Unit]
Description=My shared partition

[Mount]
What=/dev/disk/by-uuid/61aea4de-aa02-4f6d-b77d-dc0b09eac2ca
Where=/srv/nfs/V
Type=nfs
Options=defaults,rw,noatime

[Install]
WantedBy=multi-user.target

s ❯ sudo cat /etc/systemd/system/srv-nfs-V.automount
[Unit]
Description=Automount shared partition
ConditionPathExists=/srv/nfs/V

[Automount]
Where=/srv/nfs/V
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target

s ❯ sudo systemctl enable --now srv-nfs-V.automount
s ❯ ls -l /srv/nfs/V
ls: cannot open directory '/srv/nfs/V': No such device
s ❯ sudo rm /etc/systemd/system/*mount
s ❯ sudo cat /etc/fstab
UUID=61aea4de-aa02-4f6d-b77d-dc0b09eac2ca /srv/nfs/V ext4 defaults,noatime 0 0
s ❯ sudo systemctl daemon-reload
s ❯ sudo mount -a
s ❯ ls -l /srv/nfs/V
total 24
s ❯ sudo ln -s /srv/nfs/V /run/media/user/V
s ❯ sudo cat /etc/exports
/srv/nfs            192.168.1.118(rw,sync,crossmnt,fsid=0)
/srv/nfs/V          192.168.1.118(rw,sync)

s ❯ sudo systemctl enable --now nfs-server.service

c ❯ sudo systemctl enable --now nfs-client.target
c ❯ sudo cat /etc/fstab
192.168.1.122:/nfs/V   /srv/nfs/V  nfs auto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0
c ❯ sudo systemctl daemon-reload
c ❯ sudo mkdir -p /srv/nfs/V
c ❯ sudo mount -a
mount.nfs: Operation not permitted

I removed the line from /etc/fstab and tried manually:

c ❯ sudo systemctl daemon-reload
c ❯ sudo mount -t nfs 192.168.1.122:/V /srv/nfs/V
mount.nfs: Operation not permitted
c ❯ sudo mkdir -p /mnt/V
c ❯ sudo mount -t nfs 192.168.1.122:/V /mnt/V
mount.nfs: Operation not permitted

You need to choose either use fstab or use mount unit. Not both.

I know I tried with systemd mount units but it didn’t work, so I deleted the systemd mount units and used fstab instead. I’m going to try following the guide more closely because I always make some modification.

…you can make modifications
once you have established a working variant …:wink:

I’ve tried again following the instructions more carefully but it’s the same. I remember last time I at least was able to mount the drive but it had the wrong permissions, now it’s not even mounting. Should I reinstall manjaro on both computers and try with a clean install?

s: server, c: client
s ❯ sudo mkdir -p /mnt/V
s ❯ sudo chmod ugo+rwx /mnt/V

Using gnome-disks, Unmount selected partition, select Aditional partition options, select Edit Mount Options..., uncheck User Session Defaults, check Mount at system startup, check Show in user interface, additional options nosuid,nodev,nofail,x-gvfs-show, Mount Point /mnt/V, Identify As /dev/disk/by-uuid/61aea4de-aa02-4f6d-b77d-dc0b09eac2ca, Filesystem Type auto. Click Mount selected partition.

s ❯ ls /mnt/V
works

s ❯ sudo mkdir -p /srv/nfs/V
s ❯ sudo cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=E07B-7D04                            /boot/efi      vfat    umask=0077 0 2
UUID=2155c93c-6df9-458f-a4f7-03bac36ddc44 /              ext4    defaults,noatime 0 1
UUID=1240fd8e-56c9-4e64-a798-2a3cade0cec4 swap           swap    defaults,noatime 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
/dev/disk/by-uuid/61aea4de-aa02-4f6d-b77d-dc0b09eac2ca /mnt/V auto nosuid,nodev,nofail,x-gvfs-show 0 0
/mnt/V /srv/nfs/V none bind 0 0

s ❯ sudo systemctl daemon-reload
s ❯ sudo mount -a
s ❯ sudo cat /etc/exports
# /etc/exports - exports(5) - directories exported to NFS clients
#
# Example for NFSv3:
#  /srv/home        hostname1(rw,sync) hostname2(ro,sync)
# Example for NFSv4:
#  /srv/nfs4        hostname1(rw,sync,fsid=0)
#  /srv/nfs4/home   hostname1(rw,sync,nohide)
# Using Kerberos and integrity checking:
#  /srv/nfs4        *(rw,sync,sec=krb5i,fsid=0)
#  /srv/nfs4/home   *(rw,sync,sec=krb5i,nohide)
#
# Use `exportfs -arv` to reload.
/srv/nfs            192.168.1.0/24(rw,sync,crossmnt,fsid=0)
/srv/nfs/V          192.168.1.0/24(rw,sync)

s ❯ ls -l /srv/nfs
total 4
drwxrwxrwx 5 user user 4096 jul 22 23:23 V

s ❯ ls -l /srv/nfs/V
total 24
drwxrwxrwx  3 user user  4096 jul 22 23:34 dl
drwx------  2 root root 16384 jul 21 18:22 lost+found

s ❯ sudo systemctl enable --now nfs-server.service
c ❯ sudo systemctl enable --now nfs-client.target
c ❯ sudo mkdir -p /mnt/V
c ❯ sudo mount -t 192.168.1.122:/V /mnt/V
mount: /mnt/V: can't find in /etc/fstab.
c ❯ sudo cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=5053-CB3F                            /boot/efi      vfat    umask=0077 0 2
UUID=9b3a496c-b2ab-4bf0-ba72-a1c49e0e82ad /              ext4    defaults,noatime 0 1
UUID=6b1020ba-f8d5-48d9-bd19-3b9c984bd1d8 swap           swap    defaults,noatime 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
arch-desktop01:/nfs/V   /mnt/V  nfs auto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0

c ❯ sudo systemctl daemon-reload
c ❯ sudo mount -a
mount.nfs: Failed to resolve server arch-desktop01: Name or service not known

If I replace arch-desktop01 for 192.168.1.122 and repeat the last steps I get:

c ❯ sudo mount -a
Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.
mount.nfs: mounting 192.168.1.122:/nfs/V failed, reason given by server: No such file or directory

what was the “working variant”?

I’m too tired right now to assess what you wrote
or to debug it

Here I managed to mount the NFS shared folder in the client computer, but all was owned by root and I couldn’t use it. I was using an NTFS partition then, now I’m using an ext4 one.

Is there a way to know if the NFS folder is actually being shared? Can I open with nemo file manager or in some other way other than mounting it?

If the service is configured - then likely it is

showmount -e servername

It doesn’t seem to be exporting it. I was missing an instruction. That doesn’t appear in the guide.

s ❯ showmount -e arch-desktop01
Export list for arch-desktop01:
s ❯ sudo exportfs -arv
s ❯ showmount -e 192.168.1.122
Export list for 192.168.1.122:
/srv/nfs/V 192.168.1.0/24
/srv/nfs   192.168.1.0/24

I am truly impressed.

You are able to completely confuse yourself and run in circles around a truly simple operation.

Ok - I admit - if you are not familiar with *nix concepts it is not simple …

Server

  1. Define device mount using UUID (persistent device name)

    • device UUID → $(lsbl -no UUID /dev/sdy1)
    • mount point → /a/nfs

    create mount unit a-nfs.mount with content

    [Unit]
    Description=Demo NFS share mount   
    [Mount]
    What=/dev/disk/by-uuid/4fdcb623-71ce-4840-ac50-021413cbfd4a
    Where=/a/nfs
    Options=defaults,rw,noatime   
    [Install]
    WantedBy=multi-user.target
    
  2. Mount device

    systemctl enable --now a-nfs.mount
    
  3. Bind mount in fstab

    /a/nfs  /srv/nfs/share  none bind 0 0
    
  4. Ensure service folder is created

    mkdir -p /srv/nfs/share
    
  5. Ensure mount point has rw permissions

    chmod 777 /a/nfs
    
  6. Ensure NFS service enabled and up

    systemctl enable --now nfs-server
    
  7. Create NFS export file with a rw share

    /srv/nfs        tiger.net.nix.dk(rw,sync,fsid=0,no_subtree_check)
    /srv/nfs/share  tiger.net.nix.dk(rw,sync,no_subtree_check)
    
  8. Reload NFS exports

    # exportfs -arv
    exporting tiger.net.nix.dk:/srv/nfs/share
    exporting tiger.net.nix.dk:/srv/nfs
    
  9. Verify export

    # showmount -e pw0.net.nix.dk
    Export list for pw0.net.nix.dk:
    /srv/nfs/share tiger.net.nix.dk
    /srv/nfs       tiger.net.nix.dk
    

Client

  1. Verify the share can be reached

    $ showmount -e pw0.net.nix.dk
    Export list for pw0.net.nix.dk:
    /srv/nfs/share tiger.net.nix.dk
    /srv/nfs       tiger.net.nix.dk
    
  2. Define NFS mount and mountpoint

    • mount point → /a/nfs
    • mount unit → a-nfs.mount

    create mount unit a-nfs.mount with content

    [Unit]
    Description=Demo NFS share mount
    
    [Mount]
    What=pw0.net.nix.dk:/share
    Where=/a/nfs
    Type=nfs
    Options=_netdev,rw
    
    [Install]
    WantedBy=multi-user.target
    
  3. Create automount

    • automount unit → a-nfs.automount

    create automount unit a-nfs.automount with content

    [Unit]
    Description=Demo NFS client mount
    
    [Automount]
    Where=/a/nfs
    TimeoutIdleSec=10
    
    [Install]
    WantedBy=multi-user.target
    
  4. Start the mount unit once and stop it

    systemctl start a-nfs.mount
    systemctl stop a-nfs.mount
    
  5. Ensure mount point has rw permission

    chmod 777 /a/nfs
    
  6. Enable and start the automount unit

    systemctl enable --now a-nfs.automount
    

Done

On the client browse the share using your file manager

fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
fh@tiger ~ $ touch /a/nfs/new_client_file.txt
fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh fh 0 Jul 24 17:03 new_client_file.txt

Visualising point made by @winnie in below comment

fh@tiger ~ $ ls /a/nfs
file.txt  new_client_file.txt  non_root_server_user.txt
fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh   fh   0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh   fh   0 Jul 24 17:03 new_client_file.txt
-rw-r--r-- 1 1001 1001 0 Jul 24 17:18 non_root_server_user.txt
fh@tiger ~ $ echo "TEST" > /a/nfs/non_root_server_user.txt
bash: /a/nfs/non_root_server_user.txt: cannot overwrite existing file
fh@tiger ~ $ echo "TEST" >> /a/nfs/non_root_server_user.txt
bash: /a/nfs/non_root_server_user.txt: Permission denied
fh@tiger ~ $ ls -l /a/nfs
total 1
-rw-r--r-- 1 fh   fh    0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh   fh    0 Jul 24 17:03 new_client_file.txt
-rw-r--r-- 1 1001 1001 48 Jul 24 17:22 non_root_server_user.txt
fh@tiger ~ $ cat /a/nfs/non_root_server_user.txt 
fh@pw0.net.nix.dk owns the content of this file
fh@tiger ~ $ cat /a/nfs/file.txt
TEST
fh@tiger ~ $ cat /a/nfs/file.txt
TEST

nix@pw0.net.nix.dk owns this file. 
Because the user have the same UID as fh@tiger both can write the file
Confused?

3 Likes

The permissions and ownership of the files on the remote NFS server itself must have matching UIDs/GIDs on your local client.

So if on your remote server there exists a UID/GID of 1002/1002, which is the user quake, then on your client computer there must also exist the UID/GID of 1002/1002 (of which the name can be the same if you like.)

This was explained earlier by @megavolt, and I believe it is the main cause of your issues.

:point_down:


If if helps to visualize this differently, imagine NFS as a locally connected drive, yet using an ethernet cable instead of a SATA or USB cable.

Would you expect a locally connected Ext4 drive to “just work” on your computer, if the permissions/ownership of the files on this particular drive don’t even match those of your running system? The same principle applies to NFS (for the most part.)

3 Likes

I followed this other guide and it worked. Although I followed the same steps with 4 different drives and I see in all the folders the same files. So it’s like I’ve made 4 mount points in the client computer for the same hard drive from the server. But at least I can use the script in a hard drive from another computer and that’s what I wanted to do, so it’s good enough.

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