Configure nfs server debian 8 jessie servers

Moderators: mdrjr, odroid

Configure nfs server debian 8 jessie servers

Unread postby marcavatar » Sun Oct 08, 2017 11:27 pm

Hi, I was able to install the debian 8 jessie system on my Ordroid XU4, I then installed the NFS network sharing system since I have several hard drives to share, the system only works whenever I need to share a hard disk I need to restart server with the command "systemctl restart nfs-kernel-server" otherwise Client does not see it. Is there a command to start it automatically? Hard Drives I turn them off and tell them when they need them, how can I do this to avoid rebooting the server every time? Thank you.
marcavatar
 
Posts: 54
Joined: Mon Feb 15, 2016 2:24 am
languages_spoken: italian
ODROIDs: Odroid C1+

Re: Configure nfs server debian 8 jessie servers

Unread postby mad_ady » Mon Oct 09, 2017 1:00 am

How do you turn off the disks? Do you mean the go to sleep or do you unplug them? How do you handle mounting? You can also reload nfs with sudo exportfs -ra
You can also tie this to udev rules so it's restarted when a disk comes online. Not sure what happens to existing transfers though...
User avatar
mad_ady
 
Posts: 2898
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: Configure nfs server debian 8 jessie servers

Unread postby marcavatar » Mon Oct 09, 2017 6:12 am

Hi, thank you for the answer, the disks mount themselves on the desktop pc at boot but then I have to restart each time the nfs server from the terminal to be able to see them in the client. How do I make a rule for them to see them automatically on the client when hard drives start?
marcavatar
 
Posts: 54
Joined: Mon Feb 15, 2016 2:24 am
languages_spoken: italian
ODROIDs: Odroid C1+

Re: Configure nfs server debian 8 jessie servers

Unread postby mad_ady » Mon Oct 09, 2017 2:45 pm

So - the problem is client-side with stale mountpoints? Meaning your client mounts the nfs share, uses it and after a while the disks are turned off and don't recover when turning them back on?
If yes, I'd recommend using autofs on the client so that the shares are mounted automatically on first use and umounted automatically after a period of idle time.
User avatar
mad_ady
 
Posts: 2898
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: Configure nfs server debian 8 jessie servers

Unread postby marcavatar » Tue Oct 10, 2017 2:53 am

Hi, thanks for the answer, is there an understandable tutorial for an amateur to install and configure my hard drives with this autofs? Thank you.
marcavatar
 
Posts: 54
Joined: Mon Feb 15, 2016 2:24 am
languages_spoken: italian
ODROIDs: Odroid C1+

Re: Configure nfs server debian 8 jessie servers

Unread postby marcavatar » Tue Oct 10, 2017 4:58 am

For the sake of precision I use a xu4 odroid with debian installed as a server, I connected hard drives containing multimedia files that I share with a cydode c2 where I installed KODI, when I turn on a hard disk I have no problems with DEBIAN on the desktop and I can open folders, same as other hard disks, but on KODI does not open the folder, I have to restart the NFS system from the terminal with this command: "systemctl restart nfs-kernel-server" at that point opens the folder. I hope there is a specific command to prevent the NFS service from restarting every time
marcavatar
 
Posts: 54
Joined: Mon Feb 15, 2016 2:24 am
languages_spoken: italian
ODROIDs: Odroid C1+

Re: Configure nfs server debian 8 jessie servers

Unread postby mad_ady » Tue Oct 10, 2017 2:22 pm

This will get you started with autofs: https://help.ubuntu.com/community/Autofs
User avatar
mad_ady
 
Posts: 2898
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: Configure nfs server debian 8 jessie servers

Unread postby marcavatar » Thu Oct 12, 2017 8:30 pm

