我按照我想要的方式工作,但是我已经跑了两次,而且我是什么让问题暴露出来 . 我想知道我的服务设置方式是否也导致它在 umount 上运行?

Udev规则:

ACTION=="add", KERNEL=="sd?1", ENV{SYSTEMD_WANTS}="sty_usbSync.service"

sty_usbSync.service:

[Unit]
Description=Syncing thumdrive with PI
Requires=media/usb0.mount
After=media/usb0.mount

[Service]
Type=oneshot
ExecStart=/opt/styles2304/sty_usbSync.sh

[Install]
WantedBy=media/usb0.mount

sty_usbSync.sh:

#!/bin/bash

#echo "STY: shutting down emulationstation..."
#killall emulationstation

echo "STY: syncing..."
rsync -rP /media/usb0/rsync/ /

echo "STY: unmounting..."
umount /dev/sdb1

#echo "STY: restarting emulationstation..."
#emulationstation

最后 systemctl status 服务的 systemctl status

Dec 09 22:43:22 retropie systemd[1]: Starting Syncing thumdrive with PI...
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: STY: syncing...
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: sending incremental file list
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: home/pi/RetroPie/roms/neogeo/test.txt
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: [110B blob data]
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: STY: unmounting...
Dec 09 22:43:22 retropie systemd[1]: Started Syncing thumdrive with PI.