동일한 장치를 읽기 전용으로 / 하위 디렉터리(/mnt/rootfs)에 R/W로 마운트합니다.

동일한 장치를 읽기 전용으로 / 하위 디렉터리(/mnt/rootfs)에 R/W로 마운트합니다.

UBIFS 장치 /dev/ubi0_1이 있습니다. 이 장치는 Linux rootfs의 루트이며 커널 부팅 시 읽기 전용으로 마운트됩니다.

그래서 /dev/ubi0_1을 /에 RO로 마운트했습니다.

나중에 다음 명령을 통해 R/W 모드로 /mnt/rootfs에 /dev/ubi0_1을 마운트하고 싶습니다.

mount -t ubifs -o rw /dev/ubi0_1 /mnt/rootfs

그러나 EBUSY는 실패했습니다.

이 명령은 다음과 같습니다.

mount -t ubifs -o ro /dev/ubi0_1 /mnt/rootfs

성공했습니다.

따라서 두 마운트 지점 모두에 동일한 권한이 있어야 하는 것 같습니다.

재설치를 시도했지만 항상 권한(RO 또는 RW)이 다른 마운트 지점 간에 자동으로 전파됩니다.

내 질문은 /를 RO로, /mnt/rootfs를 R/W로 마운트할 수 있는지 여부입니다.

답변1

재설치를 시도했지만 항상 권한(RO 또는 RW)이 다른 마운트 지점 간에 자동으로 전파됩니다.

긴 문서를 읽어보거나 man mount"읽기 전용"을 계속 검색하면 바인드 마운트를 사용할 때는 그렇지 않다는 것을 알게 될 것입니다.

단일 마운트 지점 "(VFS 항목)"("원시 파일 시스템 수퍼블록" 제외)의 상태를 변경하려면 bind포함된 옵션을 사용하여 이를 다시 마운트해야 합니다.

이것이 나에게 효과가 있었다고 보고하게 되어 기쁩니다.원래 마운트 지점이 다음을 사용하여 생성되었는지 여부에 관계없이bind.

다음 순서를 따르는 것이 좋습니다.

mount -oremount,bind,ro /
mount -oremount,rw /

mount -o bind,rw / /mnt/rootfs

# OR - this should have the same effect as the last command
mount -t ubifs -o rw /dev/ubi0_1 /mnt/rootfs

findmnt각 마운트 지점의 전체 유효 상태가 개별적으로 표시됩니다 ro.rw

답변2

아래 표시된 형식으로 저에게 효과적이었습니다(부팅 후 /는 rw이고 제가 마운트한 두 번째 마운트 지점의 디렉토리는 /layers/rootfs입니다).

mount -o remount,ro /
mount --bind / /layers/rootfs
mount -o remount,rw /layers/rootfs

사람의 인용문:

      Note that the filesystem mount options will remain the same as those  on  the  original
      mount  point, and cannot be changed by passing the -o option along with --bind/--rbind.
      The mount options can be changed by a separate remount command, for example:

             mount --bind olddir newdir
             mount -o remount,ro newdir

답변3

또 다른 대답은 여기에 있습니다 (https://unix.stackexchange.com/a/371923/20104) 나에게는 효과가 없었습니다 † 그러나 다음과 같은 아이디어를 얻었습니다.

mount -o remount,bind,ro /
mount -t ubifs -o ro /dev/ubi0_1 /mnt/rootfs
mount -o remount,rw /mnt/rootfs

† 작동하지 않습니다. "실제" rootfs가 읽기 전용이 아니라는 뜻입니다.

관련 정보