デバイスは読み取り専用でマウントされていますが、書き込みを続けることができます(CentOS 6.8)。

デバイスは読み取り専用でマウントされていますが、書き込みを続けることができます(CentOS 6.8)。

フラッシュドライブにCentOS 6.8がインストールされており、寿命が制限されている(書き込み100,000回(各セクタが失敗するまでの平均時間))、読み取り専用でマウントしたいと思います。

カーネルはroで起動すると言われています。少なくとも結果はcat /proc/cmdline「ro...」で始まります。

/etc/fstabマウントを読み取り専用に設定しました。

UUID=4addd4a7-97f6-4399-89e4-6d3728bd2979 /     ext4    defaults,noatime,ro        1 1
UUID=21a81149-6534-4313-8696-e203896d5881 /boot ext4    defaults,noatime,ro        1 2
UUID=D64B-DD9C          /boot/efi               vfat    noatime,ro,umask=0077,shortname=winnt 0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
tmpfs                   /var/log                tmpfs   defaults        0 0

実行してみると、mountの仕様に従うことがわかります。/etc/fstabそれでもファイルを変更し、新しいファイルを書き込むことができます。実行中のマウントが書き込み可能であるという追加の証拠lsof(以下に従う)この投稿)。結果によれば、ほとんど/homeに書き込むために開いているファイルがいくつかあります。 (これを/var/log達成するにはtmpfs

CentOS 6.8のバグですか?解決策はありますか?

ベストアンサー1

おそらく、マニュアルページでデバイスを読み取り専用にするには、デバイスを再マウントする必要があるというバグがあることを読んだ覚えがあります。

mount -o remount,ro ...

fstabの他の項目の後ろにマウントを追加してみてください。 fstabでは、psマウントにファイルシステムを「none」として指定できます。

修正する:

関連 man エントリが見つかりました。

   mount(8) since v2.27 allows to change the mount options by passing the relevant options along with --bind.  For example:

          mount --bind,ro foo foo

   This feature is not supported by the Linux kernel; it is implemented in userspace by an additional mount(2) remounting syscall.  This solution is not atomic.

   The alternative (classic) way to create a read-only bind mount is to use the remount operation, for example:

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

   Note that a read-only bind will create a read-only mountpoint (VFS entry), but the original filesystem superblock will  still  be  writable,  meaning  that  the  olddir  will  be
   writable, but the newdir will be read-only.

   It's impossible to change mount options recursively (for example with -o rbind,ro).

これに基づいて、fstabオプションを試すことができます。

default,rbind,ro

失敗した場合は、エントリを追加して再インストールしてください。

アップデート2(man 8マウント/ man 8マウントblockdev);

   -r, --read-only
          Mount the filesystem read-only.  A synonym is -o ro.

          Note  that,  depending  on the filesystem type, state and kernel behavior, the system may still write to the device.  For example, ext3 and ext4 will replay the journal if
          the filesystem is dirty.  To prevent this kind of write access, you may want to mount an ext3 or ext4 filesystem with the ro,noload mount options or set the  block  device
          itself to read-only mode, see the blockdev(8) command.

つまり、以下を選択できます。

ro,noload

または使用

blockdev --setro /dev/...

おすすめ記事