GEOM jounral の設定2009年02月19日 12時17分00秒

GEOM journal は UFS にてジャーナリングを有効にする。メタデータとユーザデータの両方を記録する型のジャーナリング機構だ。

初期化用に、geom_journal を読み込む、次回利用時のために、loader に gjounral を読み込むように設定する。


$ kldload geom_journal
$ echo 'geom_journal_load="YES"' >> /boot/loader.conf

gjournal の設定をし、newfs でファイルシステムを作る。-J を渡し、ジャーナルを有効にする。softupdate は必要ないので -U は渡さない。


$ gjournal label -s 2G /dev/da0
$ newfs -J /dev/da0.journal
/dev/da0.journal: 100352.0MB (205520892 sectors) block size 16384, fragment size 2048
        using 547 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376512, 752864, 1129216, 1505568, 1881920, 2258272, 2634624, 3010976,
 3387328, 3763680, 4140032, 4516384, 4892736, 5269088, 5645440, 6021792,
 6398144, 6774496, 7150848, 7527200, 7903552, 8279904, 8656256, 9032608,
 9408960, 9785312, 10161664, 10538016, 10914368, 11290720, 11667072, 12043424,

tunefs にて、正しく設定できているかを確認する。


$ tunefs -p /dev/md2.journal 
tunefs: ACLs: (-a)                                         disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 disabled
tunefs: gjournal: (-J)                                     enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  2048
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                                 

gjounral が有効になり、softupdates は無効になっている。tuenfs -J enable -n disable <device> でも設定できる。

/dev/da0.jounal を /etc/fstab に記述する。


# Device            Mountpoint  FStype  Options   Dump   Pass#
/dev/da0.journal    /export     ufs     rw,async  0      2

ここで重要な点は二つ。Options に async を指定する。非同期書き込みを有効にするために、gjounal を使っている。障害時の不整合の処理も gjournal が担うので問題ない。そして、Pass# には 2 を指定する。ジャーナルを行なっていても、マウントの前に検査をする必要がある。ここでは、非ジャーナル領域のように、ufs 自体の整合性を調べるのではない。ジャーナルに何も残っていないことの確認し、残っている場合にはジャーナルからの復帰を試みる。

ここで、ジャーナルを有効にしているとから fsck は必要ないと思って、0 を指定すると以下のエラーでシングルユーザモードに落ちる。


Mounting local file systems:
WARNING: R/W mount of /export denied. Filesystem is not clean - run fsck
mount: /dev/da0.journal Operation not permitted
Mounting /etc/fstab filesystems failed, startup aborted
ERROR: ABORTING BOOT (sending SIGTERM to parent)!
Feb 14 06:18:06 init: /bin/sh on /etc/rc terminated abnormally, going to single 
user mode

ジャーナルの整合性の点検を自ら無効にしたので、こういう結果になる。しかし、初めて gjournal を使った時に、起こしやすい間違いだ。