How to share one folder with multiple drives?

I have multiple drives in a computer and I would like to share all of them at once instead of sharing each one as described in this tutorial. Is that possible?

For example instead of sharing the drive /mnt/hdd1, could I share all drives mounted in /mnt?

1 Like

Yes, you can. See the Arch Wiki page on NFS.

3 Likes

I’ve modified this commands that did work before, to share /mnt/ instead of /mnt/hdd1.

It didn’t work.

$c: client, $s: server
$s sudo chmod 777 /mnt
$s sudo vi /etc/exports
/mnt  192.168.1.45/24(rw,sync,no_subtree_check)
$s sudo exportfs -arv
$s sudo systemctl enable --now nfs-server.service

$c sudo systemctl enable --now nfs-client.target
$c showmount -e 192.168.1.45
Export list for 192.168.1.45:
/mnt 192.168.1.45/24
$c sudo mkdir -p /srv/nfs/lenovo
$c sudo chmod 755 /srv/nfs/lenovo
$c sudo cat /etc/fstab
192.168.1.45:/mnt   /srv/nfs/lenovo  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
$c ls -l /srv/nfs/lenovo
drwxr-xr-x 2 root root 4096 sep 24 12:57 hdd1
drwxrwxrwx 2 root root 4096 ago 28 17:19 v
$c ls -l /srv/nfs/lenovo/hdd1
total 0

The drive isn’t empty.

From the Arch Wiki… :arrow_down:

Tip:

  • The crossmnt option makes it possible for clients to access all filesystems mounted on a filesystem marked with crossmnt and clients will not be required to mount every child export separately. Note this may not be desirable if a child is shared with a different range of addresses.
  • Instead of crossmnt, one can also use the nohide option on child exports so that they can be automatically mounted when a client mounts the root export. Being different from crossmnt, nohide still respects address ranges of child exports.
  • Use an asterisk (*) to allow access from any interface.

It should be noted that modifying /etc/exports while the server is running will require a re-export for changes to take effect:

# exportfs -arv
2 Likes

Thanks, I changed the /etc/exports in the server to:

/mnt  192.168.1.45/24(rw,sync,no_subtree_check,crossmnt)

and now it works.

1 Like

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