背景
从bos对象存储中拷贝数据到硬盘中时提示No space left on device,但df
查看文件系统信息,存储和inode并没有满
分析
根据场景是将文件拷贝到一个目录下,没有二级目录,发现有可能是ext4文件系统的HTree索引限制了,需要启用ext4文件系统的特性large dirextory。
HTree索引提高目录的性能,最大深度为2层,超过这个深度时触发index full错误,
cp: cannot create regular file ‘/data_30tb_02/20xx05_all_oxxks/18xx51297.json’: No space left on device
实施
报错信息
[Fri Nov 8 17:12:02 2024] EXT4-fs warning (device sdf): ext4_dx_add_entry:2523: Directory (ino: 11939841) index full, reach max htree level :2
[Fri Nov 8 17:12:02 2024] EXT4-fs warning (device sdf): ext4_dx_add_entry:2527: Large directory feature is not enabled on this filesystem
卸载文件系统
root@xx-xx:~# umount /data_30tb_02
启用特性
root@xx-xx:~# tune2fs -O large_dir /dev/sdf
验证
root@xx-xx:~# tune2fs -l /dev/sdf |grep large
Filesystem features: has_journal ext_attr dir_index filetype needs_recovery extent 64bit flex_bg large_dir sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
重新挂载
root@xx-xx:~# mount /dev/sdf /data_30tb_02
又可以愉快的拷贝数据了
reference
https://utcc.utoronto.ca/~cks/space/blog/linux/Ext4DirectoriesMaximumSize