Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Desktop PC can't unmount network shares at shutdown

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Desktop PC can't unmount network shares at shutdown

#1 Post by csabix »

Hello all!

I have this problem since I changed my server to Stretch, back in august 2017: when my Debian Jessie desktop PC is shutting down, it hangs at unmounting network shares that are on the Debian Stretch server saying "a stop job is running for /path/to/netwrok/share. It is quite annoying when comparing this 90 second delay to the usual 4-8 seconds that I was used to in the past.

Here is how I share the directory on the Stretch server.
/etc/samba/smb.conf:

Code: Select all

[Backup]
    valid users = %S
    path = /mnt/Backup
    browseable = yes
    read only = no
    guest ok = yes
And this is the /etc/fstab file on the PC:

Code: Select all

# BACKUP DISK
//192.168.0.2/Backup    /home/bocskai/Backup    cifs    username=*****,password=******,iocharset=utf8,sec=ntlmssp        0       0
Username and pass have been scrambled intentionally.

First I thought it's because the passwords on the two machines were different. Changed them to be the same. After that, there was no stop job message but the PC hung with a blank screen and a blinking cursor. Needed to hard reboot the machine.

I cannot see anything in the Samba logs (nmbd.log, smbd.log, 192.168.0.5.log), nor in dmesg, daemon.log etc.

Is this problem serviceable or is it a bug?


Thanks in advance!
Last edited by csabix on 2018-03-04 08:11, edited 2 times in total.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Desktop system cannot unmount network shares during shut

#2 Post by peter_irich »

Try unmount this resource explicitly before shutdown by command as root

Code: Select all

umount -v //192.168.0.2/Backup
or

Code: Select all

umount -v /home/bocskai/Backup
will be the behavior the same or not.

Peter.

csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Re: Desktop system cannot unmount network shares during shut

#3 Post by csabix »

Umounting from command line works.
The problem is that I want to fix it so manual unmounting is not needed in the future.

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Desktop system cannot unmount network shares during shut

#4 Post by peter_irich »

You can write script or service to unmounting this resource at shutdown.

Peter.

csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Re: Desktop system cannot unmount network shares during shut

#5 Post by csabix »

Yes. I did check out some documentation but it seemd to complicated. Even the old init way wasn't simple and the systemd way seemed at least as complicated.
BUT, maybe I was loking at the wrong information.
Do you know a working method that doesn't take days to apply?

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Desktop system cannot unmount network shares during shut

#6 Post by peter_irich »

The easiest way is to write script for /etc/ini.d/, there is skeleton like example.
Script must work in levels to stopping only - 0, 1 and 6 on order K0.
It must be settled by command

Code: Select all

update-rc.d script_name stop 1 0 1 6 .
Scripts with the same stop/start level are executed in alphabet order.

Peter.

User avatar
cds60601
df -h | participant
df -h | participant
Posts: 716
Joined: 2017-11-25 05:58
Location: Florida
Has thanked: 133 times
Been thanked: 63 times

Re: Desktop system cannot unmount network shares during shut

#7 Post by cds60601 »

[quote="csabix"]Hello all!

I have this problem since I changed my server to Stretch, back in august 2017: when my Debian Jessie desktop PC is shutting down, it hangs at unmounting network shares that are on the Debian Stretch server saying "a stop job is running for /path/to/netwrok/share. It is quite annoying when comparing this 90 second delay to the usual 4-8 seconds that I was used to in the past.

Here is how I share the directory on the Stretch server.
/etc/samba/smb.conf:

Code: Select all

[Backup]
    valid users = %S
    path = /mnt/Backup
    browseable = yes
    read only = no
    guest ok = yes
And this is the /etc/fstab file on the PC:

Code: Select all

# BACKUP DISK
//192.168.0.2/Backup    /home/bocskai/Backup    cifs    username=*****,password=******,iocharset=utf8,sec=ntlmssp        0       0

Here is the line I use in my /etc/fstab:

# Eagle project folder
//earth/chris/Projects/eagle /home/chris/eagle cifs credentials=/home/chris/.smbcredentials,uid=1000,iocharset=utf8,noperm 0 0


You will notice that I use a file for authing the share (chmod 600). Also worth noting, my client is STABLE, the server is STABLE and I have another client that is Windows 7 that access the shares on the samba server.

Unmounting is flawless for me on all systems when I shutdown etc
Supercalifragilisticexpialidocious

pendrachken
Posts: 1394
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: Desktop system cannot unmount network shares during shut

#8 Post by pendrachken »

Known issue. Been there since the dawn of time.

It happens because for some reason MOST machines will stop the network service before umounting filesystems. You can't umount a network filesystem without the network, so you have to wait for the timeout to be reached and a fail condition to be made from the shutdown umount helper. Occasionally you get one here or there that doesn't shutdown stuff in the same order so you get one that works properly.

One workaround you can use if your desktop environment / window manager supports shutdown / logout scripts is to have a script umount all of your network shares on a shutdown. Obviously this won't work if you shutdown through the CLI or some other way than your desktop.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P

csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Re: Desktop system cannot unmount network shares during shut

#9 Post by csabix »

Hello all

Big thanks for the replies and suggestions.
I was also suspecting that the network was done before unmounting shares.
Two days ago I got a Linux job and had plenty of time and motivation to experiment with systemd startup services. After the first succesful configuration I realized I can write a workaround to this problem.

The solution has two components: a script that unmounts the shares and a systemd service that launches the script right after the graphical interface goes down.
The reason I didn't bother learning init.d is that it might become obsolete in a few years.

The script looks like this:

Code: Select all

#!/bin/bash
umount /home/bocskai/ns2/Dokumentacio
umount /home/bocskai/ns2/Transfer
umount /home/bocskai/Backup
It must be executable! Can be written and stored by any user.

The service looks like this:

Code: Select all

[Unit]
Description=Unmount network shares at KDE shutdown. To be placed in /etc/systemd/system.
After=graphical.target

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/home/bocskai/Scripts/UmountShares.sh

[Install]
WantedBy=multi-user.target
It has to be placed in /etc/systemd/system. You will need to be root. Keep a backup copy in your user's home directory!

Thank you all


PS: I'll consider using a dedicated credentials file in my fstab.

csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Re: Desktop PC can't unmount network shares at shutdown

#10 Post by csabix »

Well... It still doesn't work. At least not always.
I cannot iamgine why sometimes it works perfectly adn other times it hangs at "a stop job is bla bla bla".
I start to suspect my server is at fault.

Philippe1
Posts: 1
Joined: 2018-03-10 10:53

Re: Desktop PC can't unmount network shares at shutdown

#11 Post by Philippe1 »

Greetings,

I had the same problem in the past. It was fixed by adding (in FSTAB) the option _netdev for each Network drive.
Since I don't mount Network drives anymore at startup, I cannot guarantee that it would still work but I think it is worth a shot...

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Desktop PC can't unmount network shares at shutdown

#12 Post by peter_irich »

I think "_netdev" used at mount time. Perhaps it might try "nofail".

Peter.

csabix
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe
Contact:

Re: Desktop PC can't unmount network shares at shutdown

#13 Post by csabix »

Got it solved on another path.
I made a desktop icon in KDE. In the Apllication path form, I wrote:

Code: Select all

kdesu /path/to/application
Now, when I click on the icon, it asks for root password. After that, I can shut down my PC in a matter of seconds (less than 10) :D

I will also do some research on _netdev. Some sources say, systemd doesn't need it. But I'll read some documentation anyway.
Thank you!

Post Reply