# nfs and systemd : mounting as users but unmounting not

## mpcww

A few weeks ago I switched to systemd.

In the fstab mounting is alowed to normal user:

```
n.n.n.n:/fotos   /marvin/fotos   nfs   noauto,user      0 0
```

```
~$ mount /marvin/fotos/

~$ umount /marvin/fotos/

umount: /marvin/fotos: umount failed: operation not permitted

```

Do I miss another mount option ?

The same configuration worked with openrc by now .

Any hints are appreciated.

----------

## croutch

Maby is what you looking for?

https://bbs.archlinux.org/viewtopic.php?pid=1260240#p1260240

croutch

----------

## mpcww

 *croutch wrote:*   

> Maby is what you looking for?
> 
> https://bbs.archlinux.org/viewtopic.php?pid=1260240#p1260240
> 
> croutch

 

Hi croutch,

thanks for  the archlinux-alternative. 

As fas as I understand that thread it doesn't refer on gentoo and offers a non-systemd solution.

This is what I already have and use with the alternative system start via openrc .

Is there really no simple mount/unmount solution for systemd without stumbling across this permission-denied-problem ?

To be honest I don't need/want any automount possibilty

the

The umount command from the script in 

https://bbs.archlinux.org/viewtopic.php?pid=1260240#p1260240

gives me

```

~$ umount -l -f /marvin/mucke/

umount: only root can use "--force" option

~$ umount -l  /marvin/mucke/

umount: /marvin/mucke: umount failed: operation not permitted

```

I would like to be able to unmount as a regular user.

----------

## Gentree

Can you umount a non nfs partition as user?

----------

## mpcww

 *Gentree wrote:*   

> Can you umount a non nfs partition as user?

 

With openrc it worked as expected.

I used a write-protected sdcard for the test.

After inserting it was not automounted.

Now with sytemd:

Inserting the sdcard:

```
Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] 15556608 512-byte logical blocks: (7.96 GB/7.41 GiB)

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] Write Protect is on

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] Mode Sense: 03 00 80 00

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] No Caching mode page present

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] Assuming drive cache: write through

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] No Caching mode page present

Oct 29 08:21:39 arthur kernel: sd 6:0:0:1: [sdf] Assuming drive cache: write through

Oct 29 08:21:39 arthur kernel: sdf: sdf1

```

Check per 'mount' it is not automounted as well.

mounting

```

~$ mount /mnt/mp3playerVorne/

mount: /dev/sdf1 is write-protected, mounting read-only

mount

/dev/sdf1 on /mnt/mp3playerVorne type vfat (ro,nosuid,nodev,noexec,relatime,uid=1000,gid=4244,fmask=0022,dmask=0022,codepage=850,iocharset=utf8,shortname=mixed,errors=remount-ro,user=mpcww)

```

permissions

```
~$ ls -ld /mnt/mp3playerVorne/

drwxr-xr-x 8 mpcww mpcww 4096  1. Jan 1970  /mnt/mp3playerVorne/

```

unmounting:

```

~$ umount /mnt/mp3playerVorne/

[mpcww@arthur 2013-10-29 08:24:32:CET T2:L:2:C506]

```

It works as expected, so a regular user can mount / umount an usb device, but not a nfs-partition.

fstab settings I use

( first usbdevice, second nfs-device)

```

/dev/sdf1               /mnt/mp3playerVorne  vfat               iocharset=utf8,codepage=850,noauto,rw,user

192.168.3.25:/mucke     /marvin/mucke   nfs                noauto,user             0 0

```

Good hint, to check and compare that !

----------

## Gentree

That is what I suspected, so you maybe need to be looking at nfs permissions, rather than mount itself. 

Mount reported the error but it may not be the origin of the error. 

Perhaps look at /etc/exports

Try grepping dmesg and /var/log/messages for "nfs"

----------

## mpcww

Yes, your right, it is not a systemd/openrc-issue .

 *Gentree wrote:*   

> 
> 
> Perhaps look at /etc/exports
> 
> Try grepping dmesg and /var/log/messages for "nfs"

 

As root I can umount the nfs mounted as normal user.

The server is qnap-nas and its /etc/exports has configured in this case.

```
"/share/HDA_DATA/fotos" 192.168.1.20(rw,async,no_root_squash,insecure) 192.168.3.15(rw,async,no_root_squash,insecure)
```

On the server /var/log/messages is empty.   :Sad: 

On the client I find just these entries:

```
Oct 29 07:59:52 arthur kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).

Oct 29 07:59:52 arthur systemd[1]: Starting NFS server...

Oct 29 07:59:52 arthur systemd[1]: Starting NFSv2/3 Network Status Monitor Daemon...

Oct 29 07:59:52 arthur rpc.statd[18139]: Running as root.  chown /var/lib/nfs to choose different user

Oct 29 07:59:52 arthur systemd[1]: Started NFSv2/3 Network Status Monitor Daemon.

Oct 29 10:11:01 arthur kernel: NFS: Registering the id_resolver key type

Oct 29 10:24:37 arthur kernel: nfsd: last server has exited, flushing export cache

Oct 29 10:25:39 arthur kernel: RPC: Registered tcp NFSv4.1 backchannel transport module.

Oct 29 10:25:40 arthur rpc.statd[18060]: Running as root.  chown /var/lib/nfs to choose different user

Oct 29 10:31:41 arthur kernel: NFS: Registering the id_resolver key type

```

 *Quote:*   

> arthur mpcww # dmesg | grep -i nfs
> 
> [    5.688075] RPC: Registered tcp NFSv4.1 backchannel transport module.
> 
> [  384.396136] NFS: Registering the id_resolver key type
> ...

 

----------

## musv

I had this problem too. The solution is easy but it's only a workaround with ugly side-effects. 

Systemd wants to have /etc/mtab as a symlink to /proc/self/mounts. Because /etc/mtab keeps older entries even after a reboot. But setting the symlink causes the umount problem. So just revert /etc/mtab to an ordinary file and you'll be able to unmount nfs-partitions again as a user. 

```
rm /etc/mtab

cat /proc/self/mounts > /etc/mtab
```

The side-effect is, that the output of mount contains some mount entries up to 20 times. Haven't noticed any unwanted behaviour yet.Last edited by musv on Mon Nov 04, 2013 11:36 pm; edited 1 time in total

----------

## Gentree

```
Oct 29 10:25:40 arthur rpc.statd[18060]: Running as root.  chown /var/lib/nfs to choose different user

```

perhaps that's where to look. no time now.

----------

## mpcww

 *Gentree wrote:*   

> 
> 
> ```
> Oct 29 10:25:40 arthur rpc.statd[18060]: Running as root.  chown /var/lib/nfs to choose different user
> 
> ...

 

At the first glance that seemed really compelling.

But today I did a mount / unmount with another gentoo-client machine.

The difference: no gnome3 an systemd-use flag.

I don't see a clear relationship.

But in the past weeks I observerd some strange side effects while running the instable setup with systemd and gnome3, even if I booted that machine with openrc (for example calibre couldn't detect ereader plugged in due to dependies between udisk and the systemd use flag, do booted with openrc it didn't work any more).

I just decided to get rid of systemd and gnome3.

Anyway, thanks for your support and figuring out some possibilities.

----------

## dmpogo

Should not the mount option be  be 'users'   with 's' rather than 'user'  to allow unmounting ? (man mount says 'user' allows only to mount but not unmount)

----------

## mpcww

I think they mean "users" is necessary if you want a different user to umount. 

If the user mounts and unmounts it doesn't matter.

----------

