以下文章转载:http://blog.itpub.net/10173379/viewspace-744440/
[root@dmdb2 log]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p1 9.7G 538M 8.7G 6% /
/dev/cciss/c0d0p6 503G 35G 442G 8% /opt
/dev/cciss/c0d0p5 9.7G 158M 9.1G 2% /home
/dev/cciss/c0d0p3 9.7G 2.5G 6.8G 28% /usr
/dev/cciss/c0d0p2 9.7G 1.1G 8.2G 12% /var
tmpfs 127G 36G 91G 28% /dev/shm
/dev/sddlmaa1 493G 531M 467G 1% /etl_loader
[root@dmdb2 log]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/cciss/c0d0p1 10153988 550000 9079872 6% /
/dev/cciss/c0d0p6 526902720 36508388 463197496 8% /opt
/dev/cciss/c0d0p5 10153988 161052 9468820 2% /home
/dev/cciss/c0d0p3 10154020 2604320 7025580 28% /usr
/dev/cciss/c0d0p2 10154020 1066128 8563772 12% /var
tmpfs 132135932 36923100 95212832 28% /dev/shm
/dev/sddlmaa1 516054864 543296 489297508 1% /etl_loader
为什么df -h的结果显示中, Avail + Used 不等于Size列的值(tmpfs除外),你注意过吗?!
以 /dev/sddlmaa为例,首先用fdisk查看磁盘的大小:
[root@dmdb2 log]# fdisk -l /dev/sddlmaa
Disk /dev/sddlmaa: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sddlmaa1 1 65270 524281243+ 83 Linux
[root@dmdb2 log]# expr 536870912000 / 1048576 / 1024
500
以上可以看出 /dev/sddlmaa 大小为500GB, 但是df -h显示的结果为493G,谁动了我的7GB空间?!
猜想一下,文件系统元数据(inode), 保留空间,还是其他?
以下我们用tune2fs命令来查看 /dev/sddlmaa的superblock信息,看看7GB空间去哪儿了?
[root@dmdb2 log]# tune2fs -l /dev/sddlmaa1
tune2fs 1.39 (29-May-2006)
Filesystem volume name:
Last mounted on:
Filesystem UUID: b60c1597-b8df-4573-939f-9b9b7cbb27e8
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior.: Continue
Filesystem OS type: Linux
Inode count: 65536000
Block count: 131070310
Reserved block count: 6553515
Free blocks: 128903916
Free inodes: 65535216
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 992
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Tue Sep 27 13:44:47 2011
Last mount time: Fri May 11 05:43:36 2012
Last write time: Fri May 11 05:43:36 2012
Mount count: 7
Maximum mount count: 35
Last checked: Tue Sep 27 13:44:47 2011
Check interval: 15552000 (6 months)
Next check after: Sun Mar 25 13:44:47 2012
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 04e7940a-f2d4-4ea0-b0a4-78134302d050
Journal backup: inode blocks
根据tune2fs的结果,inode空间大小如下:
[root@dmdb2 log]# expr 65536000 \* 128 / 1048576 / 1024
7
正好是7GB,这验证我们前面的猜测!
至此我们的7GB空间找回了,回到正题还以/dev/sddlmaa为例, Size - Avail - Used= 516054864 - 543296 - 489297508 (KB)
[root@dmdb2 log]# echo "516054864 - 543296 - 489297508"|bc
26214060
这么多26214060KB的空间哪儿去了呢? 系统隐藏了,保留了? 如果是,这些空间做什么呢,可以被释放吗?
保留空间(Reserved block)做什么的? 这个空间可以调整吗(参考命令: tune2fs -m 0 )?
保留空间功能:
1. 减少Linux文件系统碎片;
2. 在磁盘分区没有剩余空间的时候.,root用户也可以登陆维护,或者系统记录日志.
File system Reserved Block Count is supposed to reduce Linux file system defragmentation,
to allow root user login for maintenance or to allow Linux system logging facility to function properly
in case file system running low of free disk space.
通常情况下,保留空间大小为 (disk size - inode size ) * 5%
根据tune2fs的结果,保留空间大小如下:
[root@dmdb2 log]# expr 6553515 \* 4
26214060 (KB)
这个值正好等于上面的 Size - Avail - Used
小结, df 命令结果显示的 Size 不等于 Avail + Used, 实际上 Avail + Used = 0.95 * Size, 剩余0.05为保留空间.
这个Size为磁盘可存储数据的大小,实际的裸盘大小参考 fdisk -l中的bytes.
顺便说一下,以前我们解释过fdisk -l查看磁盘大小跟df -h结果显示不一致的问题,还记得吗?
原因如下:
1. fdisk -l 通常以1000bytes 为1KB计数,因此显示的大小GB要大于df -h的结果.
2. df 显示的Size列,是剔除inode的大小(什么是inode?)
阅读(6626) | 评论(0) | 转发(0) |