问题描述
我有一个磁盘驱动器,其索引节点使用率为100%(使用df -i
命令).但是,在实质性删除文件后,使用率仍为100%.
I have a disk drive where the inode usage is 100% (using df -i
command).However after deleting files substantially, the usage remains 100%.
那么正确的方法是什么?
What's the correct way to do it then?
磁盘空间使用较少的磁盘驱动器如何可能具有Inode的使用率要比磁盘空间使用率更高的磁盘驱动器高?
How is it possible that a disk drive with less disk space usage can havehigher Inode usage than disk drive with higher disk space usage?
如果我压缩很多文件,是否可以减少使用的inode数量?
Is it possible if i zip lot of files would that reduce the used inode count?
推荐答案
即使磁盘不是很满,也很容易使磁盘使用大量inode.
It's quite easy for a disk to have a large number of inodes used even if the disk is not very full.
将inode分配给文件,因此,如果您有成千上万个文件(每个全1个字节),则inode会用尽很久,然后再用完磁盘.
An inode is allocated to a file so, if you have gazillions of files, all 1 byte each, you'll run out of inodes long before you run out of disk.
如果文件具有多个硬链接,则删除文件也可能不会减少inode的数量.正如我所说,inode属于文件,而不是目录条目.如果文件有两个链接的目录条目,则删除其中一个不会释放索引节点.
It's also possible that deleting files will not reduce the inode count if the files have multiple hard links. As I said, inodes belong to the file, not the directory entry. If a file has two directory entries linked to it, deleting one will not free the inode.
此外,您可以删除目录条目,但是,如果正在运行的进程仍打开了文件,则不会释放inode.
Additionally, you can delete a directory entry but, if a running process still has the file open, the inode won't be freed.
我最初的建议是删除所有可以删除的文件,然后重新启动该框以确保没有使文件保持打开状态的进程.
My initial advice would be to delete all the files you can, then reboot the box to ensure no processes are left holding the files open.
如果您这样做仍然遇到问题,请告诉我们.
If you do that and you still have a problem, let us know.
顺便说一句,如果您要查找包含许多文件的目录,此脚本可能会有所帮助:
By the way, if you're looking for the directories that contain lots of files, this script may help:
#!/bin/bash
# count_em - count files in all subdirectories under current directory.
echo 'echo $(ls -a "$1" | wc -l) $1' >/tmp/count_em_$$
chmod 700 /tmp/count_em_$$
find . -mount -type d -print0 | xargs -0 -n1 /tmp/count_em_$$ | sort -n
rm -f /tmp/count_em_$$
这篇关于如何释放Inode使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!