You are not logged in.
Hello,
I just installed ArchLinux on my work laptop (that I can also use at home) and I have a problem with my setup with my NAS.
Here is the line I have in my /etc/fstab
#//Synology/video /mnt/data/synology/video cifs users,gid=users,rw,suid,credentials=/etc/cifspwd 0 0
I commented it out because I am trying a few things to solve my problem but the mount is fine at startup. I can access my Synology NAS without problem.
The problem comes when I shutdown my computer. The system needs a time out of the umount to restart.
Apparently, I am not the only one with this problem (the network shuts down before umount so the system hangs because of that). I could find solution with DAEMONS list but that was prior systemd.
I tried to create a service like this but it doesn't work either :
cat /usr/local/bin/mount_cifs.sh
#!/bin/sh
mount -t cifs -o credentials=/etc/cifspwd //Synology/video /mnt/data/synology/video
cat /usr/local/bin/umount_cifs.sh
#!/bin/sh
umount -t cifs /mnt/data/synology/video
cat /usr/lib/systemd/system/cifs.service
[Unit]
Description=CIFS manager
Wants=network.target
After=network.target[Service]
ExecStart=/usr/local/bin/mount_cifs.sh
ExecStop=/usr/local/bin/umount_cifs.sh[Install]
WantedBy=multi-user.target
When I executed the script manually, they work. When I execute them with systemctl start cifs.service et systemctl stop cifs.service, they seem to work
systemctl status cifs.service
cifs.service - CIFS manager
Loaded: loaded (/usr/lib/systemd/system/cifs.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sat 2016-01-09 22:10:51 CET; 7min ago
Process: 1827 ExecStop=/usr/local/bin/umount_cifs.sh (code=exited, status=0/SUCCESS)
Process: 1786 ExecStart=/usr/local/bin/mount_cifs.sh (code=exited, status=0/SUCCESS)
Main PID: 1786 (code=exited, status=0/SUCCESS)Jan 09 22:10:49 arch systemd[1]: Started CIFS manager.
Jan 09 22:10:51 arch umount_cifs.sh[1827]: umount: /mnt/data/synology/backup: target is busy
Jan 09 22:10:51 arch umount_cifs.sh[1827]: (In some cases useful info about processes that
Jan 09 22:10:51 arch umount_cifs.sh[1827]: use the device is found by lsof(8) or fuser(1).)
Unfortunately, when I reboot, the system hangs (I think the error/exit code is 32).
systemctl status cifs.service
cifs.service - CIFS manager
Loaded: loaded (/usr/lib/systemd/system/cifs.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2016-01-09 22:22:35 CET; 26s ago
Process: 565 ExecStop=/usr/local/bin/umount_cifs.sh (code=exited, status=32)
Process: 459 ExecStart=/usr/local/bin/mount_cifs.sh (code=exited, status=32)
Main PID: 459 (code=exited, status=32)Jan 09 22:22:35 arch umount_cifs.sh[565]: umount: /mnt/data/synology/video: not mounted
Jan 09 22:22:35 arch systemd[1]: cifs.service: Control process exited, code=exited status=32
Jan 09 22:22:35 arch systemd[1]: cifs.service: Unit entered failed state.
Jan 09 22:22:35 arch systemd[1]: cifs.service: Failed with result 'exit-code'.
Any idea on how to fix my service or maybe the correct way to fix this ?
Thanks a lot
Last edited by hiveNzin0 (2016-01-13 11:11:05)
Offline
Try adding "-l" to the umount command.
-edit-
You also probably want Type=oneshot and RemainAfterExit=yes in your service file.
Last edited by lucke (2016-01-09 23:29:42)
Offline
Hi,
thanks for the reply. I also found the option -l for lazy unmount but it doesn't work either.
Here is my setup :
Scripts :
cat /usr/lib/systemd/system/cifs.service
[Unit]
Description=CIFS manager
Wants=network.target NetworkManager.service
After=network.target NetworkManager.service[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/mount_cifs.sh
ExecStop=/usr/local/bin/umount_cifs.sh[Install]
WantedBy=multi-user.target
cat /usr/local/bin/mount_cifs.sh
#!/bin/shserverIp="192.168.0.125"
ping -c 3 ${serverIp} > /dev/null 2>&1
if [ $? -eq 0 ]
then
mount -t cifs -o credentials=/etc/cifspwd //Synology/video /mnt/data/synology/video
fi
cat /usr/local/bin/umount_cifs.sh
#!/bin/shmountPoint="/usr/bin/mountpoint"
synoVideo="/mnt/data/synology/video"if ${mountPoint} -q ${synoVideo};
then
echo "unmounting ${synoVideo}"
umount -t cifs -l ${synoVideo}
fi
Home :
Synology NAS on 192.168.0.125 (I need the wifi to access it otherwise I am not on the same network with an ethernet cable)
ifconfig
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.36 netmask 255.255.255.0 broadcast 192.168.1.255wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.103 netmask 255.255.255.0 broadcast 192.168.0.255
I need the executestart of cifs.service to be executed after the wifi is up. I thought that adding NetworkManager.service to wants and after in cifs.service would work but apparently not. They are not mounted at startup. The only way to mount them during startup is if I remove the comment in /etc/fstab
The tests in unmount_cifs.sh are useless because this script seems to be executed after the network is down, I am just testing a few things at the moment.
edit :
I changed my cifs.service to
Wants=network-online.target
After=network-online.target
and everything is mounted at startup which is what I want. Unfortunately, there is still the problem during shutdown/reboot. The system stops the wifi then tries to unmount the network mountpoint.
Last edited by hiveNzin0 (2016-01-10 10:14:06)
Offline
Hi
any idea on how to force the unmount before the wifi is down ? I tried network-online and wpa_supplicant but I still have the problem. My wifi has no protection (no WEP, no WPA).
Offline
IIRC, the problem is that your desktop networkmanager applet will disconnect the wifi on logout/shutdown from the desktop environment.
at that point systemd ordering of services becomes moot.
maybe try to make the connection a globcal/system one (all users can connect, etc...)
Offline
If you use NetworkManager, you can try using dispatcher.
Offline
If you use NetworkManager, you can try using dispatcher.
I assume you mean this : https://wiki.archlinux.org/index.php/Ne … dispatcher
I should have read the wiki more carefully, I got lost on other pages.
I will try tonight, thanks.
Offline
Weird, I still had the same problem with the umount_cifs.sh script in the dispatcher.
I fixed my problem by creating alias for reboot and shutdown which executes umount_cifs.sh then reboot/shutdoyn
I left the mount_cifs.sh be managed by my cifs service and everything works.
Thanks.
Offline