The officially official Devuan Forum!

You are not logged in.

#1 Yesterday 12:41:55

Roberto
Member
Registered: 2023-08-20
Posts: 10  

Unmount CIFS shares before shutdown

I am using Devuan Excalibur and I have mounted various CIFS shares in fstab at startup.
Now I want to unmount these shares before shutdown.

I created the folders Data and Storage in my home directory as mountpoint for theses shares.

I tried this with the following simple script:

#!/bin/sh

umount -l /home/user/Data
umount -l /home/user/Storage

exit

I saved this script in the folder /etc/NetworkManager/dispatcher.d/pre-down.d and then made it executable with the command

sudo chmod +x /etc/NetworkManager/dispatcher.d/pre-down.d/umount.sh

Nevertheless, it takes about 3 minutes for the system to shut down.

Thank you in advance for your help an tips.

Regards
Roberto

Last edited by Roberto (Yesterday 12:46:13)

Offline

#2 Yesterday 13:36:07

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,559  

Re: Unmount CIFS shares before shutdown

Do you really want that script to exit before the unmounting has completed?
If not, then don't use "-l" as umount option.

Offline

#3 Yesterday 13:44:03

Dutch_Master
Member
Registered: 2018-05-31
Posts: 311  

Re: Unmount CIFS shares before shutdown

Rename the script cifsdown.sh, copy to /etc/init.d, give it executable rights like you already did then create a symlink in /etc/rc0.d Make sure the sym-link in /etc/rc0.d is named K01cfisdown.sh DO NOT deviate from that name, as the order of shutting down services is important.

Alternatively, execute the following line by line:

sudo su #only if you use sudo, otherwise just use su instead
mv /etc/NetworkManager/dispatcher.d/pre-down.d/umount.sh /etc/init.d/cifsdown.sh
chmod +x /etc/init.d/cifsdown.sh
ln -s /etc/init.d/cifsdown.sh /etc/rc0.d/K01cifsdown.sh

You can use cp instead of mv to keep a copy in the original location. That's the difference between cp and mv: cp leaves a copy, mv (move) doesn't. Make sure you disable the script left there before rebooting:

chmod -x /etc/NetworkManager/dispatcher.d/pre-down.d/umount.sh

HTH!

Offline

Board footer