LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-09-2014, 11:05 AM   #1
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Can't start NFS with systemd, works on OpenRC


I am currently testing to migrate a Gentoo machine from OpenRC to systemd. Works well so far, except NFS. It simply won't start, bailing out with error messages that don't give me a clue.
Code:
journalctl -xn
does not show any errors, but systemctl does:
Code:
>>> systemctl status nfs-server.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib64/systemd/system/nfs-server.service; enabled)
   Active: failed (Result: exit-code) since Wed 2014-07-09 15:38:29 UTC; 26s ago
  Process: 7436 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=1/FAILURE)
  Process: 7433 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 7436 (code=exited, status=1/FAILURE)

Jul 09 15:38:29 demon rpc.nfsd[7436]: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Jul 09 15:38:29 demon rpc.nfsd[7436]: rpc.nfsd: unable to set any sockets for nfsd
Jul 09 15:38:29 demon systemd[1]: nfs-server.service: main process exited, code=exited, status=1/FAILURE
Jul 09 15:38:29 demon systemd[1]: Failed to start NFS server and services.
Jul 09 15:38:29 demon systemd[1]: Unit nfs-server.service entered failed state.
Does anyone have a hint what may be going wrong here?
 
Old 07-09-2014, 02:53 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148

Original Poster
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Nevermind, found the answer in the second post of this thread on the Gentoo forum: http://forums.gentoo.org/viewtopic-t...552070a8938bf6
As it seems Gentoo is still missing a few config-files for NFS on systemd.
For the sake of completeness:
Quote:
Originally Posted by Kompi
You need quite a lot of services and some pseudo file systems mounted for nfs to work properly. When I switched to systemd there weren't any service files so I wrote my own. Took me a while, since it was a bit of a hassle to find out the right order and what I actually need. This is my setup for nfsv4:

proc-fs-nfsd.mount:
Code:
[Unit]
Description=/proc/fs/nfsd

Before=nfs.target
Before=rpc.nfsd.service

[Mount]
What=nfsd
Where=/proc/fs/nfsd
Type=nfsd
Options=nodev,noexec,nosuid

[Install]
WantedBy=nfs.target
var-lib-nfs-rpc_pipefs.mount:

Code:
[Unit]
Description=rpc_pipefs

Before=nfs.target
Before=remote-fs-pre.target

[Mount]
What=rpc_pipefs
Where=/var/lib/nfs/rpc_pipefs

Type=rpc_pipefs

[Install]
WantedBy=nfs.target
rpcbind.service:

Code:
[Unit]
Description=NFS port mapping server

Before=nfs.target
Before=remote-fs-pre.target

[Service]
EnvironmentFile=/etc/conf.d/rpcbind
ExecStart=/sbin/rpcbind $RPCBIND_OPTS
Type=forking

[Install]
WantedBy=nfs.target
rpc.idmapd.service:

Code:
[Unit]
Description=NFSv4 ID - Name Mapper

Wants=rpcbind.service
Wants=var-lib-nfs-rpc_pipefs.mount
Wants=proc-fs-nfsd.mount

After=proc-fs-nfsd.mount

Before=nfs.target
Before=remote-fs-pre.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.idmapd -f $OPTS_RPC_IDMAPD

[Install]
WantedBy=nfs.target

rpc.mountd.service:

Code:
[Unit]
Description=RPC mountd

Wants=rpcbind.service
After=rpcbind.service

After=rpc.svcgssd.service
After=rpc.idmapd.service

Before=nfs.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.mountd --foreground $OPTS_RPC_MOUNTD

[Install]
WantedBy=nfs.target

rpc.statd.service:

Code:
[Unit]
Description=NFS status daemon

Wants=rpcbind.service

After=rpc.svcgssd.service
After=rpc.idmapd.service
After=rpc.mountd.service

Before=rpc.nfsd.service

Before=nfs.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/sbin/rpc.statd --no-notify -F $OPTS_RPC_STATD

sm-notify.service:

Code:
[Unit]
Description=NFS sm-notify

Wants=rpc.statd.service
Before=nfs.target
Before=remote-fs-pre.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/sm-notify -d $OPTS_SMNOTIFY
Type=oneshot

[Install]
WantedBy=nfs.target


