最近openwrt玩腻了,就把之前买的R4S刷了Armbian,然后安装了个alist,用来做简单的nas,但是挂载磁盘的时候犯了难,虽说可以使用fstab来挂载磁盘,但是由于我是外接的磁盘,就有时候我会把磁盘拔下来插Windows上来临时拷贝或者上传文件,这时候R4S就会出现无法开机的情况,因为fstab挂载磁盘失败,无法进入系统,当然也就没办法连ssh
所以就使用了systemd来执行脚本挂载,然后设置开机自启动
创建 /root/auto_sh/mount.sh
#!/bin/bash
mount -t ntfs-3g /dev/sda1 /mnt/sda1
创建 /etc/systemd/system/auto_mount.service
[Unit]
Description=Auto_mount_disk
Before=1panel.service
# 我设置了在1panel启动之前启动
[Service]
Type=forking
ExecStart=/root/auto_sh/mount.sh
[Install]
WantedBy=multi-user.target
设置文件权限
chmod +x auto_mount.service
然后设置开机自启动
systemctl enable auto_mount.service