You are not logged in.
Pages: 1
Topic closed
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 packages • Zsh and other configs
Offline
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
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
@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 packages • Zsh and other configs
Offline
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
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
It's the positional argument
$ ./foo bar baz
foo = $0
bar = $1
baz = $2
Offline
Of what?
Offline
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
You've just confused me even more by not explaining how this relates to the networkmanager script
Offline
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
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
Last edited by gonX (2013-05-18 15:58:46)
since 2009
Offline
Thanks gonX, so NetworkManager output "status" corresponds to variable $2. I see now.
Offline
Thanks gonX, so NetworkManager output "status" corresponds to variable $2. I see now.
If I get it right, 'status' is $1.
Offline
Unless there is something else before "interface" and "status"
Offline
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
Ah, now I get it. I thought they were mutually exclusive.
Soooorryyyy.
Offline
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
I ran into the same problem with the script not running. For posterity's sake -- I'm a little late to help, but only by a couple of years -- I'm leaving my solution here.
The problem was due to SELinux preventing NetworkManager from mounting the directory.
The steps to correct the problem:
Changing SELinux to permissive mode in /etc/selinux/config
reboot
grep NetowrkManager_t /var/log/audit/audit.log | audit2allow -M nm_mount
selinux -i nm_mount.pp
Change SELinux back to enforcing in /etc/selinux/config
reboot
You should look at the nm_mount.te to see what it's doing before you blindly allow the new module. If there is anything along the lines of this, you will want to relabel the directory you're mounting to first:
#!!!! WARNING: 'home_root_t' is a base type.
See Think before you just blindly audit2allow -M mydomain for more info on that.
Offline
Thank you for the solution and welcome to the forums. As you noticed, you have awakened a sleeping thread. I'll use this opportunity to put it back to sleep.
Closing.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
A couple years? It was a 5 year old thread ... that was already solved.
Do not necrobump old threads, especially solved ones.
Closed (edit: too slow ... but damnit, the timestamps are the same down to the second.)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Pages: 1
Topic closed