大网数据广告活动
服务器运维问答

Quick way to restore or reload /etc/fstab settings?

· 52CE 我爱测

I'm working with a complex /etc/fstab on a RHEL 6.x-based server. The system has a variety of mount options in use across eight partitions, including several bind mounts. I'm testing options and their effect on the image I'm work…

问题原文

原帖链接 · ewwhite · CC BY-SA 3.0

I'm working with a complex /etc/fstab on a RHEL 6.x-based server. The system has a variety of mount options in use across eight partitions, including several bind mounts. I'm testing options and their effect on the image I'm working on.

e.g. options like nodev,nosuid,noexec,nobarrier and several XFS filesystem parameters are in place.

While I know it's possible to remount with specific options, is there a quick way to revert all mounts to the persistent settings hardcoded in /etc/fstab?

For instance sysctl -p loads the /etc/sysctl.conf values and applies them. Is there a mount equivalent?


Edit:

An example config:

#
# /etc/fstab
#
UUID=e6ca80cd    /                       ext4    noatime,nobarrier        1 1
UUID=a327d315    /boot                   ext4    defaults                 1 2
UUID=333ada18    /home                   ext4    noatime,nobarrier,nodev  1 2
UUID=7835718b    /tmp                    ext4    nodev,nosuid,noexec      1 2
UUID=4dd2e9d4    /usr                    ext4    defaults                 1 2
UUID=c274f65f    /var                    ext4    noatime,nobarrier        1 2
UUID=5b5941e0    /var/log                ext4    defaults                 1 2
UUID=3645951a    /var/log/audit          ext4    defaults                 1 2
UUID=3213123c    /vol1                   xfs     noatime,logbufs=8,nobarrier 1 2
UUID=1ee1c070    swap                    swap    defaults                 0 0
# Bind mount for /tmp
/tmp             /var/tmp                none    bind                     0 0
tmpfs            /dev/shm                tmpfs   nodev,nosuid,noexec      0 0
devpts           /dev/pts                devpts  gid=5,mode=620           0 0
sysfs            /sys                    sysfs   defaults                 0 0
proc             /proc                   proc    defaults                 0 0

Of course, a developer asks for execute permissions on /tmp in order to install an application...

I'm finding that the remount option does not work on this system without specifying the device and (re)mountpoint. This is a security-hardened server, so the issues I'm seeing may be SElinux-related or a result of the bind mounts, or maybe even the presence of negated options (noexec versus exec)...

已采纳解答

原帖链接 · ruief · CC BY-SA 3.0

Type this into bash:

egrep -v '^#' /etc/fstab | while read dev dir type opts dump pass ; do
    echo "mount -o remount,${opts} ${dir}";
done

On my system, this produces output like this:

mount -o remount,nodev,noexec,nosuid /proc
mount -o remount,relatime,errors=remount-ro /
mount -o remount,defaults /misc

Try it on your system. If you like it output it produces, use it, or just remove the echo and the double quotation marks from the command above.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-02-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。