Ext3

提供: ArchWiki
2015年10月19日 (月) 19:35時点におけるKusakata (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

関連記事

Third Extended ("ext3") ファイルシステムには長所がたくさんあります。ext3 のカーネル内のコードやユーザー空間のツールは他の Linux 対応のファイルシステムよりも多く使われ、テストされ、修正が施され、改善が加えられています。ext3 はシンプルかつ強固でありながら、拡張性もあります。この記事ではファイルシステムのパフォーマンスと信頼性の両方を良くするためのヒントを説明しています。

このドキュメントでは一般的なパーティションを /dev/hdXY と表記します。あなたの使用している実際のデバイスノードに適宜置き換えてください。例えば、スレーブディスクの一番目のパーティションなら /dev/hdb1、一番目の SCSI または Serial ATA ディスクの二番目のパーティションなら /dev/sda2 になります。

tune2fs と e2fsck を使う

まず最初に、tune2fs ユーティリティを使って ext2 や ext3 パーティションのファイルシステムオプションを変更できる (もしくは ext2 を ext3 に変換する) ことを確認する必要があります。tune2fsman ページを見て下さい。

ファイルシステムに変更を加えた後は e2fsck ユーティリティを使ってファイルシステムのチェックを実行すると良いでしょう。ファイルシステムが問題ないか確認して、必要であれば修正を行います。まだ使ったことがないのであれば e2fsck ユーティリティの man ページを読んで下さい。

警告: 実行するときはファイルシステムをアンマウントする必要があります。tune2fse2fsck ユーティリティを使って変更を加える前に必ずファイルシステムがアンマウントされていることを確認してください。マウント中のファイルシステムを弄った場合、ファイルシステムが破損する可能性があります。必要であれば Parted Magic や Arch Linux のインストールメディアなどの LiveCD から起動するようにしてください。

ディレクトリインデックスを使う

この機能は、ハッシュ化されたバイナリツリーを使ってディレクトリの情報を保存することで、巨大なディレクトリや、多数のファイルを含んでいるディレクトリでのファイルアクセスを高速化します。完全に安全に使うことができ、ほとんとの場合で、劇的にアクセス速度が向上します。したがって有効化すると良いでしょう:

# tune2fs -O dir_index /dev/hdXY

ディレクトリインデックスは tune2fs を実行した後に、ファイルシステムに作成されたディレクトリにだけ影響を与えます。既存のディレクトリに適用したいときは、e2fsck ユーティリティを使ってファイルシステム上のディレクトリを最適化して再インデックスする必要があります:

# e2fsck -D -f /dev/hdXY
ノート:
  • 上記のコマンドは ext2, ext3, ext4 ファイルシステムで使うことができます。ファイルシステムのサイズによって、長い時間がかかることもあります。
  • Arch Linux では /etc/mke2fs.conf によってディレクトリインデックスはデフォルトで有効になっています。

フルジャーナリングの有効化

警告: 遅延アロケーションとフルジャーナリング (例: journal=data) の両方を有効にしている場合、ext4 パーティションがマウントされません。

デフォルトでは、ext3 パーティションは 'ordered' データモードでマウントされます。このモードでは、全てのデータはメインのファイルシステムに書き込まれ、メタデータがジャーナルに送られます。ジャーナルのブロックは論理的にトランザクションにグループ化されディスク I/O を削減します。大抵の場合、これで問題は発生しませんが、(特定の状況下で) 信頼性とパフォーマンスの両方を向上させる方法があります: ファイルデータそのものを含む、全てのデータをジャーナリングさせるのです (別名 'journal' データモード)。通常、全てのデータをジャーナリングするのはパフォーマンスが落ちるように思われます。データがディスクに二回書き込まれることになるからです: 一度はジャーナルに、そしてメインのファイルシステムに。しかしながら、そうではない場合があります。読み書きを同時にたくさん行うようなファイルシステムではパフォーマンスが改善された例があります。詳しくは Daniel Robbins によって IBM のウェブサイトに書かれた この記事 を読んで下さい。

journal データモードを有効化する方法は2つあります。1つは /etc/fstab でマウントオプションとして data=journal を追加する方法です。この方法を使う場合、root ファイルシステムで journal データモードを使うときはブートローダーの設定で rootflags=data=journal をカーネルパラメータとして設定する必要があります。二番目の方法は、tune2fs を使ってファイルシステムのスーパーブロックのデフォルトマウントオプションを変更します:

# tune2fs -O has_journal -o journal_data /dev/hdXY

古いカーネルでは二番目の方法は使えないことがあるので注意してください。特に Linux 2.4.20 以下ではスーパーブロックのデフォルトマウントオプションが無視されます。さらに大胆に、ジャーナルのサイズを変更することもできます。ジャーナルを大きくすればパフォーマンスが良くなる可能性があります (そのかわりディスクの消費量は増えてリカバリにかかる時間は長くなります)。以下を実行する前に tune2fs マニュアルをよく読むようにしてください:

# tune2fs -J size=$SIZE /dev/hdXY

長ったらしいブート時のチェックを無効化

警告: チェックを無効化するのは ext3/4 などのジャーナリングファイルシステムだけにしてください。ReiserFS や XFS などの他のジャーナリングファイルシステムでも無効化できたりできなかったりしますが、テストはされていません。チェックを無効化するとファイルシステムに損害を与えたり破損してしまう可能性があります。自己責任で設定してください。

It seems that our ext3 filesystems are still being checked every 30 mounts or so. This is a good default for many because it helps prevent filesystem corruption when you have hardware issues, such as bad IDE/SATA/SCSI cabling, power supply failures, etc. One of the driving forces for creating journaling filesystems was that the filesystem could easily be returned to a consistent state by recovering and replaying the needed journaled transactions. Therefore, we can safely disable these mount-count- and time-dependent checks if we are certain the filesystem will be quickly checked to recover the journal if needed to restore filesystem and data consistency. Before you do this please make sure your filesystem entry in /etc/fstab has a positive integer in its 6th field (pass) so that it is checked at boot time automatically. You may do so using the following command:

# tune2fs -c 0 -i 0 /dev/hdXY

If you just want to limit the checks to happen less often without totally disabling them (for peace of mind). A great method is to change from a number of count's check to a time frame check. See the man page. Here is once every month:

# tune2fs -c 0 -i 1m /dev/hdXY

予約済みのファイルシステム領域を回収する

Ext3 partition contain a used space of 5% for special reasons by default. The main reason is to help with less fragmentation on the filesystem. The other reason for such space is so root can log in even when the filesystem becomes 100% used. Without this option, the root user might not be able to log in to "clean up" because the system could become unstable, trying to write logs to a 100% full system for example.

The issue with this is that hard drives are getting so big the 5% can add up to be quite a large amount of wasted space. (eg. 100 GB = 5 GB reserved). Now if you separate your filesystems to like /home for example it might be a good idea to adjust these and reclaim that wasted space on long-term archive partitions (see this email for more info). It's a safe bet to leave your / filesystem at 5% reserved just in case. Leave reserved space for filesystems containing /var and /tmp also or else you'll end up with problems.

Now to change your reserved space to 1% of the drive, which is fair for non-root filesystems.

# tune2fs -m 1 /dev/sdXY

ラベルを割り当てる

Once you have created and formated a partition, you can assign it a label using the e2label command. This allows you to add the partition to /etc/fstab using a label instead of using a device path (usefull for an USB drive). To add a label to a partition, type the following command as root:

# e2label /dev/sdXY new-label

If the optional argument new-label is not present, e2label will simply display the current filesystem label. If the optional argument new-label is present, then e2label will set the filesystem label to be new-labelq. Ext2 and ext3 filesystem labels can be at most 16 characters long; if new-label is longer than 16 characters, e2label will truncate it and print a warning message.

ユーザーエクスペリエンス

I never had problems with these tips on large (>750) filesystems. Disabling lengthy boot-time works fine as well.

I get filesystem errors even with this tips. Do not disable lengthy boot time checks.

If you have some big partitions, do not enable full journaling on them. I experienced reproducible freezes (about 30 seconds) when enabling this on my 250GB home partition.

Did you try tweaking bdflush as described by Daniel Robbins?