获取 `df` 显示 FreeBSD 的更新信息

发布于 2024-07-05 02:43:51 字数 141 浏览 6 评论 0原文

我最近用完了 FreeBSD 服务器上驱动器上的磁盘空间。 我截断了导致问题的文件,但运行 df 时没有看到反映的更改。 当我在分区上运行 du -d0 时,它显示了正确的值。 有没有办法强制更新这些信息? 是什么导致这里的输出不同?

I recently ran out of disk space on a drive on a FreeBSD server. I truncated the file that was causing problems but I'm not seeing the change reflected when running df. When I run du -d0 on the partition it shows the correct value. Is there any way to force this information to be updated? What is causing the output here to be different?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丢了幸福的猪 2024-07-12 02:43:51

df --sync 有效吗?

Does df --sync work?

两人的回忆 2024-07-12 02:43:51

这可能集中于您如何截断文件。 dudf 将不同的内容报告为 unix.com 上的这篇文章进行了解释。 仅仅因为空间未被使用并不一定意味着它是免费的......

This probably centres on how you truncated the file. du and df report different things as this post on unix.com explains. Just because space is not used does not necessarily mean that it's free...

少女的英雄梦 2024-07-12 02:43:51

在 BSD 中,目录条目只是对底层文件数据(称为索引节点)的众多引用之一。 当使用 rm(1) 命令删除文件时,仅引用计数会减少。 如果引用计数仍然为正(例如,由于符号链接,文件具有其他目录条目),则不会删除底层文件数据。

较新的 BSD 用户通常没有意识到打开文件的程序也持有引用。 这可以防止进程使用底层文件数据时消失。 当进程关闭文件时,如果引用计数降至零,则文件空间将被标记为可用。 此方案用于避免 Microsoft Windows 类型问题,即不允许您删除文件,因为某些未指定的程序仍然打开该文件。

观察这一情况的一个简单方法是执行以下操作,

cp /bin/cat /tmp/cat-test
/tmp/cat-test &
rm /tmp/cat-test

直到后台进程终止为止,/tmp/cat-test 使用的文件空间将保持分配状态且不可用,如 df(1) 所报告的,但 du(1) 命令不会能够解释它,因为它不再有文件名。

请注意,如果系统崩溃而进程没有关闭文件,则文件数据仍然存在但未被引用,则需要运行 fsck(8) 来恢复文件系统空间。

进程保持文件打开状态是 newsyslog(8) 命令向 syslogd 或其他日志记录程序发送信号以通知它们应该在轮换日志文件后关闭并重新打开日志文件的原因之一。

软更新还会影响文件系统可用空间,因为实际的索引节点空间恢复可以被推迟; 可以使用sync(8)命令来促使这种情况更快发生。

In BSD a directory entry is simply one of many references to the underlying file data (called an inode). When a file is deleted with the rm(1) command only the reference count is decreased. If the reference count is still positive, (e.g. the file has other directory entries due to symlinks) then the underlying file data is not removed.

Newer BSD users often don't realize that a program that has a file open is also holding a reference. The prevents the underlying file data from going away while the process is using it. When the process closes the file if the reference count falls to zero the file space is marked as available. This scheme is used to avoid the Microsoft Windows type issues where it won't let you delete a file because some unspecified program still has it open.

An easy way to observe this is to do the following

cp /bin/cat /tmp/cat-test
/tmp/cat-test &
rm /tmp/cat-test

Until the background process is terminated the file space used by /tmp/cat-test will remain allocated and unavailable as reported by df(1) but the du(1) command will not be able to account for it as it no longer has a filename.

Note that if the system should crash without the process closing the file then the file data will still be present but unreferenced, an fsck(8) run will be needed to recover the filesystem space.

Processes holding files open is one reason why the newsyslog(8) command sends signals to syslogd or other logging programs to inform them they should close and re-open their log files after it has rotated them.

Softupdates can also effect filesystem freespace as the actual inode space recovery can be deferred; the sync(8) command can be used to encourage this to happen sooner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文