Linuxで次回起動時にfsckを強制または抑止する方法について

タグ: linux / 公開: 2014-02-06

Linuxで次回起動時にfsckを強制したい場合は、ルートファイルシステムにforcefsckファイルを作ってやれば良い。 この操作はtouchコマンドを使って、以下のようにファイルを作ることで行うよう紹介されることが多い。

touch /forcefsck

このことは経験的に知っていたのだが、/forcefsckをブートプロセスがチェックし、fsckを実行することはどこに明文化されているのかがふと気になった。

少なくともfsckのmanページには書かれていない。 調べてみるとshutdownコマンドのmanには、/forcefsckファイルに関して、以下の記述があることがわかった。 引用する。

The -F flag means ‘force fsck’. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special ‘force’ flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.

これによるとshutdown -Fすると/forcefsckを作る、次回起動時にブートプロセスがこれをチェックし、fsckが実行されることを期待しているようにみえる。

これを読むと、実は/forcefsckファイルはユーザがおいそれとtouchするものではなく、本来はshutdownコマンドに作らせるものなのではないか、という気がしてくる。

ちなみに、shutdownコマンドのmanにはもう1つ興味深い事が書かれている。 それがshutdown -fオプションである。

The -f flag means ‘reboot fast’. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.

これはshutdown -Fと対を成すオプションだ。 これによるとルートファイルシステムにfastbootファイルを作ってやれば、次回起動時のfsckを抑止できるようだ。 試したことはないが、いつか使ってみたいものだ。

fsckをめぐる冒険はひとまずこれで終わり。

この記事をSNSでシェアする
タイトルとURLをコピーする
または投稿画面を開く
Author
Icon
ぺけみさお / xmisao
プログラマ。
Subscription
Recent articles
Related to linux