CIFS通过fstab挂载而不是在启动时安装
我在我的NAS上有一个CIFS共享,我希望在启动时安装它 – 它被我的MythTV服务器用作主要的媒体商店。 我在fstab
添加了一个条目以使其挂载,但它没有。 在查看我的系统日志之后,似乎在我的网络接口上线之前正在读取fstab
。 我可以对fstab
条目进行任何编辑吗?
用于挂载共享的fstab
条目是:
\\192.168.0.26\mythtv\media /media/mybooklive cifs username=user,password=pass,umask=002,uid=136,gid=144,iocharset=utf8 0 0
当我发出sudo mount -a
并且没有其它问题时,它在启动后安装得很好。
谢谢!
这是一个语法错误,我认为你需要一个“/”而不是一个“\”,就像这样
//192.168.0.26/mythtv/media /media/mybooklive cifs username=user,password=pass,_netdev,umask=002,uid=136,gid=144,iocharset=utf8 0 0
有关其他信息,请参阅: https : //wiki.ubuntu.com/MountWindowsSharesPermanently 。
您是否尝试将选项_netdev
添加到fstab
条目中? 您可以将其与字符串中的其他选项一起添加
//192.168.0.26/mythtv/media /media/mybooklive cifs username=user,password=pass,_netdev,umask=002,uid=136,gid=144,iocharset=utf8 0 0
_netdev
应该在网络连接之前延迟挂载。
如果_netdev不起作用,请尝试以下选项:
X-systemd.automount
代替。 它的工作原理是首次安装驱动器。
要测试自动挂载,请卸载当前挂载的共享:
$ sudo umount /media/mybooklive
然后重启remote-fs
systemd单元:
$ sudo systemctl daemon-reload $ sudo systemctl restart remote-fs.target
我正在使用2017-09-07的Raspbian-Stretch版本,并遇到了同样的问题。 但是,我能够通过进入raspi-config并在Boot Options菜单下解决这个问题,我启用了“在启动时等待网络”选项。
– 使用正斜杠(/)没有为我修复它。
– 另外,将选项_netdev
添加到我的/etc/fstab
条目并没有为我修复它。
我为修复这个问题(在我的Pi3上)所做的是修改/etc/rc.local
以睡20秒(通过调用sleep 20
)然后调用mount -a
。 这样,即使网络尚未连接,但系统首次读取fstab文件,因此挂载失败,我迫使系统在这里等待20秒(给网络时间连接)然后我强制它调用mount -a
再次将所有驱动器挂载到fstab
文件中。
这是我的/etc/rc.local
文件现在的样子:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address #GS notes: a *minimum* of sleep 10 is required for the mount below to work on the Pi 3; it failed with sleep 5, but worked with sleep 10, sleep 15, and sleep 30 sleep 20 _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" mount -a #GS: mount all drives in /etc/fstab fi exit 0
完成! 它现在对我来说很完美!
参考文献: