You are not logged in.

#1 2016-02-22 23:38:24

jdubs
Member
Registered: 2015-04-12
Posts: 9

mount nfs with systemctl --user

So, I've come across an interesting situation.

I have an NFS volume available from home. Naturally, I wanted to be able to easily mount it without typing a full address path and so on, so I added it to my /etc/fstab.

# home NFS
home.int:/srv/nfs4/media		/home/myuser/media	nfs4		ro,defaults,noauto,user		0 0

This is all well and good and allowed me to issue a simple `mount media` to gain access to my media at home. However, when I poweroff or reboot the system, it hangs seemingly forever on this mount. My next step, of course, was to have this mount managed by systemd. Specficially, I want to use the `systemctl --user` command, as this mount is specific to my user; however, I'm constantly stopped because only root can use mount, despite the fact that I have the NFS volume listed in fstab.

[Unit]
Description = mephisto media library

[Mount]
What = home.int:/srv/nfs4/media
Where = /home/myuser/media
#Type = nfs4
#Options = ro,defaults,noauto,user

[Install]
WantedBy = default.target.wants

Note that I get an error saying only root can use Type or Options. Without them, the error simply states that only root and use mount.

At the time of writing this, I think perhaps it might all be easier if I didn't use 'noauto', and thus on poweroff it might know to unmount this volume. However, I don't want to auto-mount if I can avoid it.

Any ideas? Thoughts?

Offline

#2 2016-02-23 02:50:01

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: mount nfs with systemctl --user

I may be mistaken, but I don't think you need it in both places. systemd will pick up what you have in fstab, and create it's own internal unit file at runtime for that mount. If you've then created a unit file for the same mount, your unit and runtime unit from fstab may be conflicting?

Side note, you don't need "defaults" if you're specifying options in fstab. The 'defaults' option is just a place-holder if you're not specifying any other options (because the file needs 6 fields per line).

Offline

#3 2016-02-23 03:00:40

jdubs
Member
Registered: 2015-04-12
Posts: 9

Re: mount nfs with systemctl --user

fukawi2 wrote:

I may be mistaken, but I don't think you need it in both places. systemd will pick up what you have in fstab, and create it's own internal unit file at runtime for that mount. If you've then created a unit file for the same mount, your unit and runtime unit from fstab may be conflicting?

You're correct that I don't need it in both places; however, the man page doesn't reference user unit files vs. fstab (though unit files in /usr and /etc are talked about). Nonetheless, I'll try it with the fstab entry removed and report back.

fukawi2 wrote:

Side note, you don't need "defaults" if you're specifying options in fstab. The 'defaults' option is just a place-holder if you're not specifying any other options (because the file needs 6 fields per line).

It was my understanding that defaults means rw, suid, dev, exec, auto, nouser, async, and relatime (unless otherwise overwritten), at least according to the man page.

EDIT: Commenting out the fstab entry had no effect. Still receive error stating that only root can use mount.

Last edited by jdubs (2016-02-23 03:02:59)

Offline

#4 2016-02-23 03:03:51

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: mount nfs with systemctl --user

jdubs wrote:

You're correct that I don't need it in both places; however, the man page doesn't reference user unit files vs. fstab (though unit files in /usr and /etc are talked about). Nonetheless, I'll try it with the fstab entry removed and report back.

Like I said, I could be wrong on it... I'm not completely up to speed with systemd but I do recall reading about that somewhere.

jdubs wrote:

It was my understanding that defaults means rw, suid, dev, exec, auto, nouser, async, and relatime (unless otherwise overwritten).

Exactly, those are the "defaults" -- they don't need to be specified, unless you're NOT overwriting any of them in which case the word "defaults" just provides something for the 4th column of fstab smile

Offline

Board footer

Powered by FluxBB