You are not logged in.

#1 2013-04-26 14:15:01

battlepanic
Member
Registered: 2009-08-22
Posts: 76

systemd fails to unmount CIFS network share on shutdown/reboot

I am occasionally manually mounting a CIFS share under my home directory.  I have noticed that systemd fails to unmount this particular share on shutdown or reboot.  The attempt to unmount the share will eventually timeout after a couple of minutes.

It has been suggested that my problem is due to systemd bringing down the network before attempting to unmount this particular share, though I don't know if this is actually the case.

Is there a prescribed solution to this particular issue?

Note that I have three other CIFS shares which are mounted /mnt using the systemd automount facility with the configuration specified in /etc/fstab.  None of these CIFS shares seem to suffer the same problem.

Offline

#2 2013-04-27 22:23:23

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

Re: systemd fails to unmount CIFS network share on shutdown/reboot

Systemd uses your fstab to generate native unit files.  These are kept in /run/systemd/generator.  Go find the relavent unit files and copy them to /etc/systemd/system (botht the mnt.mount and mnt.automount).  Then remove the needed parts like the SourcePath= lines and the "noauto,x-systemd.automount" from the options line.  You no longer need that part because that only tells systemd to generate these automount units in addition to the mount unit.   You will need to add an [Install] section to the automount file, so that you can enable it.  For my NFS automounts, I have it "WantedBy=remote-fs.target".

Then to fix your problem, you will need to give it some kind of dependency setup against your network manager of choice.  So you should put "After=NetworkManager.service" into the mount unit.  This will ensure that it will not be mounted until after NetworkManager has been started.  Though the automount unit will be harmlessly started.  This will also make it so that if the mount unit has been started (/mnt is mounted), NetworkManager will not be stopped until after your share has been unmounted.

Hope that made sense.

Offline

#3 2013-04-28 02:27:35

kevdog
Member
Registered: 2013-01-26
Posts: 102

Re: systemd fails to unmount CIFS network share on shutdown/reboot

Just wondering if you somehow could make it go the other way -- lets say if Network Manager were stopped, it would automatically unmount the cifs mount point?  I'm just wondering if this would be best controlled in a systemd file or within a configuration file native to NetworkManager itself.

Offline

#4 2013-04-28 02:46:00

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

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I don't know... I have never tried to achieve such a thing.  But maybe if you added some kind of hard dependency to NetworkManager from the cifs mount unit file.  So I guess this would mean using the Requires=NetworkManager.service as well as After=NetworkManager.service.  I am not sure if that would mean that if NetworkManager were stopped then it would also (and first) disconnect the cifs share.

Give it a go and see what happens.

Offline

#5 2013-04-28 08:59:57

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: systemd fails to unmount CIFS network share on shutdown/reboot

FYI, you can use a script in /etc/NetworkManager/dispatcher.d to mount remote shares after connecting and unmount them before disconnecting.

Offline

#6 2013-04-28 15:01:21

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

Re: systemd fails to unmount CIFS network share on shutdown/reboot

lucke wrote:

FYI, you can use a script in /etc/NetworkManager/dispatcher.d to mount remote shares after connecting and unmount them before disconnecting.

I always forget about that feature of NetworkManager.  I guess that also brings up the point that with netctl there is the ExecUpPost= and ExecDownPre= that would certainly handle this functionality.  It would also confine the mount and unmount of that share to a certain network, which I think is exactly what you are looking for.

Offline

#7 2013-04-29 00:03:20

battlepanic
Member
Registered: 2009-08-22
Posts: 76

Re: systemd fails to unmount CIFS network share on shutdown/reboot

My knowledge of the systemd mount facilities is sketchy so this is all helpful information.

In my particular case, I have automount points which aren't presenting any issues even though I have configured them in the /etc/fstab file.  I rely on these network shares all the time and there are only a couple of them so it is easy to maintain.

My main problem seems to be with CIFS network shares which I mount manually during the course of my session.  The particular shares to which I am connecting varies and there at least a couple dozen or so to choose from.  I don't necessarily know, in advance which of these shares I will be mounting.

To make this work, do I have to let systemd know about every possible share I might ever want to mount in advance?

Can systemd somehow query the system to determine which mount points are network-dependent and create the necessary dependencies on automatically?

Offline

#8 2013-04-29 01:08:38

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

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I am not sure exactly what you are asking here.  In your first post you mentioned that you had this handled by entries in the fstab.  But in terms of the dependencies necessary to make the system know how to do this, there are a couple different targets in place.  There is the local-fs.target as well as the remote-fs.target.  So when you mount something handled by systemd and it is a network-dependent target, it should know and place it in the remote-fs.target.  When doing things manually, I would have to imagine that init (systemd) should know that these filesystems are remote and that it should remove them on shutdown before downing the network.target.  Does it do this?  I have no idea.  I honestly don't have enough network shares not to put them all in either my fstab or native systemd units.

Edit: Just a friendly hint.  The systemd mailing list and IRC channel are extremely friendly places.  There can be some highly technical discussion going on, but they seem to be always willing to help.

Last edited by WonderWoofy (2013-04-29 01:09:59)

Offline

#9 2013-04-29 13:38:17

battlepanic
Member
Registered: 2009-08-22
Posts: 76

Re: systemd fails to unmount CIFS network share on shutdown/reboot

Thanks for all this info.  I think my original post may have been a bit confusing because I closed by mentioning that in contrast to my problem mountpoint, the few CIFS shares I have which are mounted automatically using systemd do work well.  These automatically mounted shares are unmounted cleanly on shutdown so they are actually not the issue.

My issue is with CIFS shares which I mount manually, using the mount command from the shell.  I don't necessarily know which particular share I'll be mounting in advance, so as far as I can tell, it's not practical to configure an automount/mount unit through systemd.

Although these "manually mounted" shares are not mounted by systemd, I wonder if it is possible for systemd to recognize that these particular mountpoints depend on network connectivity and then subsequently do the right thing on shutdown.

I haven't checked the systemd mailing list nor the IRC channel.  I'll have a look over there and see if someone can shed some more light.

Offline

#10 2013-04-29 14:14:45

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I'm no systemd expert, but this inspired me to do some messing around.

It seems that when you mount something, systemd creates a corresponding .mount unit. For example, when I mount /mnt/phoenix (noauto cifs specified in fstab), systemctl list-units will show a new unit "mnt-phoenix.mount". Similarly, if I "manually mount" /mnt/manualcifs, systemctl list-units will then show "mnt-manualcifs.mount". I looked at both of these units with systemctl show <unit> and both look like they should be handled similarly at shutdown/restart.

So my guess is that what you're experiencing is a bug. The question is, Arch or upstream?


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#11 2013-06-02 06:38:28

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I wonder if OP has found a solution to this? Or anyone has a solution? I have the same problem.

Mount samba share entry in fstab (automount): no problem shutdown/reboot
Same entry as above, set to noauto, manually mounted: shutdown/reboot waits for share to be umounted for about 1 or 2 minutes (timeout).

Same as above but with vbox share (vboxsf), no problems.

Offline

#12 2013-06-12 13:17:23

battlepanic
Member
Registered: 2009-08-22
Posts: 76

Re: systemd fails to unmount CIFS network share on shutdown/reboot

stryder wrote:

I wonder if OP has found a solution to this?

I have not found a solution to this problem.  Admittedly I haven't put much time into it and this annoyance is currently pretty far down on my list of TODO's.  As WonderWoofy suggested, raising the issue in the systemd IRC channel and/or the systemd mailing list may bear some fruit if you're interested in figuring this one out.

Offline

#13 2013-06-12 13:56:55

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: systemd fails to unmount CIFS network share on shutdown/reboot

stryder wrote:

Same as above but with vbox share (vboxsf), no problems.

Do vbox shares communicate over the network, though? If not, the comparison is meaningless.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#14 2013-06-13 17:14:23

jqvillanova
Member
From: Madrid, Spain
Registered: 2013-04-25
Posts: 17

Re: systemd fails to unmount CIFS network share on shutdown/reboot

Mount the share with -o intr , if don't no SIGKILL could bring down the processes using the share

Offline

#15 2013-06-13 18:03:14

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

Re: systemd fails to unmount CIFS network share on shutdown/reboot

jqvillanova wrote:

