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: 51,867

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.

Online

Board footer

Powered by FluxBB