How to process files from a different computer?

How did you set /etc/exports ?

Assuming the source of the script is not just a random piece you find useful - there is a lot hard coded paths which likely will cause issues unless you refactor to fit your exact use case.

And no - I won’t help with that.

I’ve repeated the process with another drive and adding that instruction but I still see everything owned by root.

server ❯ sudo mkdir -p /mnt/V
server ❯ sudo chmod ugo+rwx /mnt/V
server ❯ sudo umount /run/media/user/V
server ❯ lsblk -no UUID /dev/sdc1
4435D137344DB3E9
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

[Install]
WantedBy=multi-user.target
server ❯ sudo cat /etc/systemd/system/mnt-V.automount
[Unit]
Description=Automount shared partition
ConditionPathExists=/mnt/V

[Automount]
Where=/mnt/V
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target
server ❯ sudo systemctl enable --now mnt-V.automount
server ❯ ls -l /mnt
drwxrwxrwx 1 root root 4096 jun 28 18:10 V
server ❯ ls -l /mnt/V
everything is owned by root
server ❯ sudo cat /etc/fstab
/mnt/V /srv/nfs/V none bind 0 0
server ❯ sudo mkdir -p /srv/nfs/V
server ❯ systemctl daemon-reload
server ❯ sudo mount -a
server ❯ ls -l /srv/nfs
drwxr-xr-x 2 root root 4096 jul 17 15:11 V

Seriously? NTFS don’t save Linux permissions on its filesystem. You have to set it as a option when mounting.

2 Likes

I’ve followed this tutorial to share a folder with NFS but maybe because the folder is a NTFS partition all files are owned by root and I can’t use them.

This is what I’ve done, I need to fix whatever I’ve done wrong.

server ❯ sudo mkdir -p /mnt/V
server ❯ sudo chmod ugo+rwx /mnt/V
server ❯ sudo umount /run/media/user/V
server ❯ lsblk -no UUID /dev/sdc1
4435D137344DB3E9
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

[Install]
WantedBy=multi-user.target
server ❯ sudo cat /etc/systemd/system/mnt-V.automount
[Unit]
Description=Automount shared partition
ConditionPathExists=/mnt/V

[Automount]
Where=/mnt/V
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target
server ❯ sudo systemctl enable --now mnt-V.automount
server ❯ ls -l /mnt
drwxrwxrwx 1 root root 4096 jun 28 18:10 V
server ❯ ls -l /mnt/V
everything is owned by root
server ❯ sudo cat /etc/fstab
/mnt/V /srv/nfs/V none bind 0 0
server ❯ sudo mkdir -p /srv/nfs/V
server ❯ systemctl daemon-reload
server ❯ sudo mount -a
server ❯ ls -l /srv/nfs
drwxr-xr-x 2 root root 4096 jul 17 15:11 V
server ❯ sudo cat /etc/exports
/srv/nfs            192.168.1.0/24(rw,sync,crossmnt,fsid=0)
/srv/nfs/V          192.168.1.0/24(rw,sync)
server ❯ systemctl enable --now nfs-server.service
client ❯ systemctl enable --now nfs-client.target
client ❯ sudo mkdir -p /mnt/V
client ❯ sudo mount -t nfs 192.168.1.122:/V /mnt/V
client ❯ ls -l /mnt
drwxr-xr-x 2 root root 4096 jul 17 15:11 V

Additionally set Owner and Group:

uid=1000,gid=1000

Set permissions:

dmask=0002,fmask=0113
  • files: -rw-rw-r--
  • dirs: drwxrwxr-x

Maybe this helps also:

windows_names,hide_hid_files,hide_dot_files,big_writes

Note that NFS expect the same UID on client and server for writing to it. You have to set permissions for other, so that everyone can write if that is not the case or use usermapping.

4 Likes

Where does this go? In /etc/systemd/system/mnt-V.mount: Options=defaults,rw,noatime,uid=1000,gid=1000,dmask=0002,fmask=0113,windows_names,hide_hid_files,hide_dot_files,big_writes?

So by copy pasting those values it will work if the UIDs are different?

After changing /etc/systemd/system/mnt-V.mount I’ve done

sudo umount /mnt/V
sudo systemctl start mnt-V.automount
❯ ls -l /mnt/
drwxr-xr-x 2 root root 0 jul 17 16:02 V

So the permissions have changed but the ownership that is what is giving me trouble is the same.

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