rpc.gssd.service:

Code:
[Unit]
Description=NFS rpcsec_gss daemon

Wants=rpcbind.service
Wants=var-lib-nfs-rpc_pipefs.mount
After=var-lib-nfs-rpc_pipefs.mount

Before=nfs.target
Before=remote-fs-pre.target

# shutdown while sleeping, to re-authenticate with kerberos after resume
Conflicts=sleep.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.gssd -f $OPTS_RPC_GSSD
Restart=on-failure

[Install]
WantedBy=nfs.target
rpc.svcgssd.service:

Code:
[Unit]
Description=NFS rpcsec_gss server daemon

Wants=rpcbind.service
Wants=proc-fs-nfsd.mount

After=proc-fs-nfsd.mount
Before=nfs.target

[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.svcgssd -f ${OPTS_RPC_SCVGSSD}
Restart=on-failure

[Install]
WantedBy=nfs.target
rpc.nfsd.service:


Code:
[Unit]
Description=NFS server

Wants=rpcbind.service
Wants=rpc.statd.service
Wants=rpc.mountd.service

After=rpcbind.service
After=rpc.statd.service
After=rpc.svcgssd.service
After=rpc.idmapd.service

Before=nfs.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/nfs

ExecStart=/usr/sbin/rpc.nfsd ${OPTS_RPC_NFSD}
ExecStop=/usr/sbin/rpc.nfsd 0


[Install]
WantedBy=nfs.target
exportfs.service:

Code:
[Unit]
Description=NFS server exports

Wants=rpcbind.service
Wants=rpc.statd.service

After=rpc.mountd.service
After=rpc.statd.service

Before=nfs.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/nfs

ExecStart=/usr/sbin/exportfs -r
ExecStop=/usr/sbin/exportfs -ua
ExecReload=/usr/sbin/exportfs -r

[Install]
WantedBy=nfs.target

nfs.target:

Code:
[Unit]
Description=NFS services

[Install]
WantedBy=multi-user.target

The rpc.[svc]gssd services are only needed if you use nfsv4 with kerberos authentication. Enable rpc.gssd on the client and rpc.svcgssd on the server.

The rpc.mountd and rpc.statd, as well als sm-notify services are only necessary if you are using nfsv3 shared. Enable the first two on the server if you export nfsv3 shares, and sm-notify on the client.


To make it a little easier, these are the services you need to enable on the server:



Code:
systemctl enable var-lib-nfs-rpc_pipefs.mount
systemctl enable proc-fs-nfsd.mount 
systemctl enable rpcbind.service   
systemctl enable rpc.idmapd.service 
systemctl enable rpc.nfsd.service   
systemctl enable exportfs.service 

# for NFSv3 only:
systemctl enable rpc.mountd.service
systemctl enable rpc.statd.service

# for NFSv4 kerberos auth only:
systemctl enable rpc.svcgssd.service

# finally, enable nfs.target to start services at boot:
systemctl enable nfs.target

on the client:


Code:
systemctl enable rpcbind.service   
systemctl enable var-lib-nfs-rpc_pipefs.mount
systemctl enable rpc.idmapd.service 

# for nfsv3 only:
systemctl enable sm-notify.service 

# for nfsv4 kerberos auth only:
systemctl enable rpc.gssd.service

# finally, enable nfs.target to start services at boot:
systemctl enable nfs.target
Of course you need to add a "After=remote-fs-pre.target" in the [unit] section to any .mount unit on the client that should mount an nfs share.

Hope those files can help you.
 
  


Reply

Tags
nfs, systemd



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
question about using systemd and automount for NFS share lleb Linux - Networking 1 08-16-2013 06:48 AM
[SOLVED] new Sabayon 13.04 install: Can't get GPM to start as a service... {systemd} jtwdyp Sabayon 2 06-16-2013 12:46 PM
nfs wicd netcl systemd blues (cannot shutdown without CPU Lock) forshark Linux - Networking 2 05-28-2013 02:29 PM
SysVinit vs OpenRC vs systemd vs other init system cristi92b Linux - Newbie 2 01-07-2013 03:02 AM
NFS works but cannot start at boot automatically jsh684 SUSE / openSUSE 5 04-11-2010 07:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration