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 / 问题 / 1433199
Accepted
fixit7
fixit7
Asked: 2022-10-01 14:05:44 +0800 CST2022-10-01 14:05:44 +0800 CST 2022-10-01 14:05:44 +0800 CST

autofs 的问题

  • 772

我需要有关 autofs 的帮助。这有点复杂。

我被困在这一点上。我没有 /data 目录。

The/data directory and the subdirectories fs1/, fs2/, and fs3/ should be automatically created, as you can see in the screenshot below.
$ ls /data

https://imgur.com/a/8mvbROE

https://linuxhint.com/mount-filesystems-automatically-on-demand-using-autofs/

这是我的 auto.sda2

/dev/sda2   ext3    UUID=5b4b2ae5-9aaa-4559-9f41-afb313998c75

我的汽车大师

#
# 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
/etc/auto.sda2
ubuntu-mate
  • 1 1 个回答
  • 25 Views

1 个回答

  • Voted
  1. Best Answer
    Marco
    2022-10-02T02:27:29+08:002022-10-02T02:27:29+08:00

    首先,automount它是 daemon 的一部分autofs,但systemd在他的上下文中也使用了名称 automount(请参阅 参考资料man systemd.automount)。

    其次,我假设您使用的 Ubuntu 版本仍受支持(例如 20.04、22.04、...)。

    据我了解,您想自动挂载/dev/sda2为/data/fs2.

    您需要安装软件包autofs( sudo apt-get install autofs)。有了它有一些示例文件/etc,您可以在其中看到它是如何工作的。

    在您的情况下,涉及多个文件。

    1. /etc/auto.master(请参阅man auto.master完整的语法和选项)您已经添加了/etc/auto.sda2不正确的行。从文件中的示例可以看出,挂载点丢失。正确的是/data /etc/auto.sda2,但我宁愿命名它auto.data。但让我们坚持auto.sda2
    2. /etc/auto.sda2 这行需要在里面(请参阅man 5 autofs完整的语法和选项):
    fs2 -fstype=ext3 :/dev/sda2
    
    1. 您必须创建挂载点的根目录:sudo mkdir /data
    2. 重新启动 autofs:sudo systemctl restart autofs
    3. 至此,一切准备就绪,您应该可以做ls /data/fs2

    正如名称“自动挂载”所说,它仅在“按需”时挂载,即在访问时挂载。通常ls /data会显示一个空目录。

    在文件中/etc/autofs.conf(请参阅man 5 autofs.conf完整的语法和选项),您可以更改多个选项。一个被命名browse_mode,默认设置为no。在现有/etc/autofs.conf文件中搜索它,取消注释并将其设置为yes( browse_mode = yes)。重新启动 autofs(见上文)。现在您将始终看到 中的目录/data,即使它们尚未安装。

    • 1

相关问题

  • 在 Ubuntu Mate 下使用鼠标中键关闭窗口

  • 为什么高级 MATE 菜单没有教育功能?

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