/proc/mounts 和 /etc/mtab 的顺序
有谁知道 /proc/mounts 是否保证按照设备安装的顺序?
例如:
[root@machine proc]# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/sda1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/dev/root /boot ext3 rw,data=ordered 0 0
在上面的情况下,我可以确定/boot当前将显示/dev/root而不是/dev/sda1,后者当前是隐藏的。
我猜 /etc/mtab 应该有同样的答案。
我使用的是 RHEL 5.5。
Does anyone know whether /proc/mounts is guaranteed to be in the order in which devices are mounted?
For instance:
[root@machine proc]# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/sda1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/dev/root /boot ext3 rw,data=ordered 0 0
In the above case, can I be sure that /boot will currently show /dev/root rather than /dev/sda1, which is currently hidden.
I'm guessing the same answer should be true of /etc/mtab.
I'm on RHEL 5.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/proc/mounts 中的挂载点按挂载顺序排列。如果您挂载一个新的文件系统,它会被附加到文件系统列表中,从而实质上掩盖了原始挂载点。
/etc/mtab 的内容绝对没有保证,它纯粹由用户态 mount 命令管理,因此可以任意绕过或重写,另外您可以使用“-n”选项进行挂载,实际上会省略将条目放入/etc/mtab,从而使其相对于内核不正确。
作为一个愚蠢的问题,你为什么需要这些信息?
The mount points in /proc/mounts are in mounted order. If you mount a new file system it gets appended to the list of filesystems, essentially obscuring the original mount point.
There are absolutely no guarantees about the content of /etc/mtab, it is purely managed by the userland mount command, so can be bypassed or rewritten arbitrarily, plus you can use the '-n' option to mount will actually omit placing entries in the /etc/mtab, thus making it incorrect relative to the kernel.
As a silly question, why do you need this information?