我的 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
Run Code Online (Sandbox Code Playgroud)
当我发出问题时,它在启动后安装良好,sudo mount -a并且没有其他问题。
谢谢!
djm*_*ler 29
您是否尝试将选项添加_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
Run Code Online (Sandbox Code Playgroud)
_netdev 应该将挂载延迟到网络连接之后。
小智 25
如果_netdev不起作用,请尝试使用此选项:
x-systemd.automount
Run Code Online (Sandbox Code Playgroud)
它的工作原理是在第一次访问时安装驱动器。
要测试自动挂载,请卸载当前已挂载的共享:
sudo umount /media/mybooklive
Run Code Online (Sandbox Code Playgroud)
然后重启remote-fssystemd 单元:
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target
Run Code Online (Sandbox Code Playgroud)
小智 12
我正在使用日期为 2017-09-07 的 Raspbian-Stretch 版本并遇到了同样的问题。但是,我能够通过进入 raspi-config 并在“启动选项”菜单下启用“启动时等待网络”选项来克服这个问题。
Pan*_*her 10
这是一个语法错误,我认为你需要一个“/”而不是一个“\”,就像这样
//192.168.0.26/mythtv/media /media/mybooklive cifs username=user,password=pass,_netdev,umask=002,uid=136,gid=144,iocharset=utf8 0 0
Run Code Online (Sandbox Code Playgroud)
有关其他信息,请参阅:https : //wiki.ubuntu.com/MountWindowsSharesPermanently。
_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
Run Code Online (Sandbox Code Playgroud)
完毕!它现在非常适合我!
参考: