新建配置文件 sudo vim /lib/systemd/system/mount.nas.cifs.service
然后启用该服务 sudo systemctl enable mount.nas.cifs.service
[Unit] Description=启动挂载nas文件夹到本地 After=network-online.target firewalld.service Wants=network-online.target Requires=network-online.target [Service] Type=oneshot # 等待网络真正连接成功 ExecStartPre=/bin/sh -c 'until ping -c1 js-css.com; do sleep 1; done;' # 通过账号密码 挂载远程目录到本地 # 远程目录 //192.168.50.100/media # 本地目录 /media/pi ExecStart=mount -t cifs -o username=username,password=password,file_mode=0777,dir_mode=0777 //192.168.50.100/media /media/pi [Install] WantedBy=multi-user.target