5.3. 手动挂载 SMB 共享

如果您只需要临时挂载 SMB 共享,您可以使用 mount 工具手动挂载它。

注意

重启系统时,手动挂载的共享不会再次自动挂载。要配置 Red Hat Enterprise Linux 在系统引导时自动挂载共享,请参阅 当系统引导时自动挂载 SMB 共享

先决条件

  • cifs-utils 软件包已安装。

流程

  • 使用带有 -t cifs 参数的 mount 工具挂载 SMB 共享:

    # mount -t cifs -o username=<user_name> //<server_name>/<share_name> /mnt/
    Password for <user_name>@//<server_name>/<share_name>:  password

    -o 参数中,您可以指定用于挂载共享的选项。详情请查看 mount.cifs(8) 手册页中的 OPTIONS 部分,以及 常用的挂载选项

    例 5.1. 使用加密的 SMB 3.0 连接挂载共享

    要以 DOMAIN\Administrator 用户的身份,将 \\server\example\ 共享通过加密的 SMB 3.0 连接挂载到 /mnt/ 目录:

    # mount -t cifs -o username=DOMAIN\Administrator,seal,vers=3.0 //server/example /mnt/
    Password for DOMAIN\Administrator@//server_name/share_name:  password

验证

  • 列出挂载的共享的内容:

    # ls -l /mnt/
    total 4
    drwxr-xr-x.  2 root root 8748 Dec  4 16:27 test.txt
    drwxr-xr-x. 17 root root 4096 Dec  4 07:43 Demo-Directory