You are not logged in.

#1 2024-04-14 09:58:30

dcy3rka
Member
Registered: 2022-01-19
Posts: 52

unmount cifs on shutdown before network goes down

I mounted some cifs mount in the /etc/fstab:

//<ip>/home  /mounts/<user>  cifs  user,credentials=/etc/cifs-credentials/<user>,uid=<user>,gid=<user>,_netdev,x-systemd.requires=graphical.target,noauto,x-gvfs-name=<user>

Every time I shutdown it waits with the following message:

(1 of 2) A stop job is running for /mounts/<user> (25s / 1min 33s)

I found out that the network is stopped before and that this is probably why it can't unmount. If I unmount all shares manually before shutdown, I don't need to wait.

Then I tried to add a systemd service to force unmount before network goes down:

# cat /etc/systemd/system/unmount-cifs-before-shutdown.service
[Unit]
Description=Unmount all cifs mounts before network down on shutdown
Requires=network-online.target
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/usr/bin/umount -t cifs -all --force --lazy

[Install]
WantedBy=multi-user.target

Unfortunately without success. Any recommendations?

Offline

#2 2024-04-14 15:32:08

seth
Member
Registered: 2012-09-03
Posts: 56,103

Re: unmount cifs on shutdown before network goes down

This has nothing to do w/ the shutdown, you need to umount the shares before you lose the network, see eg. https://wiki.archlinux.org/title/Samba# … c_mounting
The best approach is to hook up w/ your network managing service, they pretty much all provide soem sort of take-down hook.

Offline

#3 2024-06-09 12:52:09

phonemic
Member
Registered: 2024-06-09
Posts: 1

Re: unmount cifs on shutdown before network goes down

Same issue here. I am interested in how to accomplish what seth is proposing.

EDIT: I found a solution. In KDE Plasma, I checked the box "All users may connect to this network" under General Configuration. My assumption is the root user couldn't connect in order to unmount the shares during poweroff/reboot.

Last edited by phonemic (2024-06-09 13:36:17)

Offline

#4 2024-06-09 13:36:27

seth
Member
Registered: 2012-09-03
Posts: 56,103

Re: unmount cifs on shutdown before network goes down

Depends on what you use to configure your network, for NM see https://wiki.archlinux.org/title/Networ … SMB_shares

Offline

Board footer

Powered by FluxBB