如何释放 inode 的使用? [英] How to Free Inode Usage?

查看:43
本文介绍了如何释放 inode 的使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 inode 使用率为 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 have higher 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 属于文件, 目录条目.如果一个文件有两个链接到它的目录条目,删除一个不会释放 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 的使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