第 10 章 Creating root-level directories and symlinks at runtime with image mode for RHEL
As a privileged user, you can create dynamic, top-level mountpoints at runtime while the filesystem remains read-only by default by using the transient-ro option. This is useful for applications that require bind-mount host paths that might be platform-specific or dynamic.
This feature addresses the following use cases:
- Applications that require specific, absolute host paths for bind-mounts.
-
Platforms that require specific mountpoints, for example,
/users. - Requirement to create dynamic mountpoints after deployment, but before an application starts.
- A security requirement to keep the root filesystem read-only for all regular processes.
10.1. How the transient-ro=true option works 复制链接链接已复制到粘贴板!
When you enable the transient-ro=true option in the image, it changes the boot process of the system.
The following workflow describes the boot process changes:
transient-ro=truemounts theoverlayfsupper directory inread-onlymode by default.-
With this, a privileged process, such as
rootor asystemdservice, can remount the root filesystem asread-write, but only within a new, private mount namespace.
-
With this, a privileged process, such as
- Within the private namespace, the process can perform changes, such as creating new top-level directories to serve as mountpoints.
- The mountpoints persist for the current boot, but do not persist through reboots or upgrades.
-
All other regular processes on the system continue to see the original, unmodified,
read-onlyroot filesystem.
For security reasons, only privileged users (root) can create these mountpoints:
- The mountpoints are transient and do not persist across reboots.
-
The filesystem remains
read-onlyfor non-privileged processes.
Due to a limitation in util-linux, you must set the LIBMOUNT_FORCE_MOUNT2=always environment variable when performing mount operations with the transient-ro option, because this variable affects the mount namespace functionality required by transient-ro.