大网数据广告活动
服务器运维问答

df says 33MB is used when there are no files on the partition

· 52CE 我爱测

When I run 'df -ha' on my system for an empty partition it is reporting that 33 MB is used: /dev/sdb2 16G 33M 16G 1% /mypartition Yet there are no files on the partition: ls -lha /mypartition/ total 0 drwx------ 2 root root 6 Feb…

问题原文

原帖链接 · binarylegit · CC BY-SA 3.0

When I run 'df -ha' on my system for an empty partition it is reporting that 33 MB is used:

/dev/sdb2        16G   33M   16G   1% /mypartition

Yet there are no files on the partition:

ls -lha /mypartition/
total 0
drwx------ 2 root root  6 Feb 16 21:09 .
drwxr-xr-x 5 root root 57 Feb 17 06:26 ..

What could be causing 'df' to report some space as used?

已采纳解答

原帖链接 · Siddharth sharma · CC BY-SA 3.0

This is perfectly normal. When we create a filesystem (say ext4) it creates a lot of overhead before any files are created. This is Reserved Space and serves the purposes to lower the fragmentation chances and to have some space for fsck, mainly for root user as to assure that services using files on that partition cannot be ruled out of space by some local user filling all the space. Different filesystem reserve different space.

form man tune2fs

-m reserved-blocks-percentage

          Set the percentage of the filesystem which may only be allocated
          by  privileged  processes.   Reserving some number of filesystem
          blocks for use by privileged processes is done to avoid filesys‐
          tem  fragmentation,  and  to  allow system daemons, such as sys‐
          logd(8), to continue to function correctly after  non-privileged
          processes  are  prevented  from writing to the filesystem.  Nor‐
          mally, the default percentage of reserved blocks is 5%.

So when you create a filesystem then default is 5% reserved blocks. You can adjust this reserve block according to your need during filesystem creation mkfs.ext4 -m <X> /dev/sdaX. You can also adjust this value after creating filesystem using tune2fs -m <X> </dev/sdaX> command.

Like if you want to remove reserved blocks:

tune2fs -m 0 /dev/sdaX

I strongly recommend against using -m 0. Reserved space is there for a reason. Even with no reserved blocks (-m 0) there is always a part of the space used for filesystem internal management.

Also, overhead comes from the inode tables and it is purely depends on how many inodes you allocate in a filesystem. Default size of inode is 256 bytes.

And there is no way to confirm this on CLI. What you can do is create different filesystem with different size and reserved space on different Linux Distributions and compare the result.

To confirm Reserved space is for root user only

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。