Ext4 (简体中文)
From ArchWiki
i18n |
---|
Česky |
English |
Türkçe |
简体中文 |
Contents |
介绍
Ext4是Linux上Ext3文件系统的进化。在很多方面,Ext4对于Ext3有着比Ext3对于Ext2更多更深的改变。Ext3主要是针对Ext2添加了日志系统,而Ext4修改了重要的文件系统的数据结构,比如用来存储文件数据的那部分。当然结果就是文件系统有更好的设计,更好的性能,稳定性还有更多的功能。
来源: Ext4 - Linux Kernel Newbies
删除一个分区并创建ext4分区
- 升级你的系统: pacman -Syu
- 格式化分区: mkfs.ext4 /dev/sdxY (查看mkfs.ext4 man帮助获得更多选项)
- 挂载这个分区
- 添加相关条目到fstab /etc/fstab, 并且修改文件系统类型'type'为 ext4
从Ext3迁移到Ext4
有两种方法迁移分区从Ext3到Ext4:
- 不转换直接把ext3分区挂载成ext4分区格式 (兼容模式)
- 转换ext3分区到ext4格式 (性能模式?)
这两种方法下面详细介绍。
不转换直接把ext3分区挂载成ext4分区格式
基本原理
转换到ext4和继续使用ext3格式的折衷的办法就是把ext3分区当作ext4分区来挂载。
Pros:
- Compatibility (the filesystem can continue to be mounted as ext3) – This allows users to still read the filesystem from other distributions/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)
步骤
- 修改 /etc/fstab,把你想要挂载成ext4的现有ext3分区的'type'栏的内容从 ext3改为ext4。
- 重新挂载使修改成效。
- 完成!
转换ext3分区到ext4格式
基本原理
为了能够使用ext4的全部特性,必须完成一个不可逆转的转换过程。
Pros:
- Improved performance and awesome new features – See Ext4 - Linux Kernel Newbies for details
Cons:
- Cannot be read/written with ext3 drivers (note that there is no known ext4 driver for Windows)
- Irreversible (ext4 partitions cannot be 'downgraded' to ext3)
必要条件
在 Arch Linux 下需要如下软件:
- kernel26 >= 2.6.28
- e2fsprogs >= 1.41
如果需要/boot分区也转换成ext4,还要求:
- grub >= 0.97 (包含ext4补丁)
如果需要转换主分区(/)到ext4还需要:
- mkinitcpio >= 0.5.20
如果需要转换主分区(/)到ext4,还需要一个带有如下软件的可引导的CD或者USB设备:
- e2fsprogs >= 1.41
步骤
这些说明是从http://ext4.wiki.kernel.org/index.php/Ext4_Howto 还有 http://bbs.archlinux.org/viewtopic.php?id=61602截取下来的。已经在2009年1月16日被作者测试过和确认过了。
- 升级! 进行一次整个系统的升级,来保证系统软件符合要求: pacman -Syu
- 备份! 备份准备转换到ext4的ext3分区上所有的数据。尽管ext4被认为日常使用非常稳定,但是仍然是一个年轻的没有经过充分测试的文件系统。何况,这个转换过程只是经过相对简单的测试,因为不可能测试所有各种各样用户可能用到的环境配置。
- 修改 /etc/fstab 的'type'栏,把需要转换的所有分区的ext3改为ext4。
- 使用e2fsprogs的转换过程必须在分区没有被挂载前提下进行。如果转换主分区,最简单的方法就是启动到其他live环境(其他支持ext4的环境)。就如同'前提条件'里面所描述的那样。
- 有必要的话,启动到Live环境.
- 对于每个需要转换的分区:
- 确保分区没有被挂载
- 运行tune2fs -O extents,uninit_bg,dir_index /dev/分区 (/dev/分区替换成需要转换分区的路径,例如/dev/sda1)
- 运行fsck -fp /dev/分区
- 重新启动 Arch Linux!
问题解决
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:
# mkinitcpio -p kernel26
During the creation process, mkinitcpio correctly detected and included ext4 modules in the initial ramdisk.
GRUB Error 13
After a recent kernel update, this author encountered a GRUB error while attempting to boot from an ext4 /boot partition:
Error 13: Invalid or unsupported executable format
The solution is to boot from the live medium and chroot into the Arch Linux installation:
# mkdir /mnt/arch # mount -t ext4 /dev/sda1 /mnt/arch # mount -t proc proc /mnt/arch/proc # mount -t sysfs sys /mnt/arch/sys # mount -o bind /dev /mnt/arch/dev
# chroot /mnt/arch /bin/bash
If /boot is on a separate partition, this partition must also be mounted:
# mount -t ext4 /dev/sda2 /boot
Then, the following command should resolve the issue. (Does anyone know why?):
# grub-install --recheck /dev/sda
Data Corruption
If data corruption is encountered after a hard reboot, one user found that adding rootflags=data=ordered to their kernel line in GRUB's menu.lst helped resolve the issue.
(It was not specified whether this recovered the corrupt data or whether it simply helped prevent future corruption.)
Please read Ext4 data loss; explanations and workarounds for more information.