Mount the share with -o intr , if don't no SIGKILL could bring down the processes using the share

This is a hack. Do not do this.

I'm fairly sure I've dissected the problem in the bug report that stryder filed, but I've not had time to look at the code behind this.

Offline

#16 2013-06-13 22:18:33

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I don’t use cifs but if it uses processes like sshfs does, this may help: https://wiki.archlinux.org/index.php/Ss … is_mounted

Offline

#17 2013-06-21 05:08:22

Padfoot
Member
Registered: 2010-09-03
Posts: 381

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I am experiencing a similar issue on one of my machines (my media centre). THe funny thing is, I am using the same scripts on both machines to mount and unmount my CIFS shares. The scripts are run via netctl as ExecPostUp and ExecPreDown. On my laptop, over wireless, it is working flawlessly. The shares are unmounted before the network is brought down. On my media centre (ethernet), well dhcpd is killed even before systemd gets to bringing down netctl, resulting in no network device being available and the system hanging when netctl executes the ExecPreDown script to unmount the shares.

I used to put the shares (with a noauto) in fstab and then use ExecPostUp and ExecPreDown to mount them, but that was also resulting in the network going down before the unmount script was run. So I just removed the fstab entries and did all the mounting options in the scripts. This fixed the laptop (wireless) freeze, but not the media centre (ethernet) freeze.

I just don't get why dhcpd is being stopped before netctl. Should that not happen until after netctl has gone down?

CIFS shares have always been a headache for me for this reason, even with initscripts. I finally got a model working perfectly with initscripts, and then systemd came along and I have had issues ever since.

Cheers.

[EDIT] Doing a systemctl show on the mount profiles systemd creates gives a possible cause. There is a loaderror resulting in the mount being dead, which I am guessing leads systemd to ignore it on shutdown, yet the mount succeeded.

Id=mount-library.mount
Names=mount-library.mount
Description=mount-library.mount
LoadState=error
ActiveState=inactive
SubState=dead
InactiveExitTimestampMonotonic=0
ActiveEnterTimestampMonotonic=0
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=yes
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureIsolate=no
IgnoreOnIsolate=yes
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
ConditionTimestampMonotonic=0
ConditionResult=no
LoadError=org.freedesktop.DBus.Error.FileNotFound "No such file or directory"
TimeoutUSec=1min 30s
ControlPID=0
DirectoryMode=0755
Result=success
UMask=0022
LimitCPU=18446744073709551615
LimitFSIZE=18446744073709551615
LimitDATA=18446744073709551615
LimitSTACK=18446744073709551615
LimitCORE=18446744073709551615
LimitRSS=18446744073709551615
LimitNOFILE=65536
LimitAS=18446744073709551615
LimitNPROC=127460
LimitMEMLOCK=65536
LimitLOCKS=18446744073709551615
LimitSIGPENDING=127460
LimitMSGQUEUE=819200
LimitNICE=0
LimitRTPRIO=0
LimitRTTIME=18446744073709551615
OOMScoreAdjust=0
Nice=0
IOScheduling=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SecureBits=0
CapabilityBoundingSet=18446744073709551615
MountFlags=0
PrivateTmp=no
PrivateNetwork=no
SameProcessGroup=yes
ControlGroupModify=no
ControlGroupPersistent=no
IgnoreSIGPIPE=yes
NoNewPrivileges=no
KillMode=control-group
KillSignal=15
SendSIGKILL=yes

Calling systemctl stop on the mount fails as the mount is dead so considered not mounted by systemd

# systemctl stop mount-library.mount
Failed to issue method call: Unit mount-library.mount not loaded.

[/edit]

Last edited by Padfoot (2013-06-21 05:22:52)

Offline

#18 2013-06-28 06:44:00

butler360
Member
Registered: 2012-09-08
Posts: 29

Re: systemd fails to unmount CIFS network share on shutdown/reboot

I've found that mine with never shut down when I have Crashplan running, which is set to back up a CIFS mount. If I kill Crashplan it works eventually, so it seems like that constantly pinging it locks it up.

Seems to be a similar bug already filed: https://bugs.freedesktop.org/show_bug.cgi?id=59152

Offline

Board footer

Powered by FluxBB