- Red Hat Enterprise Linux (RHEL) 7
- Trying to set up readonly
/filesystem and have modified below parameters in
/etc/sysconfig/readonly-rootto the following:
- However when the server is rebooted, the root filesystem is mounted as rw and not ro as expected:
/dev/xvda1 on / type xfs (rw,relatime,attr2,inode64,noquota)
- To mount
/in readonly mode in RHEL 5/6 refer Is it possible to mount the root filesystem read-only (Stateless Linux)?
- For RHEL 7, follow below steps :
 Edited below file by changing the parameters as per your requirement. Minimal requirement is to edit
# cat /etc/sysconfig/readonly-root # Set to 'yes' to mount the system filesystems read-only. READONLY=yes # Set to 'yes' to mount various temporary state as either tmpfs # or on the block device labelled RW_LABEL. Implied by READONLY TEMPORARY_STATE=yes # Place to put a tmpfs for temporary scratch writable space RW_MOUNT=/var/lib/stateless/writable # Label on local filesystem which can be used for temporary scratch space RW_LABEL=stateless-rw # Options to use for temporary mount RW_OPTIONS= # Label for partition with persistent data STATE_LABEL=stateless-state # Where to mount to the persistent data STATE_MOUNT=/var/lib/stateless/state # Options to use for persistent mount STATE_OPTIONS= # NFS server to use for persistent data? CLIENTSTATE= # Use slave bind-mounts SLAVE_MOUNTS=yes
 Change fstab entry for
ro by replacing
# cat /etc/fstab | grep root /dev/mapper/rhel-root / xfs ro 0 0
 Take a backup of current initramfs (to be on safer side).
# cp /boot/initramfs-3.10.0-229.el7.x86_64.img /boot/initramfs-3.10.0-229.el7.x86_64.img.bkp
 Rebuild the initramfs for current kernel version.
# dracut -f -v
 Perform a reboot.
 Verify if
/ is mounted in
ro mode :
# cat /proc/mounts | grep root rootfs / rootfs rw 0 0 /dev/mapper/rhel-root / xfs ro,seclabel,relatime,attr2,inode64,noquota 0 0
initramfswas not re-built.
- Red Hat Enterprise Linux
- Customize or extend
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.