如何使用大于16TB的ext4文件系统

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用大于16TB的ext4文件系统相关的知识,希望对你有一定的参考价值。

很多人用mkfs.ext4尝试不通之后,就改用xfs了。
而实际上,这个问题早有人解决了,解决方法起始也比较简单。

原来EXT4是真的支持1EiB的文件系统的,只是mkfs无法支持大于16T的文件系统,所以只需要升级一下格式化工具即可。
关于为什么mkfs.ext4不能格式化大于16T的Ext4文件系统以及其解决方法,原文解释如下:
To be specific: Even with the most recent e2fsprogs 1.41.14 there is no way to create file systems larger than 16 TB.

But: According to this post it should work since June:

It’s taken way too long, but I’ve finally finished integrating the 64-bit patches into e2fsprogs’s mainline repository. All of the necessary patches should now be in the master branch for e2fsprogs. The big change from before is that I replaced Val’s changes for fixing up how mke2fs picked the correct fs-type profile from mke2fs.conf with something that I think works much better and leaves the code much cleaner. With this change you need to add the following to your /etc/mke2fs.conf file if you want to enable the 64-bit feature flag automatically for a big disk:

[fs_types] ext4 =
features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize
auto_64-bit_support = 1 # <—- add this line
inode_size = 256


Alternatively you can change the features line to include the feature “64bit”; this will force the use of the 64-bit fields, and double the size of the block group descriptors, even for smaller file systems that don’t require the 64-bit support. (This was one of my problems with Val’s implementation; it forced the mke2fs.conf file to always enable the 64-bit feature flag, which would cause backwards compatibility issues.) This might be a good thing to do for debugging purposes, though, so this is an option which I left open, but the better way of doing things is to use the auto_64-bit-support flag.

所以,只需要升级下工具即可,升级方式如下:
git clone git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
cd e2fsprogs
./configure
make && make install

完毕之后还是不能用mkfs.ext4来格式化,而要用“mke2fs”进行格式化,命令参考如下:
mke2fs -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -i 4194304 /dev/md0

需要注意的是,这是一个还在开发中的工具,使用请个人承担风险:
This are *development* tools – use at your OWN RISK

格式化完毕后就挂载了,来看看你的超大EXT4文件系统吧:
mount -t ext4 /dev/md0 /mnt

mount|grep md0
/dev/md0 on /cache/data type ext4 (rw)

df -h
/dev/md0 19T 229M 18T 1% /mnt

最后,E文作者总结了这么几点,Conclusion:
With the most recent e2fstools (1.42-WIP) it is possible to create ext4 file system larger than 16 TB.

If you do so remember the following:

the tool is still in development – use at your own risk!
tune the values for autocheck (after x mounts / after y days)
adjust the “-i” switch which defines the bytes/inode ratio; in the example above one inode is created for every 8 MB
the more inodes you create the longer fsck takes and the more memory it needs
Resizing the file system (growing / shrinking) is NOT possible at the moment
参考技术A http //blog ronnyegner-consulting de/2011/08/18/ext4-and-the-16-tb-limit-now-solved/
http //rritw com/a/JAVAbiancheng/ANT/20101003/43604 html

CentOS6.4的ext4文件系统如何实现挂载大于16TB的磁盘分区

环境:

CentOS6.4_64bit


服务器硬盘配置12X2T,做了1个Raid5,再分了1个约500G的虚拟磁盘组和1个约21.5T的虚拟磁盘组。


选择500G的磁盘安装完系统CentOS6.4_64bit后,对21.5T的磁盘进行mkpart分区。


CentOS6.4_64bit中自带的低版本e2fsprogs不支持创建16TB以上的文件系统。


操作:

1、下载与CentOS6.4_64bit匹配的较高版本e2fsprogs-1.42.13.tar.gz

2、在系统镜像文件中提取并安装依赖包

rpm -ivh kernel-headers-2.6.32-431.el6.x86_64.rpm
rpm -ivh glibc-headers-2.12-1.132.el6.x86_64.rpm
rpm -ivh glibc-devel-2.12-1.132.el6.x86_64.rpm
rpm -ivh libgomp-4.4.7-4.el6.x86_64.rpm
rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
rpm -ivh cpp-4.4.7-4.el6.x86_64.rpm
rpm -ivh gcc-4.4.7-4.el6.x86_64.rpm

3、修改/etc/mke2fd.conf

#vi /etc/mke2fs.conf
[fs_types]
        ext3 = {
                features = has_journal
        }
        ext4 = {
                features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize
                auto_64-bit_support = 1  #添加这一行
                inode_size = 256
        }

4、将e2fsprogs-1.42.13.tar.gz拷贝到/home下,依次执行如下操作升级e2fsprogs

cd /home

tar xzvf e2fsprogs-1.43.4.tar.gz

cd e2fsprogs-1.42.13

mkdir build

cd build

../configure

make && make install
5、fdisk -l 查看21.5T的磁盘的盘符,如/dev/sdb1,对其执行如下命令来格式化

mkfs.ext4 /dev/sdb1

注:慎用快速格式化命令 mkfs.ext4 -T largefile /dev/sdb1  本人使用过程中,出现过磁盘空间未用完而inode用完致使磁盘写入使用的问题。重新用mkfs.ext4格式化后,目前工作磁盘读写正常。

6、mount /dev/sdb1 /data 将21.5T磁盘挂载在/data下

7、blkid -s UUID /dev/sdb1 查看/dev/sdb1的UUID,如下

/dev/sdb1: UUID="d0d1908c-f407-43ad-8300-6405f7f12866" TYPE="ext4"

8、vi /etc/fstab 编辑文件/etc/fstab,加入如下行,实现开机自动挂载

UUID=d0d1908c-f407-43ad-8300-6405f7f12866 /data ext4    defaults        0 0






本文出自 “COMMUNICATION” 博客,请务必保留此出处http://7136516.blog.51cto.com/7126516/1939385

以上是关于如何使用大于16TB的ext4文件系统的主要内容,如果未能解决你的问题,请参考以下文章

各位,linux 32位系统,分区能大于16TB吗

文件系统EXT3,EXT4和XFS的区别

linux之文件系统详解

liunx-储存管理-文件系统

文件系统及分区和raid

CentOS 6U7分区大于2TB的磁盘以及挂载大于16TB分区磁盘的解决方案