Mount Network Disk
文件协议类型
- The Server Message Block (SMB) Protocol is the network file sharing protocol of Microsoft Windows. The set of message packets defining a particular version of the protocol is called a dialect(方言?).
- The Common Internet File System (CIFS) is a dialect of SMB.
- Both
SMB
andCIFS
are also available onVMS
. BothSMB
andCIFS
are also available on other operating systems like Linux and Android via alternate implementations which are not officially supported by Microsoft.
- Both
- mount 通过修改
/etc/fstab
文件实现
Ubuntu 挂载网络硬盘
在Ubuntu系统上挂载SMB共享非常简单,可以通过以下步骤完成:
安装cifs-utils:
这是一个用于挂载SMB文件系统的工具包。如果你还没有安装它,可以通过以下命令安装:1
2sudo apt update
sudo apt install cifs-utils创建挂载点:
你需要一个目录作为挂载点。可以在你的主目录下创建一个目录,例如:1
mkdir /nas_share
挂载SMB共享:
使用mount.cifs
命令挂载共享。你需要提供共享的路径、挂载点,以及访问共享所需的用户名和密码。1
2
3
4# 假设id是1001:1001, 或者cat /etc/passwd来查看
id -u jellyfin
id -g jellyfin
sudo mount.cifs //192.168.31.242/共享目录 ~/nas_share -o username=你的用户名,password=你的密码,uid=1001,gid=1001注意:将
//192.168.31.242/共享目录
替换为实际的共享路径,将~/nas_share
替换为你创建的挂载点目录,将你的用户名
和你的密码
替换为实际的SMB用户名和密码。验证挂载:
挂载成功后,可以通过以下命令验证:1
df -h
你应该能看到类似于
//192.168.31.242/共享目录
的条目。自动挂载(可选):
如果你希望每次启动时自动挂载,可以编辑/etc/fstab
文件,添加以下行:1
//192.168.31.242/共享目录 /home/你的用户名/nas_share cifs username=你的用户名,password=你的密码,uid=1000,gid=1000 0 0
注意:将上述路径和用户名、密码替换为你的实际信息。
uid=1000,gid=1000
表示将挂载的文件所有权设置为当前用户(假设用户ID和组ID为1000)。
完成以上步骤后,你应该能够在Ubuntu系统上成功挂载并访问NAS的SMB共享。如果在挂载过程中遇到任何问题,请提供详细的错误信息,我可以帮助你进一步排查。
无密码情况
1 | # ip acsa-med.acsalab.com |
- 注意: 挂载的时候选择ipv6域名
synology.acsalab.com
更好, 之前ipv4反而走了WARP的wiregaurd代理导致链接不上
取消挂载
1 | sudo umount /nas_share/home |
强制卸载
如果确认可以安全地终止使用挂载点的所有进程,可以使用umount -l
(懒卸载)或umount -f
(强制卸载):
懒卸载:
1
sudo umount -l /nas_share/home
强制卸载:
1
sudo umount -f /nas_share/home
懒卸载会立即分离文件系统,但不会终止正在使用该文件系统的进程。强制卸载会尝试立即卸载文件系统,即使文件系统正在使用。
强制取消 CIFS Share 挂载
以-l
lazy的方式unmount所有-a
文件系统为-t cifs
的挂载
1 | umount -a -t cifs -l /path/to/share |