You are not logged in.

#1 2014-12-28 21:54:56

leonixyz
Member
Registered: 2014-07-12
Posts: 62

mount NFS as non-root user

I followed this wiki article and my nfs server (a raspberry-pi) works well. I can mount on my laptop (as superuser) all exported directories without problems. However, I want mount them as normal user, manually, into my home folder.

This is part of my fstab:

# NFS @ raspberrypi
raspberrypi:/srv/nfs/incoming   /home/leonixyz/doc/incoming     nfs     noauto,user,noatime         0       0
raspberrypi:/srv/nfs/film       /home/leonixyz/doc/film         nfs     noauto,user,noatime         0       0
raspberrypi:/srv/nfs/music      /home/leonixyz/doc/music        nfs     noauto,user,noatime         0       0
raspberrypi:/srv/nfs/foto       /home/leonixyz/doc/foto         nfs     noauto,user,noatime         0       0

Reading the wiki I understand to enable both nfs-client.target and  rpcbind.service, but after reading this I disabled nfs-client.target. However, this seems not be the problem.

I wrote ~/bin/mount-nfs to have a fast way to mount everything:

#!/bin/bash

mount /home/leonixyz/doc/music &&
mount /home/leonixyz/doc/foto &&
mount /home/leonixyz/doc/film &&
mount /home/leonixyz/doc/incoming 

exit $?

If I try to run mount-nfs as non-root, the first line of the output states: "Failed to start rpc-statd.service: Interactive authentication required.". So, by looking a little bit into systemd's units, I also tried by adding "-t nfs" to each mount to be sure that rpc-statd.service is actually called. Unfortunately, in this way I get "mount: only root can use "--types" option".

I can workaround this by first starting rpc-statd.service manually, and then running mount-nfs. In this way it works as expected.
However, I need to sudo systemctl, and I want to avoid this because of the user mount option in fstab.
If there is a way to mount everything without typing my password it'd be great!

Thank you in advance.

Offline

#2 2014-12-28 22:33:42

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: mount NFS as non-root user

So why don't you simply enable the rpc.statd.service as well as the other recommended units?

Offline

#3 2014-12-28 22:35:37

leonixyz
Member
Registered: 2014-07-12
Posts: 62

Re: mount NFS as non-root user

WonderWoofy wrote:

So why don't you simply enable the rpc.statd.service as well as the other recommended units?

$ sudo systemctl enable rpc-statd.service 
[sudo] password for leonixyz: 
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).

as far as I understand it's not always needed to have rpc-statd.service enabled, because it's used only when mounting. So, if I "Wants" or "Requires" this unit into i.e. nfs-client.target, all the times I don't mount nfs I still have that service running... This is the unit I keep disabled to avoid getting an error in the journal at boot time (see this link)

$ cat /usr/lib/systemd/system/nfs-client.target 
[Unit]
Description=NFS client services
Before=remote-fs-pre.target
Wants=remote-fs-pre.target

# Note: we don't "Wants=rpc-statd.service" as "mount.nfs" will arrange to
# start that on demand if needed.
Wants=rpc-gssd.service rpc-svcgssd.service auth-rpcgss-module.service
Wants=nfs-blkmap.service rpc-statd-notify.service
Before=rpc-gssd.service rpc-svcgssd.service nfs-blkmap.service

[Install]
WantedBy=multi-user.target
WantedBy=remote-fs.target

Is that right?

Last edited by leonixyz (2014-12-28 22:43:02)

Offline

#4 2014-12-28 23:45:58

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: mount NFS as non-root user

Ah I see how that could be an issue then. 

I use autofs to just automagically mount my nfs shares when I venture into the directories where they are mounted (and when they are available).  You can also use the systemd autofs as well, which works quite nicely and just takes one additional fstab option to what you already have.  I like the full autofs because it will automatically unmount after a specified time of not being used.

Offline

#5 2014-12-29 00:10:08

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,367

Re: mount NFS as non-root user

sshfs could do the same thing.


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

Board footer

Powered by FluxBB