Python操作系统错误设备上没有剩余空间
我在一个文件夹中写入了很多文件,没有子目录,但是在280万个文件之后,出现了这个错误:Python操作系统错误设备上没有剩余空间,python,linux,ext4,Python,Linux,Ext4,我在一个文件夹中写入了很多文件,没有子目录,但是在280万个文件之后,出现了这个错误: with open(bottleneck_path, 'w') as save_file: OSError: [Errno 28] No space left on device: '/home/user/path/redacted' 我已经检查了文件名的长度,它只有149个字符长。文件大小应该在18K左右 我的操作系统是Linux df-i: Filesystem
with open(bottleneck_path, 'w') as save_file:
OSError: [Errno 28] No space left on device: '/home/user/path/redacted'
我已经检查了文件名的长度,它只有149个字符长。文件大小应该在18K左右
我的操作系统是Linux
df-i:
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 4106923 544 4106379 1% /dev
tmpfs 4113022 836 4112186 1% /run
/dev/sda2 28401664 9008557 19393107 32% /
tmpfs 4113022 40 4112982 1% /dev/shm
tmpfs 4113022 5 4113017 1% /run/lock
tmpfs 4113022 16 4113006 1% /sys/fs/cgroup
/dev/sda1 0 0 0 - /boot/efi
df-T
杜什
56G
ls | wc-l
2892084
根据我的理解,ext4应该能够很好地处理这个问题
编辑:
tune2fs-l/dev/sda2
tune2fs 1.42.13 (17-May-2015)
Filesystem volume name: <none>
Last mounted on: /
Filesystem UUID: cd620466-1f88-400b-acf5-457a9c9544cf
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 28401664
Block count: 113587456
Reserved block count: 5679372
Free blocks: 82864623
Free inodes: 25755495
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 996
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Wed Mar 1 15:14:22 2017
Last mount time: Mon Mar 27 13:20:00 2017
Last write time: Mon Mar 27 13:20:00 2017
Mount count: 35
Maximum mount count: -1
Last checked: Wed Mar 1 15:14:22 2017
Check interval: 0 (<none>)
Lifetime writes: 1813 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
First orphan inode: 1312056
Default directory hash: half_md4
Directory Hash Seed: e186507d-32b5-49c0-8ce1-09bf2a75d816
Journal backup: inode blocks
抛出错误,但相同的文件名结构使用不同的名称可以正常工作。例如:
touch /home/user/path/redacted/somefile_2
ext4的最大索引节点没有默认限制,这取决于设备的大小和创建时选择的选项。使用以下命令检查现有限制:
tune2fs -l /path/to/device
这是由于哈希冲突。禁用目录索引解决了问题。您是将所有280万个文件都作为所述目录的子目录写入,还是也存在嵌套?似乎ext4每个目录有64k个子目录的限制,根据@HoriaComan,没有嵌套,看看ls.ext4应该能够很好地处理这个问题。“没有子目录。@MatteoItalia已发布。在df-TSure之上,它可能能够处理它,但这仍然是一个相当糟糕的想法,是可以避免的。没有dir_索引,性能不会有任何问题吗?文件查找速度是否仍然可以接受?
touch /home/user/path/redacted/somefile_2
tune2fs -l /path/to/device