12.2. transient-ro를 사용하여 동적 마운트 지점 생성


루트 사용자는 bootc root.transient-ro 기능을 사용하여 기본적으로 읽기 전용 인 루트 파일 시스템 상단에 일시적인 오버레이를 빌드하고 동적 최상위 마운트 지점을 생성하고 필요한 경우 파일 시스템을 읽기-쓰기 로 다시 마운트할 수 있습니다.

root.transient-ro 기능을 사용하는 경우 애플리케이션이 호스트 디렉터리에 올바르게 액세스하고 읽기 전용 파일 시스템에서 필요한 마운트 지점을 생성할 수 있도록 하려면 다음과 같은 몇 가지 고려 사항이 적용됩니다.

  • 애플리케이션은 호스트의 절대 경로와 일치하는 호스트 디렉터리를 바인딩 마운트해야 합니다.
  • macOS의 /Users 와 같은 플랫폼별 마운트 지점이 필요합니다.
  • 배포 후 애플리케이션을 시작하기 전에 동적 마운트 지점 생성.
  • 파일 시스템은 일반 프로세스에 대해 읽기 전용 으로 유지됩니다.

사전 요구 사항

  • container-tools meta-package가 설치되어 있습니다.

프로세스

  1. transient-root-example.service 서비스를 생성하여 읽기쓰기 권한이 있는 디렉터리를 생성합니다. 다음 예제에는 /etc/afs 가 있습니다.

    [Unit]
    Description=Transient Root Example - Dynamic Mount Point Creation
    After=local-fs.target
    ConditionPathExists=/etc/afs
    DefaultDependencies=no
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    MountFlags=slave
    # LIBMOUNT_FORCE_MOUNT2=always is required for mount command compatibility
    # See: https://github.com/util-linux/util-linux/issues/3171
    Environment=LIBMOUNT_FORCE_MOUNT2=always
    ExecStart=/usr/bin/bash -c "echo 'Transient root example: Detected /etc/afs, remounting root as read-write'; mount -o remount,rw /; mkdir -p /afs; echo 'Created /afs directory for AFS mount point'"
    
    [Install]
    WantedBy=multi-user.target
  2. ContainerFile에 다음 구성을 추가합니다.

    # Copy the systemd service unit that demonstrates dynamic mount point creation
    # The service will:
    # 1. Check for existence of /etc/afs (ConditionPathExists)
    # 2. Use MountFlags=slave for proper mount propagation
    # 3. Set LIBMOUNT_FORCE_MOUNT2=always for mount command compatibility
    # 4. Remount root as read-write and create /afs directory when triggered
    COPY transient-root-example.service /usr/lib/systemd/system/
    
    # Enable the service to start automatically on boot
    RUN systemctl enable transient-root-example.service
  3. 컨테이너 빌드 프로세스 중에 transient-ro 옵션을 활성화하려면 이미지 내부의 /usr/lib/ostree/prepare-root.conf 파일에 다음 구성을 생성합니다.

    RUN echo -e '[root]\ntransient=true' > /usr/lib/ostree/prepare-root.conf && \
        set -x; kver=$(cd /usr/lib/modules && echo *); dracut -vf /usr/lib/modules/$kver/initramfs.img $kver
    참고

    파일 시스템 구성을 변경할 때 initramfs 이미지를 다시 생성해야 합니다.

  4. 일시적인 루트 파일 시스템을 사용하여 bootc 이미지를 빌드합니다.

    $ podman build --cap-add SYS_ADMIN -t transient-root-ro:test .

    그러면 빌드 중 ostree 작업에 필요한 SYS_ADMIN 기능이 추가되었습니다.

검증

  1. transient-ro = true 구성 파일이 빌드된 이미지에 올바르게 설정되어 있는지 확인합니다.

    $ sudo podman run --rm transient-root-ro:test cat /usr/lib/ostree/prepare-root.conf

    다음과 유사한 출력이 표시됩니다.

    [root]
    transient-ro = true
  2. 실행 중인 시스템에서 런타임 기능을 확인합니다.

    1. 이미지를 부팅합니다.
    2. /etc/afs 테스트 디렉토리를 만듭니다.

      $ sudo mkdir -p /etc/afs
    3. 서비스를 다시 시작하여 동적 마운트 지점 생성을 트리거합니다.

      $ systemctl restart transient-root-example.service

      서비스는 root를 읽기-쓰기 로 다시 마운트하고 /afs 디렉터리를 생성합니다.

  3. systemd 서비스 없이 기능을 테스트하려면 실행 중인 시스템에서 root로 테스트 디렉토리를 생성합니다.

    $ sudo export LIBMOUNT_FORCE_MOUNT2=always
    $ sudo unshare -m -- /bin/sh -c 'mount -o remount,rw / && mkdir /transient-test'
  4. 디렉터리가 생성되었는지 확인합니다.

    $ sudo ls -d /transient-test /transient-test
  5. root 파일 시스템에 쓰기를 시도하여 다른 프로세스에 대한 읽기 전용 상태를 확인합니다.

    $ touch /another-test-file
    touch: cannot touch '/another-test-file': Read-only file system
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동