You are not logged in.

#1 2012-10-20 00:01:42

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,423
Website

Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

I'm experiencing a 60 sec on boot which I attribute to my NFS mount specified in /etc/fstab (if I comment them out booting is as expected):

% grep nfs /etc/fstab
mars:/media     /mnt/media                      nfs4  defaults  0 0

The delay is clearly present:

% systemd-analyze blame
 61806ms mnt-media.mount
...

If I switch to the automount option, the box boots normally, but I cannot access the mount for around 60 sec!

% grep nfs /etc/fstab
mars:/media     /mnt/media                      nfs4  defaults,x-systemd.automount  0 0
% cd /mnt/media
ll
<<<HANG for about 60 sec>>>
...
 % ll
total 36K
drwxr-xr-x 3 root    root  4.0K Oct  7 14:25 backup
drwx------ 2 root    root   16K May  1 20:17 lost+found
drwxrwxr-x 4 facade users 4.0K Sep 22 17:45 music
drwxrwxr-x 2 facade users 4.0K Jan  1  2011 photos
drwxrwxr-x 9 facade users 4.0K Oct  7 10:29 video

Additionally, `systemd-analyze blame` still records a 60 sec freeze but I do not have to wait staring at a black screen... X is loaded while I wait.  Rather than posting tons of config files from either the NFS server or client, I thought I'd ask people for ideas based on this info; glad to post whatever upon request.  Thanks in advance!

Last edited by graysky (2012-10-20 14:06:44)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2012-10-20 00:47:22

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,092
Website

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

You're missing the _netdev option, so systemd tries to mount it before the network is up.

Offline

#3 2012-10-20 12:47:33

steelman
Member
Registered: 2012-10-20
Posts: 1

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Hi,

Acc to "http://www.softpanorama.info/Net/Linux_ … _nfs.shtml"
"The rsize value is the number of bytes used when reading from the server. The wsize value is the number of bytes used when writing to the server. The default for both is 1024, but using 8192 greatly improves throughput and is recommended. The timeo value is the amount of time, in tenths of a second, to wait before resending a transmission after an RPC timeout. After the first timeout, the timeout value is doubled for each retry for a maximum of 60 seconds or until a major timeout occurs. If connecting to a slow server or over a busy network, better performance can be achieved by increasing this timeout value. The intr option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share. Refer to the NFS man page with the command man nfs for a full list of available options.
Using /etc/fstab to Connect to the NFS Share

After you have verified that the client can mount the share, you can configure the system to mount it at boot time by modifying the /etc/fstab file as follows:
server:/exported/dir   /mountpoint   nfs    rsize=8192,wsize=8192,timeo=14,intr"


They key is in your fstab should be "timeo=14"

My fstab without "timeo=14"
systemd-analyze blame
60542 ms "my nfs share"

My fstab with "timeo=14"
systemd-analyze blame
1532 ms "my nfs share"

Offline

#4 2012-10-20 13:34:22

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,837

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

falconindy wrote:

You're missing the _netdev option, so systemd tries to mount it before the network is up.

Really? I don't use that option, and my nfs shares are mounted correctly, after the network comes up.

graysky, does /run/systemd/generator/mnt-media.mount look right?

Last edited by tomk (2012-10-20 23:48:12)

Offline

#5 2012-10-20 14:06:30

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,423
Website

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

@steelman - Thx for that suggestion and for taking the time to explain the additional options.  Seems to have solved this issue for me:

% systemd-analyze blame
  8734ms mnt-media.mount
  1903ms systemd-vconsole-setup.service
  1111ms systemd-remount-fs.service
...
% grep nfs /etc/fstab
mars:/media   /mnt/media   nfs4	 timeo=14,intr	0 0

EDIT: Updated NFS wiki with this learning.

Last edited by graysky (2012-10-20 22:58:24)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2012-10-21 23:19:22

akb825
Member
Registered: 2011-03-27
Posts: 77

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Specifying a lower timeout seems to be a bandaid for the problem that systemd wants to delay the boot process by that timeout. Having systemd mount your NFS volumes also adds a large delay to shutdown.

I have solved the issue another way: by using the hooks available in NetworkManager to mount and unmount the drives when the network is connected and disconnected. To do this, add a file /etc/NetworkManager/dispatcher.d/nfs.sh (with executable permissions) with the following contents:

#/bin/sh

if [ "$2" = "up" ]
then
	mount "/mnt/media"
