树莓派3b使用systemd自动装载usb硬盘分区

树莓派3b上外接了一块硬盘,加上resilio-sync来做同步,备份文件。
vim /etc/systemd/system/opt-sync.mount,文件名是目录+.mount

[Unit]
Description=My flashdrive script trigger
#Requires=.mount
#After=media-YourMediaLabel.mount
After=usb_modeswitch@.service
#[Service]
#ExecStart=/home/you/bin/triggerScript.sh
[Mount]
#What=UUID=ea8d7bf8-384d-412b-b9eb-b92f702fc360
What=/dev/sda2
Where=/opt/sync
#Options=nofail
Type=ext4

[Install]
WantedBy=multi-user.target

开机自动挂载systemctl enable opt-sync.mount

编辑sync的systemd配置文件,确保在挂载了usb硬盘后启动
vi /lib/systemd/system/resilio-sync.service

[Unit]
Description=Resilio Sync service
Documentation=http://help.getsync.com/
#opt-sync.mount是后增加的,确保在挂载了usb硬盘后,resilio-sync才启动
After=network.target network-online.target opt-sync.mount
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容