通过终端,我使用mount
命令找到要重新挂载为只读的磁盘分区。我正在处理的具体分区是/dev/sdb2
。
我尝试使用此命令将磁盘重新安装为只读,期望磁盘重新安装为只读:
mount -o remount,r /dev/sdb2
没有错误输出。
但是当我进入磁盘时,我可以在磁盘上创建文件,提示磁盘未以只读方式挂载。为什么会这样?
答案1
-o
在或 Mount Options的上下文中,r
不等同于“只读”;事实上,它甚至不存在。您需要改用ro
- 完整命令如下:mount -o remount,ro /dev/sdb2
唯一r
作为选项存在的地方mount
是作为参数,而不是安装选项。
我从 上的手册页中mount
摘取了一些信息部分供您参考。#
前面的注释是我自己写的,并非来自手册页。
# 'mount' command arguments (NOT mount options, which are passed via `-o`!)
-r, --read-only
Mount the filesystem read-only. A synonym is -o ro.
-o, --options opts
Options are specified with a -o flag followed by a comma sepa‐
rated string of options. For example:
mount LABEL=mydisk -o noatime,nouser
# FILESYSTEM INDEPENDENT MOUNT OPTIONS
remount
Attempt to remount an already-mounted filesystem. This is com‐
monly used to change the mount flags for a filesystem, espe‐
cially to make a readonly filesystem writable. It does not
change device or mount point.
The remount functionality follows the standard way how the mount
command works with options from fstab. It means the mount com‐
mand doesn't read fstab (or mtab) only when a device and dir are
fully specified.
mount -o remount,rw /dev/foo /dir
After this call all old mount options are replaced and arbitrary
stuff from fstab 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 (or mtab) and merges these
options with options from command line ( -o ).
ro Mount the filesystem read-only.
rw Mount the filesystem read-write.