Hi, I have installed AUTOFS as recommended by links, but I do not know where to mount my files, first opened the configuration file with this command "nano / etc / exports" and then created a line such as "/ media / root / ElementsP 192.168.178.0/255.255.255.0(rw,no_subtree_check,crossmnt,sync,fsid=0,no_root_squash) "and restarted, this system allowed me to mount the file on a client, but then if I leave the hard disk containing the folder in question and subsequently re-ignited the same did not see me anymore. What do I have to open through a timeline, and what should I write, is the line equal or do I have to write a different command? Thank you.
marcavatar
 
Posts: 54
Joined: Mon Feb 15, 2016 2:24 am
languages_spoken: italian
ODROIDs: Odroid C1+

Re: Configure nfs server debian 8 jessie servers

Unread postby lazlo » Sun Oct 15, 2017 6:34 am

If the nfs exports are not going to be available for some reason you might want to read the nfs and mount manual pages to learn about the timeout and retry settings built into nfs.

You should be able to set the mount points with the desired options in /etc/fstab of the client. That way the directories exported via nfs from the server will always mount in the same place on the client. A word of advice about mount options in fstab: you usually do need a lot of options set.



lazlo
lazlo
 
Posts: 16
Joined: Sun Oct 01, 2017 11:32 am
languages_spoken: english
ODROIDs: XU4

Re: Configure nfs server debian 8 jessie servers

Unread postby mad_ady » Mon Nov 27, 2017 2:08 pm

It's funny (and troubling at the same time) to see how spambots evolve. They read a thread and use some sort of AI to create a seemingly coherent post, but they give themselves away by failing to be relevant and resurrecting many old threads...
I'm looking at you @Rose1812! Shame!
User avatar
mad_ady
 
Posts: 2898
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: Configure nfs server debian 8 jessie servers

Unread postby odroid » Mon Nov 27, 2017 2:11 pm

The bot posted over 20 replies in very smart way. I've removed all. :(
User avatar
odroid
Site Admin
 
Posts: 25361
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Configure nfs server debian 8 jessie servers

Unread postby mad_ady » Tue Nov 28, 2017 7:05 pm

So, to get back on topic - an issue I've been seeing with my setup (autofs mounts the disks on the servers, clients use autofs to mount those disks through NFS from the server), was that on power outages, the clients would mount empty shares, requiring a restart of nfs-mountd server-side and autofs client-side. After some head scratching I think I know why - autofs on the client mounts the NFS share before the server-side autofs manages to mount the disk, so at that point in time the server only sees an empty directory and when it finally gets mounted, nfs will not re-export it because it doesn't re-export mounted directories.

To get around this, we need to tell the NFS daemon to wait for autofs to mount the disks. Systemd has a directive for a service to wait for something to be mounted before starting:
RequiresMountsFor=

Takes a space-separated list of absolute paths. Automatically adds dependencies of type Requires= and After= for all mount units required to access the specified path.

Mount points marked with noauto are not mounted automatically through local-fs.target, but are still honored for the purposes of this option, i.e. they will be pulled in by this unit.


So I did the following changes on my server:
Code: Select all
$ sudo cp /lib/systemd/system/nfs-mountd.service /etc/systemd/system
$ sudo vi /etc/systemd/system/nfs-mountd.service
[Unit]
Description=NFS Mount Daemon
DefaultDependencies=no
Requires=proc-fs-nfsd.mount
After=proc-fs-nfsd.mount
After=network.target local-fs.target
After=rpcbind.socket
BindsTo=nfs-server.service
RequiresMountsFor=/media/ssd /media/wdc
Wants=nfs-config.service
After=nfs-config.service

[Service]
EnvironmentFile=-/run/sysconfig/nfs-utils
Type=forking
ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDARGS

$ sudo systemctl daemon-reload

I added this line to it, corresponding to the mount points of autofs:
Code: Select all
RequiresMountsFor=/media/ssd /media/wdc


On reboot NFS will trigger the mounting of the shares and will export them afterwards, hopefully preventing my problem.
User avatar
mad_ady
 
Posts: 2898
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2


Return to Other OS

Who is online

Users browsing this forum: No registered users and 5 guests