Ext4 (Русский)

From ArchWiki
Revision as of 17:47, 10 July 2011 by Roma-n (talk | contribs)
Jump to navigation Jump to search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Ext4 - результат эволюции файловой системы ext3. Ext4 в сравнении с ext3 сильнее улучшена, чем ext3 по сравнению с ext2. В ext3 практически просто добавили журналирование, а ext4 изменена более кардинально. В результате получилась ФС с улучшенным дизайном, производительностью, стабильностью, и расширенными возможностями.

Source: Ext4 - Linux Kernel Newbies

Создание раздела ext4 с нуля

  1. Обновите систему: Template:Codeline
  2. Отформатируйте раздел: Template:Codeline (замените Template:Codeline устройством, которое собрались форматировать (например Template:Codeline))
  3. Монтируйте раздел
  4. Добавьте пункт в Template:Filename, в качестве типа ФС укажите ext4
Tip: Прочитайте ман по mkfs.ext4 для других опций; редактируйте Template:Filename чтобы изменить/посмотреть стандартные опции.

Миграция с ext3 на ext4 без потери данных

Есть два способа:

  • монтировать ext3 как ext4 без конвертирования (совместимость)
  • конвертировать раздел ext3 в ext4 (производительность)

Оба способа описаны ниже.

Mounting ext3 Partitions as ext4 Without Converting


Компромисс между полным преобразованием в ext4 и использованием ext3 это монтирование ext3 как ext4.


  • Совместимость (ФС может быть монтирована как ext3 и ext4) – Это позволит пользователю читать ФС с дистрибьютивами/программами не поддерживающими ext4 (например Windows с драйвером для ext3)
  • Увеличенная производительность (менее производительно чем полное конвертирование) – смотри Ext4 - Linux Kernel Newbies


  • Используются не все возможности ext4
Note: Не считая относительной новизны ext4 (которую можно рассматривать как риск), однако крупных недостатков у этой техники нет.


  1. Edit Template:Filename and change the 'type' from ext3 to ext4 for any partitions you would like to mount as ext4.
  2. Re-mount the affected partitions.
  3. Done.

Converting ext3 Partitions to ext4


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



  • 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)


The following software is required on the Arch Linux system:

If converting one's /boot partition to ext4:

Note: The ext4 patch is included by default with Arch's GRUB package (at the time of writing, but this will likely not change). Otherwise, GRUB2 is required for booting from an ext4 partition.
Warning: Booting from an ext4 partition is not 'officially' supported by GRUB, and GRUB2 is still under development. While GRUB does currently work, the 'safe' option is to boot from an ext2 or ext3 /boot partition. CONSIDER YOURSELF WARNED!

If converting one's root (/) partition to ext4:

If converting one's root (/) partition to ext4, the following software is also needed on a bootable CD/USB drive:

Note: Using the latest Arch Linux release (2009.02) is recommended. Older Arch Linux images (<= 2008.06) ship with an older version of Template:Codeline, but it is a simple matter to Template:Codeline from the live environment after setting up networking. Alternatively, SystemRescueCd >= 1.1.4 contains an appropriate version, and is in itself a handy CD to have.


These instructions were adapted from http://ext4.wiki.kernel.org/index.php/Ext4_Howto and http://bbs.archlinux.org/viewtopic.php?id=61602. They have been tested and confirmed by this author as of January 16, 2009.

  • UPGRADE! Perform a sysupgrade to ensure all required packages are up-to-date: Template:Codeline
  • BACK-UP! Back-up all data on any ext3 partitions that are to be converted to ext4. Although ext4 is considered 'stable' for general use, it is still a relatively young and untested file system. Furthermore, this conversion process was only tested on a relatively simple setup; it is impossible to test each of the many possible configurations the user may be running.
  • Edit Template:Filename and change the 'type' from ext3 to ext4 for any partitions that are to be converted to ext4.
Warning: ext4 is backwards-compatible with ext3 until extents and other new fancy options are enabled. If the user has a partition that is shared with another OS that cannot yet read ext4 partitions, it is possible to mount said partition as ext4 in Arch and still be able to use it as ext3 elsewhere at this point... Not so after the next step! Note, however, that there are fewer benefits to using ext4 if the partition is not fully converted.
  • The conversion process with Template:Codeline 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, as described in the 'Prerequisites' section above.
Note: 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.
  • Reboot Arch Linux!
Warning: 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: Template:Codeline

Migrating files to extents

Warning: Do NOT use the following method with Mercurial repository that have been cloned locally, as doing so will corrupt the repository. It might also corrupt other hard link in the filesystem.

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 new extents 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. A utility called e4defrag is being developed and will take care of this task ; however, it is not yet ready for production.

Fortunately, it is possible to use the chattr program, which will cause the kernel to rewrite the file using extents. It is possible to run this command on all files and directories of one partition (e.g. if /home is on a dedicated partition): (Must be run as root)

find /home -xdev -type f -print0 | xargs -0 chattr +e
find /home -xdev -type d -print0 | xargs -0 chattr +e

It is recommended to test this command on a small number of files first, and check if everything is going all right. It may also be useful to check the filesystem after conversion.

Using the lsattr command, it is possible to check that files are now using extents. The letter 'e' should appear in the attribute list of the listed files.

Tips and tricks

Remove reserved blocks

By default 5% of a filesystem will be flagged as reserved for root user. For modern high-capacity disks, this is much higher than necessary - particularly if the partition is not being used for system files. 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)
  • Not being used for system files

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

tune2fs -m 1 /dev/sdXY


Kernel Panic

One problem this author encountered was a kernel panic after converting the root (/) partition to ext4. This is because the initial ramdisk was detecting the partition as 'ext4dev', rather than 'ext4'. It was a simple matter to boot with the 'fallback' initial ramdisk and re-create the 'default' initial ramdisk :

  • Remount the root partition in read-write mode; assuming 'XXX' is your root partition :
# mount /dev/XXX / -o remount,rw
  • Manually mount the boot partition on /boot if it is on a separate partition.
  • Re-create the ramdisk :
# mkinitcpio -p kernel26

During the creation process, Template:Codeline correctly detected and included ext4 modules in the initial ramdisk.

Data Corruption

Some early adopters of ext4 encountered data corruption after a hard reboot. Please read Ext4 data loss; explanations and workarounds for more information.

Since kernel 2.6.30, ext4 is considered "safe(r)." Several patches improved the robustness of ext4 - albeit at a slight performance cost. A new mount option (Template:Codeline) can be used to disable this behavior. For more information, please read Linux 2 6 30 - Filesystems performance improvements.

For kernel versions earlier than 2.6.30, consider adding Template:Codeline to the Template:Codeline line in GRUB's Template:Filename as a preventative measure.

Improving performance

Since kernel 2.6.30, ext4 performance has decreased due to changes that serve to improve data integrity.[1] Users can improve performance with the Template:Codeline option when mounting the disk, but this can be dangerous and may result in data loss or corruption after power failures. To turn barriers off, add the option Template:Codeline to the desired filesystem in Template:Filename. For example:

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


E4rat is a preloading application designed for ext4. It monitors files opened during boot, optimizes their placement on the partition to improve access time, and preloads them at the very begining of the boot process.