AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 884389
Accepted
Matthieu Kints van
Matthieu Kints van
Asked: 2017-02-18 05:56:19 +0800 CST2017-02-18 05:56:19 +0800 CST 2017-02-18 05:56:19 +0800 CST

通过 autonfs 自动挂载 NFS

  • 772

上周我一直在努力为我的网络添加一个(asustor)nas,终于到了可以通过 ubuntu 中的 nfs 和运行 rune-audio 的树莓派挂载文件夹的地步。

我将它们安装在 root/nfs/"folder" 中并将其添加到 nautilus 侧边栏。现在我想在启动时自动安装这些并通读:
https ://help.ubuntu.com/community/Autofs以及
如何设置 Automount/Autofs

我已经安装了autofs。

但是当我手动将其挂载到 auto.master 的规则时,我似乎不明白如何在终端中转换分配:

使用的手动挂载规则:sudo mount 192.168.0.200:/volume1/Public /nfs/Public

对此“转换”的帮助将不胜感激。

那就是我假设将该规则添加到标准 auto.master 就足够了,还是我应该使用间接规则?合并 auto.nfs?

非常感谢任何帮助。

添加:

由于steeldriver的帮助,我确实安装了文件夹。
但我忘了提到除了上面提到的规则:
sudo mount 192.168.0.200:/volume1/Public /nfs/Public.

我还需要安装:

须藤挂载 192.168.0.200:/share/USB1 /nfs/Music。

我认为这与实现类似,但是当它尝试以下操作时:
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/volume1/Public
* -fstype=nfs ,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/share/USB1

但这只给了我一个包含公共内容的音乐文件夹,而不是 USB1 内容。我在这里做错了什么?

automount
  • 2 2 个回答
  • 26247 Views

2 个回答

  • Voted
  1. Izzno
    2017-02-18T07:13:17+08:002017-02-18T07:13:17+08:00

    要挂载 NFS 共享,我们需要安装 nfs-common:

    sudo apt-get install nfs-common
    

    为了避免我们在每次重新启动后重新键入它,我们将以下行添加到 /etc/fstab:

    <nfs-server-IP>:/   /mnt   nfs    auto  0  0
    

    如果挂载后,/proc/mounts 中的条目显示为 ://(带有两个斜杠),那么您可能需要在 /etc/fstab 中指定两个斜杠,否则 umount 可能会抱怨找不到挂载。

    auto 选项在启动时挂载。但是,如果您的客户端使用在用户级别(登录后)管理的 wifi 连接,这将不起作用,因为网络在启动时不可用。在 Ubuntu 12.04 LTS 及更高版本中,wifi 连接默认在系统级别进行管理,因此在启动时自动挂载 NFS 共享应该可以正常工作

    来源:https ://help.ubuntu.com/community/SettingUpNFSHowTo

    使用 WIFI 最好使用 Autofs:

    我们首先安装 AutoFS:

    sudo apt install autofs
    

    我们编辑 /etc/auto.master:

    sudo nano /etc/auto.master
    

    内容:

    #
    # Sample auto.master file
    # This is a 'master' automounter map and it has the following format:
    # mount-point [map-type[,format]:]map [options]
    # For details of the format look at auto.master(5).
    #
    #/misc  /etc/auto.misc
    #
    # NOTE: mounts done from a hosts map will be mounted with the
    #       "nosuid" and "nodev" options unless the "suid" and "dev"
    #       options are explicitly given.
    #
    #/net   -hosts
    #
    # Include /etc/auto.master.d/*.autofs
    # The included files must conform to the format of this file.
    #
    #+dir:/etc/auto.master.d
    #
    # Include central master map if it can be found using
    # nsswitch sources.
    #
    # Note that if there are entries for /net or /misc (as
    # above) in the included master map any keys that are the
    # same will not be seen as the first read key seen takes
    # precedence.
    #
    #+auto.master
    
    /media/nfs /etc/auto.nfs --ghost
    

    注释掉 (#) "+auto.master" 和 "+dir:/etc/auto.master.d" 并在底部添加行。我花了 2 个小时试图让它工作,但不知何故,如果不添加 --ghost 选项它就无法工作。如果有人知道为什么,请发表评论。现在 /media/nfs 是包含您的 NFS 共享的目录(您不必创建它,autofs 会为您创建)并且 /etc/auto.nfs 是您的共享的配置文件。我们现在将这样做:

    sudo nano /etc/auto.nfs
    

    插入共享:

    Backup      10.0.1.100:/Backup
    Multimedia  10.0.1.100:/Multimedia
    

    现在备份目录10.0.1.100:/Backup将采用 /media/nfs。

    重新启动 autofs:

    sudo systemctl restart autofs
    

    就是这样,享受你的分享。

    • 10
  2. Best Answer
    steeldriver
    2017-02-18T10:08:26+08:002017-02-18T10:08:26+08:00

    自从我这样做以来已经有一段时间了,但是据我记得通常的配置是,它只auto.master包含挂载的位置,以及特定于协议的映射文件的名称,例如

    在/etc/auto.master:

    # configure nfs automount (for ad-hoc connection to local NAS) 
    /nfs   /etc/auto.nfs
    

    地图文件/etc/auto.nfs将类似于:

    # configure nfs automount (for ad hoc connection to local NAS)
    * -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp 192.168.0.200:/Volume1/Public
    

    如果您使用的是 Ubuntu 16.04 或更高版本,systemd重新加载autofs地图的方式似乎是

    sudo systemctl reload autofs.service
    

    或(如果这还不够)

    sudo systemctl restart autofs.service
    

    之后,NAS 卷应按需安装,例如

    ls /nfs/Public
    

    请注意,如果您的数字 UID 在 NAS 和本地系统上不同,您可能需要在系统之间设置用户映射。

    • 3

相关问题

  • 如何在 Ubuntu Server 10.04 中关闭自动挂载

  • 如何禁用提示为我的数字音频播放器的存储卡运行程序?

  • 无法在自动安装的 Windows 驱动器上创建新目录/文件

  • 我们如何在不弹出磁盘的情况下使用具有多个帐户的已安装 DVD?

  • 在 ubuntu 服务器上使用 gvfs 或其他自动挂载程序?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve