[英]Dealing with large number of files in a directory on linux
I have a python code that will generate about 28 million files in a directory, but after generating about 6 million files, python will throw an OSError: [Errno 28] No space left on device
when it wants to open a new txt file.我有一个 python 代码,它将在一个目录中生成大约 2800 万个文件,但是在生成大约 600 万个文件后,python 会抛出一个OSError: [Errno 28] No space left on device
当它想要打开一个新的 txt 文件时OSError: [Errno 28] No space left on device
。
My disk space still has sufficient size to save files, and filesystem is ext4.我的磁盘空间仍然有足够的大小来保存文件,文件系统是 ext4。 I also check inodes and it still have 112M to use for each files.我还检查了 inode,它仍然有 112M 可用于每个文件。
Here is my disk info.这是我的磁盘信息。
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1999GB 1999GB primary ext4 boot
2 1999GB 2000GB 1023MB extended
5 1999GB 2000GB 1023MB logical linux-swap(v1)
and the remain space和剩余空间
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1.8T 150G 1.6T 9% /
and inodes和 inode
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdb1 117M 4.5M 112M 4% /
Is there a good way to store large number of files on linux?有没有一种在linux上存储大量文件的好方法?
尝试了很多方法后,比如格式化磁盘,使用gc清理内存,解决方案是使用一些文件夹来分散文件,并且它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.