
頻繁に読み取られる大規模な ext3 ファイル システムが、通常 1 日に 2 ~ 3 回、常にハード電源サイクルされるシステムに読み取り専用でマウントされています。
通常、デバイスの電源は電源を切ることによってオフになるため、fsck はそのファイル システムで起動時に実行されますが、このアプリケーションでは起動時間の高速化 (秒単位) が重要です。
fstabでファイルシステムのブート時のチェックを無効にすることはできますが、私の質問は、これを行うのは安全かどうかです。ファイルシステムが読み取り専用でマウントされているが、適切にアンマウントされることがない場合は、どれでも起動時のチェックを無効にすると、長期間にわたってファイル システムの破損が蓄積されるリスクはありますか?
答え1
マンページからmount
、
-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 or ext4 will replay its journal if the filesystem is dirty.
To prevent this kind of write access, you may want to mount ext3
or ext4 filesystem with "ro,noload" mount options or set the
block device to read-only mode, see command blockdev(8).
不十分であることが判明した場合ro,noload
、fstab エントリだけで読み取り専用デバイスを設定する方法はわかりません。ファイルシステムがマウントされる前に、他の方法でblockdev --setro
読み取り専用ループ デバイス ( losetup --read-only
) を呼び出すか作成する必要がある場合があります。
完全に読み取り専用にすると、マウントされたことすら認識されなくなります。したがって、デバイスに何も書き込まれない限り、マウント カウントの更新や強制 fsck は行われず、特に破損が発生することはありません...
答え2
マンページからtune2fs
:
-c max-mount-counts
Adjust the number of mounts after which the filesystem will be checked by e2fsck(8). If max-mount-counts is 0 or -1, the number
of times the filesystem is mounted will be disregarded by e2fsck(8) and the kernel.
Staggering the mount-counts at which filesystems are forcibly checked will avoid all filesystems being checked at one time when
using journaled filesystems.
You should strongly consider the consequences of disabling mount-count-dependent checking entirely. Bad disk drives, cables,
memory, and kernel bugs could all corrupt a filesystem without marking the filesystem dirty or in error. If you are using jour-
naling on your filesystem, your filesystem will never be marked dirty, so it will not normally be checked. A filesystem error
detected by the kernel will still force an fsck on the next reboot, but it may already be too late to prevent data loss at that
point.
See also the -i option for time-dependent checking.
そして:
-i interval-between-checks[d|m|w]
Adjust the maximal time between two filesystem checks. No postfix or d result in days, m in months, and w in weeks. A value of
zero will disable the time-dependent checking.
It is strongly recommended that either -c (mount-count-dependent) or -i (time-dependent) checking be enabled to force periodic
full e2fsck(8) checking of the filesystem. Failure to do so may lead to filesystem corruption due to bad disks, cables, memory,
or kernel bugs to go unnoticed until they cause data loss or corruption.
両方をゼロに設定すれば、自動のfsck
機能は無効になります(実は(でも、そうしたいです)。
答え3
歴史的および文脈的な理由から他の回答は残しておきますが、読み直すと、あなたの実際の質問がわかります。はい、あなたはまだ最終的にを実行しますfsck
。すべてのディスクには寿命があり、fsck
不良セクタを「不良ブロック」inode/リストに割り当てて、新しいファイルが使用できないようにします。
読み取り専用にすると (そしてnoload
frotschutz が言及しているようなことを実行すると)、サービスの中断による一貫性の問題を防ぐのに役立ちますが、それでもハードウェアが突然故障する可能性を考慮する必要があります。