首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >autofs的麻烦

autofs的麻烦
EN

Ask Ubuntu用户
提问于 2022-09-30 22:05:44
回答 1查看 505关注 0票数 0

我需要自动驾驶的帮助。有点复杂。

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

代码语言:javascript
复制
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

代码语言:javascript
复制
/dev/sda2   ext3    UUID=5b4b2ae5-9aaa-4559-9f41-afb313998c75

我的auto.master

代码语言:javascript
复制
#
# 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
EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2022-10-01 10:27:29

首先,automountautofs的守护进程部分,但是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 ):
代码语言:javascript
复制
fs2 -fstype=ext3 :/dev/sda2
  1. 您必须创建挂载点的根目录:sudo mkdir /data
  2. 重新启动autofs:sudo systemctl restart autofs
  3. 此时,一切都准备好了,您应该能够执行ls /data/fs2

就像"automount“这个名字所说的那样,它只能按”需要“挂载,意思是当访问时。通常,ls /data会显示一个空目录。

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

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1433199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档