Page 1 of 1

How to set up NFS

PostPosted: Dec 12th, '22, 22:27
by lloyd
Ok, I need some help, as I'm out of my element here (but you learn by asking questions, right?)
I have two computers, A + B. One runs Mageia 8 and the other runs Mageia 9 Alpha. They are both connected (hardwired with Ethernet) to the same router.
Computer A has more disk space, so I want it to be my server. I have a directory called /home1 (it's actually an NVME drive) that I want to use as a shared directory. I want to be able to access this directory from Computer A and Computer B.
I have NFS and related utilities installed on both machines. I really don't quite understand what I'm supposed to do next.
How and where do I start?
Thank you.

Re: How to set up NFS

PostPosted: Dec 13th, '22, 00:54
by doktor5000
Basically you'd install nfs-server (on Mageia the package is called nfs-utils) on computer A, and add the filesystem /home1 to /etc/exports, then start nfs-server service there (which will also run exportfs -a which exports the content of /etc/exports via NFS) .

On the other box, you'd need to also install nfs-utils and check if the NFS export can be seen via
Code: Select all
showmount -e IP.of.computer.A
and then either manually mount it via
Code: Select all
mount -t nfs IP.of.computer.A:/home1 /mnt/somewhere/on/computer/B
and if that works you can add this mount to /etc/fstab in a similar manner. If the former doesn't work, then probably because rpcbind (also called portmapper) is not running yet on computer B, e.g.
Code: Select all
rpcinfo -p IP.of.computer.A
should show portmapper on port 111 and nfs on port 2049, among some others.

More details can be configured, like access restrictions (e.g. making sure the NFS export is only exported to your local subnet) or user mapping and such, but this is the most basic stuff.

There's a section in MCC for doing all this, but from reading other threads and some bugreports it does not work sometimes, possibly due to missing firewall entries or because the hostnames are not resolvable in both directions and people try to use hostnames without covering proper name resolution between each participating box beforehand.

Re: How to set up NFS

PostPosted: Dec 13th, '22, 03:34
by lloyd
A project for tomorrow...
I tried using the Mageia tools from Network Sharing (from drakconf)
Or would I use those AFTER it's been set up?

Also, how would I mount it automatically?

Now I am having a problem getting nfs-server to start. I had it set to start on bootup. But it doesn't start most of the time. Which computer should be started first? Client or server?

Re: How to set up NFS

PostPosted: Dec 13th, '22, 10:40
by doktor5000
In theory you should be able to set this up using draknfs on both server and client, see https://doc.mageia.org/mcc/8/en/content ... ml#draknfs and https://doc.mageia.org/mcc/8/en/content ... drake--nfs

You mount it automatically by either adding an entry for the filesystem to /etc/fstab or by adding and systemd .mount unit for it, other ways would also be possible.
entry in fstab could look something like this, similar to the manual mount command, although adding _netdev as option to mark it as a network file system so it should only be tried once network is up
Code: Select all
IP.of.computer.A:/home1 /mnt/somewhere/on/computer/B nfs _netdev 0 0

But I'd do it as automount, so it will automatically get mounted once you access it: https://wiki.archlinux.org/title/NFS#Mo ... th_systemd

If nfs-server doesn't start, then you'd need to post the output of
Code: Select all
systemctl status nfs-server -al -n150
as root if it doesn't start.
Also, obviously the server should be started first.