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
    • 最新
    • 标签
主页 / computer / 问题 / 1503224
Accepted
Tomas.R
Tomas.R
Asked: 2019-11-19 14:09:27 +0800 CST2019-11-19 14:09:27 +0800 CST 2019-11-19 14:09:27 +0800 CST

mount -a 和 mount -o remount /dir 有什么区别?

  • 772

我创建了一个新的文件系统并安装了它:

mount /dev/sda5 /dir

然后我将有关它的信息添加到 /etc/fstab 文件中,以便文件系统始终安装在引导过程中。

vim /etc/fstab

保存 /etc/fstab 文件后,我看到建议这样做:

mount -a

或者

mount -o remount /dir

这些命令之间有什么区别,在修改 /etc/fstab 文件后我应该使用哪一个?

mount fstab
  • 2 2 个回答
  • 5546 Views

2 个回答

  • Voted
  1. Best Answer
    Ljm Dullaart
    2019-11-19T14:34:47+08:002019-11-19T14:34:47+08:00

    man mount说:

       -a, --all
              Mount all filesystems (of the given types) mentioned in fstab (except for those whose line contains the noauto keyword).  The filesystems are
              mounted following their order in fstab.
    

    和

       remount
              Attempt to remount an already-mounted filesystem.  This is commonly used to change the mount flags for a filesystem,  especially  to  make  a
              readonly filesystem writable.  It does not change device or mount point.
    
              The  remount  functionality follows the standard way the mount command works with options from fstab.  This means that the mount command only
              doesn't read fstab (or mtab) when both the device and dir are specified.
    
              mount -o remount,rw /dev/foo /dir
    
              After this call all old mount options are replaced and arbitrary stuff from fstab (or mtab) is ignored, except  the  loop=  option  which  is
              internally generated and maintained by the mount command.
    
              mount -o remount,rw  /dir
    
              After  this call mount reads fstab and merges these options with the options from the command line (-o). If no mountpoint found in fstab than
              remount with unspecified source is allowed.
    

    所以,这就是区别。

    现在修改后应该使用什么/etc/fstab?嗯,这取决于。如果您有许多未挂载的文件系统/etc/fstab,mount -a则将它们全部挂载。这可能不是您想要的,但也可能正是您想要的。

    如果/dir尚未挂载,您可以简单地mount /dir,这将/etc/fstab单独提及其余文件系统。

    • 2
  2. Haroldo Payares Salgado
    2019-11-19T14:50:11+08:002019-11-19T14:50:11+08:00

    取自 MAN 页面:

    在 Unix 系统中可访问的所有文件都排列在一棵大树中,即文件层次结构,以 / 为根。这些文件可以分布在多个设备上。mount 命令用于将在某个设备上找到的文件系统附加到大文件树。相反,umount 命令将再次分离它。

    moun-a(通常在引导脚本中给出)导致 fstab 中提到的所有文件系统(具有正确的类型和/或具有或不具有适当的选项)按照指示安装,除了那些行包含 noauto 关键字的文件系统。添加 -F 选项将进行挂载分叉,以便同时挂载文件系统。在挂载 fstab 或 mtab 中提到的文件系统时,只提供设备或只提供挂载点就足够了。

    在mount -o remount /dir的情况下,调用 mount 所使用的全部挂载选项是通过首先从 fstab 表中提取文件系统的挂载选项,然后应用 -o 参数指定的任何选项来确定的,最后应用 -r 或 -w 选项(如果存在)。其中一些选项仅在出现在 /etc/fstab 文件中时才有用,其中一些选项可以在系统内核中默认启用或禁用。要检查当前设置,请参阅 /proc/mounts 中的选项。

    remount选项尝试重新挂载一个已经挂载的文件系统。这通常用于更改文件系统的挂载标志,尤其是使只读文件系统可写。它不会更改设备或安装点。

    重新挂载功能遵循 mount 命令如何与 fstab 中的选项一起使用的标准方式。这意味着只有在完全指定了设备和目录时,mount 命令才读取 fstab(或 mtab)。

    因此,根据 MA​​N 页面,它们之间的区别在于读取 fstab 文件,修改后,如果要全部挂载,则应使用mount -a否则,如果您只想挂载目录,则应使用其他选项。

    • 2

相关问题

  • 不支持“用户”CIFS 安装 - fedora 30

  • NFS Mount 手动工作,但 fstab 条目失败

  • 如何在 Linux 中将文件挂载为 HFS+ 文件系统?

  • 为什么在使用 fstab 时不推荐 /dev/sdxy?

  • 如何在没有 sudo (root) 的情况下以非 root 用户身份挂载 ramdisk 系统

Sidebar

Stats

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

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve