Linux 如何在 ext4 上存储 10 亿个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21397110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to store one billion files on ext4?
提问by redice
I only created about 8 million files, then there was no free inode in /dev/sdb1.
我只创建了大约 800 万个文件,然后 /dev/sdb1 中没有空闲的 inode。
[spider@localhost images]$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdb1 8483456 8483456 0 100% /home
Someone says can specify the inode count when format the partition.
有人说可以在格式化分区时指定inode计数。
e.g. mkfs.ext4 -N 1000000000.
例如 mkfs.ext4 -N 1000000000。
I tried but got an error:
我试过了,但出现错误:
"inode_size (256) * inodes_count (1000000000) too big...specify higher inode_ratio (-i) or lower inode count (-N). ".
“inode_size (256) * inodes_count (1000000000) 太大了...指定更高的 inode_ratio (-i) 或更低的 inode count (-N)。”。
What's the appropriate inode_ratio value?
什么是合适的 inode_ratio 值?
I heard the min inode_ratio value is 1024 for ext4.
我听说 ext4 的最小 inode_ratio 值为 1024。
Is it possible to store one billion files on a single partition? How to? And someone says it will be very slow.
是否可以在单个分区上存储 10 亿个文件?如何?有人说它会很慢。
采纳答案by Christophe Vu-Brugier
When creating an ext4 file system, you can specify the usage type:
创建ext4文件系统时,可以指定使用类型:
mkfs.ext4 -T usage-type /dev/something
The available usage types are listed in /etc/mke2fs.conf. The main difference between usage types is the inode ratio. The lower the inode ratio, the more you can create files in your file system.
可用的使用类型列在 /etc/mke2fs.conf 中。使用类型之间的主要区别是 inode 比率。inode ratio越低,您可以在文件系统中创建的文件就越多。
The usage type in mke2fs.conf which allocates the highest number of inodes in the file system is "news". With this usage type on a 1 TB hard drive, ext4 creates 244 million inodes.
mke2fs.conf 中分配文件系统中最多数量的 inode 的使用类型是“news”。使用 1 TB 硬盘驱动器上的这种使用类型,ext4 创建 2.44 亿个 inode。
# tune2fs -l /dev/sdb1 | grep -i "inode count"
Inode count: 244219904
# sgdisk --print /dev/sdb
Disk /dev/sdb: 1953525168 sectors, 931.5 GiB
This means that it would require more than 4 TB to create an ext4 file system with "-Tnews" that could possibly hold 1 billion inodes.
这意味着使用“-Tnews”创建一个可能包含 10 亿个 inode 的 ext4 文件系统将需要超过 4 TB 的空间。