分类
技术

使用 fstab 自动挂载 Samba

网络存储,永远的神

虽然 NFS 性能好,但抵不过 SMB 兼容性高啊——实际上是设备不支持 NFS 🥲 。

首先安装 CIFS(Common Internet File System):

sudo apt install cifs-utils

如果开启了鉴权,建议使用凭证(credentials)的方式连接;因为我心大,没设置密码,因此 guest 一把梭。

编辑 /etc/fstab 文件,添加条目:

//{IP/Name}/{Sharename}    /mnt/{FolderName}    cifs    guest,noauto,x-systemd.automount,_netdev     0    0

The _netdev option ensures systemd understands that the mount is network dependent and order it after the network is online.

因为我的设备是 DHCP 获取 IP,如果在网络起来前进行挂载操作,那么只能得到错误:

CIFS VFS: Error connecting to socket

根据介绍,加了这个 _netdev 应该能朝期望的方向发展,但经过多次测试,我的设备无效 😫,网络和挂载两者每次系统启动都预料不到谁快谁慢。到底是设备架构(ARM)问题还是其他原因,触及到知识盲区,目前不想过多探究。

最后根据万能的 Arch Linux Wiki,添加 noauto,x-systemd.automount 即可解决以上问题——按需加载。

参考链接:

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注