Can't Add mounted NFS drive

Creating a bug report/issue

Required Information

  • DietPi version | cat /boot/dietpi/.version
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=15
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
    G_LIVE_PATCH_STATUS[0]=‘not applicable’
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
    bullseye
  • Kernel version | uname -a
    Linux MediaServer 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)
    Native PC (x86_64)
  • Power supply used | (EG: 5V 1A RAVpower)
    Native PC
  • SD card used | (EG: SanDisk ultra)
    Samsung SSD

Steps to reproduce

1.Go to other dietpi PC try and add other PC drive
2. Get error

Expected behaviour

  • It should just add it without any issues.

Actual behaviour

  • getting error

Extra details

Hi,

I have two PC’s both runing Dietpi both on the same network, both Native PC (x86_64) and both running bullseye

On PC 1 I have added a bigger harddrive where I’m going to store all my media, I added the drive with dietpi-drive_manager without any issues:

On PC 2 am trying to add the drive with NFS (PC one has NFS server, and PC 2 has NFS client) on PC two I get the following:

──────────────────────────────┤ DietPi-Drive_Manager | File viewer ├──────────────────────────────┐
│                                                                                                  │
│ [FAILED] NFS mount failed with the following error output:                                       │
│                                                                                                  │
│ mount.nfs: mount(2): No such file or directory                                                   │
│ mount.nfs: trying 192.168.1.173 prog 100003 vers 3 prot TCP port 2049                            │
│ mount.nfs: trying 192.168.1.173 prog 100005 vers 3 prot UDP port 50495                           │
│ mount.nfs: mount(2): Permission denied                                                           │
│ mount.nfs: access denied by server while mounting 192.168.1.173:/mnt/Media                       │
│ mount.nfs: timeout set for Mon Mar 27 12:47:24 2023                                              │
│ mount.nfs: trying text-based options                                                             │
│ 'port=2049,vers=4.2,addr=192.168.1.173,clientaddr=192.168.1.233'                                 │
│ mount.nfs: trying text-based options 'port=2049,addr=192.168.1.173'                              │
│ mount.nfs: prog 100003, trying vers=3, prot=6                                                    │
│ mount.nfs: prog 100005, trying vers=3, prot=17

My only guess it’s something to do with the drive setup as running ls-al I can see it’s root:root?

dietpi@MediaServer:/mnt$ ls -al
total 16
drwxr-xr-x  4 root   root   4096 Mar 27 12:46 .
drwxr-xr-x 18 root   root   4096 Mar 27 11:50 ..
drwxr-xr-x  2 root   root   4096 Mar 27 12:28 Media
drwxrwxr-x  6 dietpi dietpi 4096 Mar 27 12:05 dietpi_userdata


fstab:
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------


#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=7470M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777

#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf, glusterfs, mergerfs, bind, Btrfs subvolume
#----------------------------------------------------------------


#----------------------------------------------------------------
# SWAP SPACE
#----------------------------------------------------------------


#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
UUID=1460962e-b62a-4f4c-bfc8-b7a5e8cbd421 / ext4 noatime,lazytime,rw 0 1
UUID=24C8-D21A /boot/efi vfat noatime,lazytime,rw 0 2
UUID=fd6320c0-c945-45c5-b936-4e338c2937f8 /mnt/Media ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount`

df:
dietpi@MediaServer:/mnt$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.3G     0  7.3G   0% /dev
tmpfs           1.5G  8.7M  1.5G   1% /run
/dev/sdb2       111G  952M  104G   1% /
tmpfs           7.3G     0  7.3G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.3G     0  7.3G   0% /tmp
tmpfs            50M   40K   50M   1% /var/log
/dev/sdb1        63M   11M   53M  17% /boot/efi
/dev/sda1        15T   12K   15T   1% /mnt/Media

PC two has no issues with finding the NFS server

┌─────────────────────────────────────┤ DietPi-Drive_Manager ├─────────────────────────────────────┐
│ Please select the NFS export of 192.168.1.173 from the list below:                               │
│                                                                                                  │
│                    /mnt/dietpi_userdata                                                          │
│                    Custom               : Enter custom NFS server share path                     │
│                                                                                                  │
│                                                                                                  │
│                           <Ok>                               <Cancel>

Thank you!

Did you try to access /mnt/Media via NFS? Because this is not going to work. You would need to add this directory to the NFS export configuration.

As you can see on your own output (last Drive Manager information), the NFS server is providing /mnt/dietpi_userdata only :wink:

To add the media folder, simply add it on server side by adjusting /etc/exports.d/dietpi.exports

As well, always good to have a look to our online docs File Servers Options - DietPi.com Docs

1 Like

Hello Joulinar,

Thank you so much that has worked, but not the way I had hoped, I followd your advise and the link and the client can see the /mnt/Media

But now it’s marked as a read only drive and the client can’t save to the nfs drive. I did try this "/mnt/Media (rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)"

But that just mappped it back to /mnt/dietpi_userdata

Doing the following has worked:

exports:
/mnt/dietpi_userdata *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)
/mnt/Media

But again PC2 can’t save to the drive.

dietpi@PC2:/mnt/nfs_client$ mkdir test1
mkdir: cannot create directory ‘test1’: Read-only file system
dietpi@Downloader:/mnt$ ls -al
total 16
drwxr-xr-x  4 root   root   4096 Mar 27 13:43 .
drwxr-xr-x 18 root   root   4096 Mar 25 23:09 ..
drwxrwxr-x  8 dietpi dietpi 4096 Jan 29 04:48 dietpi_userdata
drwxr-xr-x  3 root   root   4096 Mar 27 13:44 nfs_client

My end goal is to do the following:

Mount the drive so dietpi can write and read onto itself.
Mapp the drive using NFS so PC 2 can write and read the drive using dietpi.

As I don’t use root as the default login (old habbits).

Thank you :slight_smile:

cat you share full conetent of /etc/fstab from client side and /etc/exports.d/dietpi.exports from server side.

Client side:

dietpi@Clientside:~$ cat /etc/fstab
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------
192.168.1.173:/mnt/Media /mnt/nfs_client nfs nofail,noauto,x-systemd.automount

#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=1924M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777

#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf, glusterfs, mergerfs, bind, Btrfs subvolume
#----------------------------------------------------------------


#----------------------------------------------------------------
# SWAP SPACE
#----------------------------------------------------------------


#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
UUID=622bde80-1656-479c-9b5d-70289b8062af / ext4 noatime,lazytime,rw 0 1
UUID=34B0-2A7A /boot/efi vfat noatime,lazytime,rw 0 2

Server Side:

root@ServerSide:~# cat /etc/exports.d/dietpi.exports
/mnt/dietpi_userdata *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)
/mnt/Media

I think it should be

/mnt/Media *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)
1 Like

Yes correct NFS export for Media would need to be defined. Otherwise, you have no right to write to the share. I would recommend following (without fsid=0):

/mnt/dietpi_userdata *(rw,async,no_root_squash,crossmnt,no_subtree_check)
/mnt/Media *(rw,async,no_root_squash,crossmnt,no_subtree_check)

Don’t forget to restart NFS server and to remount share on client side.

I removed the share on the client side
Made the change on the NFS server side and rebooted the server as the “exportfs” commnds don’t work.

Sadly I’m still unable to write to the folder. However, either sides can’t write to the folder the server or the client side.

dietpi@client side:/mnt/nfs_client$ pwd
/mnt/nfs_client
dietpi@client side:/mnt/nfs_client$ mkdir test
mkdir: cannot create directory ‘test’: Permission denied
dietpi@clientside:/mnt/nfs_client$ ls -al
total 24
drwxr-xr-x  6 root root 4096 Mar 27 13:48  .
drwxr-xr-x  4 root root 4096 Mar 27 22:25  ..
drwxr-xr-x  8 root root 4096 Mar 27 13:48  Anime
drwxr-xr-x 62 root root 4096 Mar 27 13:52  Movies
drwxr-xr-x 12 root root 4096 Mar 27 13:52 'TV Shows'
drwxr-xr-x  4 root root 4096 Mar 27 13:52  Video
dietpi@client side:/mnt/nfs_client$ cat /etc/fstab
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------
192.168.1.173:/mnt/Media /mnt/nfs_client nfs nofail,noauto,x-systemd.automount

#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=1924M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777

#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf, glusterfs, mergerfs, bind, Btrfs subvolume
#----------------------------------------------------------------


#----------------------------------------------------------------
# SWAP SPACE
#----------------------------------------------------------------


#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
UUID=622bde80-1656-479c-9b5d-70289b8062af / ext4 noatime,lazytime,rw 0 1
UUID=34B0-2A7A /boot/efi vfat noatime,lazytime,rw 0 2
dietpi@NFSServer:/mnt/Media$ pwd
/mnt/Media
dietpi@NFSServer:/mnt/Media$ mkdir test
mkdir: cannot create directory ‘test’: Permission denied
dietpi@MediaServer:/mnt/Media$ ls -al
total 24
drwxr-xr-x  6 root root 4096 Mar 27 13:48  .
drwxr-xr-x  4 root root 4096 Mar 27 12:46  ..
drwxr-xr-x  8 root root 4096 Mar 27 13:48  Anime
drwxr-xr-x 62 root root 4096 Mar 27 13:52  Movies
drwxr-xr-x 12 root root 4096 Mar 27 13:52 'TV Shows'
drwxr-xr-x  4 root root 4096 Mar 27 13:52  Video
dietpi@NFSServer:/mnt/Media$ cat /etc/exports.d/dietpi.exports
/mnt/dietpi_userdata *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)
/mnt/Media *(rw,async,no_root_squash,crossmnt,no_subtree_check)

I’m going to guess because the drive_manager needed root, it mounted it with root access? But I could be wrong it’s just my guess. But I’m unsure how to change this without breaking anything :smiling_face_with_tear:

Your problem are file system permission on server side. All files and folder are owned by user root. But you are trying to access files as user dietpi. Hence, this can’t work :wink: This has nothing to do with drive manager or the NFS client. What file system format your USB attached disk is using?

lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid