检测 Linux 中配额的块大小
Linux 中磁盘配额的限制以块为单位。但是,我没有找到可靠的方法来确定块大小。我发现教程将块大小称为 512 字节,有时称为 1024 字节。
我在阅读帖子时感到困惑LinuxForum.org 了解块大小的真正含义。所以我试图在配额的背景下找到这个含义。
我找到了“确定硬盘文件系统上磁盘配额的块大小”NixCraft 上的提示,建议使用以下命令:
dumpe2fs /dev/sdXN | grep -i 'Block size'
或
blockdev --getbsz /dev/sdXN
但在我的系统上,这些命令返回 4096,当我检查同一系统上的实际配额块大小时,我得到的块大小为 1024 字节。
是否有一种可编写脚本的方法来确定设备上的配额块大小,无需创建已知大小的文件并检查其配额使用情况?
The limit placed on disk quota in Linux is counted in blocks. However, I found no reliable way to determine the block size. Tutorials I found refer to block size as 512 bytes, and sometimes as 1024 bytes.
I got confused reading a post on LinuxForum.org for what a block size really means. So I tried to find that meaning in the context of quota.
I found a "Determine the block size on hard disk filesystem for disk quota" tip on NixCraft, that suggested the command:
dumpe2fs /dev/sdXN | grep -i 'Block size'
or
blockdev --getbsz /dev/sdXN
But on my system those commands returned 4096, and when I checked the real quota block size on the same system, I got a block size of 1024 bytes.
Is there a scriptable way to determine the quota block size on a device, short of creating a known sized file, and checking it's quota usage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件系统块大小和配额块大小可能不同。配额块大小由
(/usr/include/sys/mount.h) 中定义的BLOCK_SIZE
宏给出:文件系统块大小给定的文件系统由 statvfs 调用返回:
标头包含一个方便的宏,用于将文件系统块转换为磁盘配额块:The filesystem blocksize and the quota blocksize are potentially different. The quota blocksize is given by the
BLOCK_SIZE
macro defined in<sys/mount.h>
(/usr/include/sys/mount.h):The filesystem blocksize for a given filesystem is returned by the
statvfs
call:The
<sys/quota.h>
header includes a convenience macro to convert filesystem blocks to disk quota blocks: