Desktop PC can't unmount network shares at shutdown

If none of the more specific forums is the right place to ask

Desktop PC can't unmount network shares at shutdown

Postby csabix » 2018-02-26 14:50

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.
csabix
 
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe

Re: Desktop system cannot unmount network shares during shut

Postby peter_irich » 2018-02-26 18:10

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.
peter_irich
 
Posts: 1227
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: Desktop system cannot unmount network shares during shut

Postby csabix » 2018-02-26 19:17

Umounting from command line works.
The problem is that I want to fix it so manual unmounting is not needed in the future.
csabix
 
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe

Re: Desktop system cannot unmount network shares during shut

Postby peter_irich » 2018-02-26 20:29

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

Peter.
peter_irich
 
Posts: 1227
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: Desktop system cannot unmount network shares during shut

Postby csabix » 2018-02-27 15:27

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?
csabix
 
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe

Re: Desktop system cannot unmount network shares during shut

Postby peter_irich » 2018-02-27 18:28

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.
peter_irich
 
Posts: 1227
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: Desktop system cannot unmount network shares during shut

Postby cds60601 » 2018-02-28 02:19

[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
Yeah, 220, 221. Whatever it takes.
User avatar
cds60601
 
Posts: 62
Joined: 2017-11-25 05:58

Re: Desktop system cannot unmount network shares during shut

Postby pendrachken » 2018-02-28 04:37

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
pendrachken
 
Posts: 1315
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: Desktop system cannot unmount network shares during shut

Postby csabix » 2018-03-03 07:29

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

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

Postby csabix » 2018-03-04 08:12

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.
csabix
 
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe

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

Postby Philippe1 » 2018-03-10 11:05

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...
Philippe1
 
Posts: 1
Joined: 2018-03-10 10:53

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

Postby peter_irich » 2018-03-10 12:43

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

Peter.
peter_irich
 
Posts: 1227
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

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

Postby csabix » 2018-03-12 19:42

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!
csabix
 
Posts: 194
Joined: 2007-09-23 21:15
Location: Sf Gheorghe


Return to General Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable