在/usr/lib/systemd/system自定义一个Service服务文件nas-mount.service。
[Unit]
Description=nas mount
After=network.target syslog.target cloud-config.target
Requires=cloud-config.target
Wants=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/nas_mount.sh
[Install]
WantedBy=multi-user.target
在/usr/local新建一个bash脚本nas_mount.sh。挂载的命令可以在阿里云NAS控制台查看到。
#!/bin/bash
#挂载命令写你自己的,可以在阿里云NAS控制台查看到
sudo mount -t nfs -o vers=4.0,noresvport XXXXXXXX-southeast-1.nas.aliyuncs.com:/ /mnt
使用chmod 777 /usr/local/nas_mount.sh开放权限
使用systemctl enable nas-mount启用开机自启即可