Ext4

提供: ArchWiki
2015年1月6日 (火) 20:54時点におけるKusakata (トーク | 投稿記録)による版 (ページの作成:「Category:ファイルシステム cs:Ext4 de:Ext4 en:Ext4 es:Ext4 fr:Ext4 it:Ext4 ru:Ext4 tr:Ext4 zh-CN:Ext4 {{Related articles st...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

テンプレート:Related articles start (日本語)

  • ファイルシステム
  • Ext3
  • Ext4 は Linux で一番よく使われているファイルシステム、Ext3 の発展版です。多くの点で、Ext3 から Ext4 になって Ext2 から Ext3 に進んだときよりも大きな改善がされています。Ext3 では Ext2 にジャーナリングを追加したのがほとんどでしたが、Ext4 ではファイルデータを保存するファイルシステムの重要なデータ構造にメスが入っています。その結果、改良された設計、優れたパフォーマンス、信頼性、機能性を備えたファイルシステムが誕生しました。

    ソース: Ext4 - Linux Kernel Newbies

    新しく ext4 ファイルシステムを作成

    パーティションをフォーマットするには次を実行:

    # mkfs.ext4 /dev/partition
    
    ヒント: オプションについては mkfs.ext4 の man ページを見て下さい。/etc/mke2fs.conf を編集すればデフォルトのオプションを見たり設定できます。

    デフォルトでは、mkfs.ext4 はやや低めの比率の bytes-per-inode を使って、作成される inode の定量を計算します。容量が 750GB 以上のパーティションではこれだと inode 番号が大きくなりすぎて、ディスク容量の無駄になります。比率は -i オプションで直接設定することができます。1/6291456 なら 2TB のパーティションで 476928 の inode になります。

    ext3 から ext4 に移行

    ext3 パーティションを変換せずに ext4 としてマウント

    理由

    A compromise between fully converting to ext4 and simply remaining with ext3 is to mount existing ext3 partitions as ext4.

    Pros:

    • Compatibility (the filesystem can continue to be mounted as ext3) – This allows users to still read the filesystem from other operating systems without ext4 support (e.g. Windows with ext3 drivers)
    • Improved performance (though not as much as a fully-converted ext4 partition) – See Ext4 - Linux Kernel Newbies for details

    Cons:

    • Fewer features of ext4 are used (only those that do not change the disk format such as multiblock allocation and delayed allocation)
    ノート: Except for the relative novelty of ext4 (which can be seen as a risk), there is no major drawback to this technique.

    方法

    1. Edit /etc/fstab and change the 'type' from ext3 to ext4 for any partitions you would like to mount as ext4.
    2. Re-mount the affected partitions.

    ext3 パーティションを ext4 に変換

    理由

    To experience the benefits of ext4, an irreversible conversion process must be completed.

    Pros:

    Cons:

    • Read-only access from Windows can be provided by Ext2Explore, but there is currently no driver for writing data.
    • Irreversible (ext4 partitions cannot be 'downgraded' to ext3)

    方法

    These instructions were adapted from http://ext4.wiki.kernel.org/index.php/Ext4_Howto and https://bbs.archlinux.org/viewtopic.php?id=61602.

    警告: ext4 is backwards-compatible with ext3 until extent and other unique options are enabled. Note, however, that there are fewer benefits to using ext4 if the partition is not fully converted.
    1. BACK-UP! Back-up all data on any ext3 partitions that are to be converted to ext4. A useful package for this, especially for / (root) partitions, is Clonezilla.
    2. Edit /etc/fstab and change the 'type' from ext3 to ext4 for any partitions that are to be converted to ext4.
    3. Boot the live medium (if necessary). The conversion process with e2fsprogs must be done when the drive is not mounted. If converting one's root (/) partition, the simplest way to achieve this is to boot from some other live medium.
    4. Ensure the partition is NOT mounted
    5. Run tune2fs -O extent,uninit_bg,dir_index /dev/the_partition (where /dev/sdxX is replaced by the path to the desired partition, such as /dev/sda1)
    6. Run fsck -f /dev/sdxX
    7. Recommended: mount the partition and run e4defrag -c -v /dev/sdxX.
    8. Reboot Arch Linux!
    ノート: The user MUST fsck the filesystem, or it will be unreadable! This fsck run is needed to return the filesystem to a consistent state. It WILL find checksum errors in the group descriptors -- this is expected. The '-f' parameter asks fsck to force checking even if the file system seems clean. The '-p' parameter asks fsck to 'automatically repair' (otherwise, the user will be asked for input for each error). You may need to run fsck -f rather than fsck -fp.
    ノート: Even though the filesystem is now converted to ext4, all files that have been written before the conversion do not yet take advantage of the extent option of ext4, which will improve large file performance and reduce fragmentation and filesystem check time. In order to fully take advantage of ext4, all files would have to be rewritten on disk. Use e4defrag to take care of this problem.
    警告: If the user converted their root (/) partition, a kernel panic may be encountered when attempting to boot. If this happens, simply reboot using the 'fallback' initial ramdisk and re-create the 'default' initial ramdisk: mkinitcpio -p linux

    Tips and tricks

    予約ブロックの削除

    By default 5% of a filesystem will be flagged as reserved for root user to avoid fragmentation. For modern high-capacity disks, this is higher than necessary if the partition is used as long-term archive (see this email for more info). It is generally safe to reduce the percentage of reserved blocks to free up disk space when the partition is either

    • Very large (for example >50 G)
    • Used as long-term archive, i.e., where files will not be deleted and created very often

    Use the tune2fs utility to do this. The command below would set the percentage of reserved blocks on the partition /dev/sdXY to 1.0%:

    tune2fs -m 1.0 /dev/sdXY
    

    If you need to find your drive's device name, issue the following command:

    df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
    

    E4rat

    E4rat is a preload application designed for the ext4 filesystem. It monitors files opened during boot, optimizes their placement on the partition to improve access time, and preloads them at the very beginning of the boot process. E4rat does not offer improvements with SSDs, whose access time is negligible compared to hard disks.

    トラブルシューティング

    バリアとパフォーマンス

    カーネル 2.6.30 から、データの整合性を確保するのに役立つ変更によって ext4 のパフォーマンスは落ちています [1]

    Most file systems (XFS, ext3, ext4, reiserfs) send write barriers to disk after fsync or during transaction commits. Write barriers enforce proper ordering of writes, making volatile disk write caches safe to use (at some performance penalty). If your disks are battery-backed in one way or another, disabling barriers may safely improve performance.

    Sending write barriers can be disabled using the barrier=0 mount option (for ext3, ext4, and reiserfs), or using the nobarrier mount option (for XFS) [2].

    警告: Disabling barriers when disks cannot guarantee caches are properly written in case of power failure can lead to severe file system corruption and data loss.

    To turn barriers off add the option barrier=0 to the desired filesystem in /etc/fstab. For example:

    # /dev/sda5    /    ext4    noatime,barrier=0    0    1