elif [ "$2" = "down" ]
then
	umount "/mnt/media"
fi

You will also need to ad the "noauto" option to your NFS entries in /etc/fstab to prevent systemd from attempting to mount those drives.

Offline

#7 2013-05-18 14:33:49

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

akb825 wrote:

Specifying a lower timeout seems to be a bandaid for the problem that systemd wants to delay the boot process by that timeout. Having systemd mount your NFS volumes also adds a large delay to shutdown.

I have solved the issue another way: by using the hooks available in NetworkManager to mount and unmount the drives when the network is connected and disconnected. To do this, add a file /etc/NetworkManager/dispatcher.d/nfs.sh (with executable permissions) with the following contents:

#/bin/sh

if [ "$2" = "up" ]
then
	mount "/mnt/media"
elif [ "$2" = "down" ]
then
	umount "/mnt/media"
fi

You will also need to ad the "noauto" option to your NFS entries in /etc/fstab to prevent systemd from attempting to mount those drives.

I have been having all sorts of issues trying to get NFS to mount at boot with systemd.
This script looks like a decent fix - can you clarify what the "$2" relates to?

Offline

#8 2013-05-18 14:39:53

karol
Archivist
Registered: 2009-05-06
Posts: 25,424

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

It's the positional argument

$ ./foo bar baz

foo = $0
bar = $1
baz = $2

Offline

#9 2013-05-18 14:49:48

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Of what?

Offline

#10 2013-05-18 14:52:53

karol
Archivist
Registered: 2009-05-06
Posts: 25,424

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

You need to run that script with some arguments, like 'up' or 'down'.

Example what the positional arguments mean:

$ cat aaa
#!/bin/bash

echo $0 $1 $2
$ ./aaa one two three
./aaa one two

http://www.linuxcommand.org/wss0130.php

Last edited by karol (2013-05-18 14:54:36)

Offline

#11 2013-05-18 14:55:46

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

You've just confused me even more by not explaining how this relates to the networkmanager script

Offline

#12 2013-05-18 14:59:07

karol
Archivist
Registered: 2009-05-06
Posts: 25,424

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

If the second argument is 'up', command 'mount "/mnt/media"' is run.
If the second argument is 'down', command 'umount "/mnt/media"' is run.

Offline

#13 2013-05-18 15:58:08

gonX
Member
From: Denmark
Registered: 2009-08-16
Posts: 110

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

kaipee wrote:

You've just confused me even more by not explaining how this relates to the networkmanager script

NetworkManager passes "interface" and "status", respectively, where "status" can be 'up' or 'down. Interface should be self-explanatory smile

Last edited by gonX (2013-05-18 15:58:46)


since 2009

Offline

#14 2013-05-18 17:24:08

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Thanks gonX, so NetworkManager output "status" corresponds to variable $2. I see now.

Offline

#15 2013-05-18 18:10:42

karol
Archivist
Registered: 2009-05-06
Posts: 25,424

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

kaipee wrote:

Thanks gonX, so NetworkManager output "status" corresponds to variable $2. I see now.

If I get it right, 'status' is $1.

Offline

#16 2013-05-18 18:48:49

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Unless there is something else before "interface" and "status"

Offline

#17 2013-05-18 19:07:01

gonX
Member
From: Denmark
Registered: 2009-08-16
Posts: 110

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

karol wrote:
kaipee wrote:

Thanks gonX, so NetworkManager output "status" corresponds to variable $2. I see now.

If I get it right, 'status' is $1.

$ echo "echo $0
 echo $1
 echo $2" > /tmp/bashscript

$ chmod +x /tmp/bashscript

$ /tmp/bashscript Hi Mate
/tmp/bashscript
Hi
Mate

Said in another way, no, status is $2, and interface is $1.


since 2009

Offline

#18 2013-05-18 19:12:07

karol
Archivist
Registered: 2009-05-06
Posts: 25,424

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Ah, now I get it. I thought they were mutually exclusive.

Soooorryyyy.

Offline

#19 2013-05-18 19:39:21

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 200

Re: Systemd delay of 60 sec on boot due to NFS mount [SOLVED]

Sorry for hijacking but does anybody know why this same script doesn't work on my laptop? (wireless)

NetworkManager[251]: <warn> Dispatcher script failed: Script '/etc/NetworkManager/dispatcher.d/nfs.sh' exited with error status 32

Offline

Board footer

Powered by FluxBB