免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4193 | 回复: 14
打印 上一主题 下一主题

solaris 上的df -k 和du -ks怎么差距这么大??? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-09-15 14:32 |只看该作者 |倒序浏览
最近/oracle目录增长很快,有没有发现是什么东西,没有新增文件。
看看下面的输出:
Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001
root@jmibss-db1 # cd /oracle
root@jmibss-db1 # df -k
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/rootvol 5165838 2976890 2137290 59% /
/proc 0 0 0 0% /proc
fd 0 0 0 0% /dev/fd
mnttab 0 0 0 0% /etc/mnttab
swap 11334744 136 11334608 1% /var/run
swap 11336104 1496 11334608 1% /tmp
/dev/vx/dsk/archive 50091616 2164914 47425786 5% /archive
/dev/vx/dsk/oracle 6198606 5285891 850729 87% /oracle
/dev/vx/dsk/node@1 774007 3608 716219 1% /global/.devices/node@1
/dev/vx/dsk/node@2 774007 3607 716220 1% /global/.devices/node@2
root@jmibss-db1 # du -ks
3096432 .
root@jmibss-db1 # pwd
/oracle
root@jmibss-db1 #


df -k看到的 /oracle uesed是5285891
但du -ks看到的却是3096432
怎么回事呢?

论坛徽章:
0
2 [报告]
发表于 2005-09-15 18:00 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

没有人回复嘛? 不知道嘛? 自己顶一下。

论坛徽章:
7
荣誉会员
日期:2011-11-23 16:44:17水瓶座
日期:2013-08-28 21:20:16丑牛
日期:2013-10-02 21:01:462015年迎新春徽章
日期:2015-03-04 09:54:45操作系统版块每日发帖之星
日期:2016-06-05 06:20:0015-16赛季CBA联赛之吉林
日期:2016-06-20 08:24:0515-16赛季CBA联赛之四川
日期:2016-08-18 15:02:02
3 [报告]
发表于 2005-09-15 18:01 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

我基本知道原因,但是我不知道你是不是我想象中的那种原因引起的。

论坛徽章:
11
金牛座
日期:2015-03-19 16:56:22数据库技术版块每日发帖之星
日期:2016-08-02 06:20:00数据库技术版块每日发帖之星
日期:2016-04-24 06:20:00数据库技术版块每日发帖之星
日期:2016-04-13 06:20:00IT运维版块每日发帖之星
日期:2016-04-13 06:20:00数据库技术版块每日发帖之星
日期:2016-02-03 06:20:00数据库技术版块每日发帖之星
日期:2015-08-06 06:20:00季节之章:春
日期:2015-03-27 15:54:57羊年新春福章
日期:2015-03-27 15:54:37戌狗
日期:2015-03-19 16:56:41数据库技术版块每日发帖之星
日期:2016-08-18 06:20:00
4 [报告]
发表于 2005-09-15 18:12 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

df -k是以K为单位的结果
du 是以块为单位
块的大小决定结果

论坛徽章:
0
5 [报告]
发表于 2005-09-15 20:37 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

du -sk 也是以k为大小的

论坛徽章:
0
6 [报告]
发表于 2005-09-15 22:45 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

知道可能的引起原因还不说。Faint。
幸亏还是老乡。

论坛徽章:
0
7 [报告]
发表于 2005-09-16 08:23 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

关注

论坛徽章:
0
8 [报告]
发表于 2005-09-16 08:34 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

windows下面叫簇
一般一个簇是4K,如果你保存不到4K的文件,它也会占用4K。
最小存贮单元

论坛徽章:
7
荣誉会员
日期:2011-11-23 16:44:17水瓶座
日期:2013-08-28 21:20:16丑牛
日期:2013-10-02 21:01:462015年迎新春徽章
日期:2015-03-04 09:54:45操作系统版块每日发帖之星
日期:2016-06-05 06:20:0015-16赛季CBA联赛之吉林
日期:2016-06-20 08:24:0515-16赛季CBA联赛之四川
日期:2016-08-18 15:02:02
9 [报告]
发表于 2005-09-16 08:40 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

原帖由 "benny80818" 发表:
知道可能的引起原因还不说。Faint。
幸亏还是老乡。


我也不敢肯定,所以不敢敢妄下结论。

论坛徽章:
0
10 [报告]
发表于 2005-09-16 09:33 |只看该作者

solaris 上的df -k 和du -ks怎么差距这么大???

Why "du" and "df" report different totals of used disk space?

SHORT ANSWER

There are 3 reasons why du and df can show different answers:

  1. Inconsistent fileystem requiring fsck(1m).
  2. Process with open file which does not exist in filesystem.
  3. Mount point directory contains data.

LONG ANSWER

Before going into detail for the 3 possibilities, it is important to
recognize how du and df obtain their answers:

  . du "walks" the filesystem (like "find" command would),
    checking the size of each file in turn, and keeping track of the total.

  . df makes a system call to the filesystem itself and requests a
    number of details, one of which is the current disk space used.
    (it gets the info directly from the superblocks of the filesystem).

1. Inconsistent fileystem requiring fsck(1m).

   If the filesystem becomes corrupt/inconsistent for some reason, it
   is quite likely that du and df will differ.  What can be seen by a
   process looking at the filesystem (i.e. du), does not match up with
   the view the filesystem itself has (i.e. what will be returned to
   the querying df process).
   
   Corrupt/inconsistent filesystems should be repaired using fsck(1m).
   
2. Process with open file which does not exist in the filesystem directory
   structure.

   This scenario commonly occurs when some process keeps writing to a file
   (usually a logfile) and a sysadmin deletes the file in panic to prevent
   the filesystem from filling up.  But the offending process keeps running
   and the space is not freed (the process keeps the file open).

   The disk blocks associated with a file are actually deleted and made
   available for reuse when the last "reference" to the file is removed.
   When a Unix process opens a file, the reference count to that file is
   incremented.  Subsequently, if the file itself is removed from the
   filesystem, the data blocks remain in use until the process closes
   the file, either explicitly with close(2), or implicitly when the
   process dies.

   Under these conditions, du will be unable to "see" the file in the
   filesystem (it was rm'd from the dir. structure), and therefore will
   not count its size, but df (in getting the answer from the filesystem
   itself) "knows" the file still exists.

   When the process closes the file (explicitly, or implicitly when the
   process either quits or is killed, or the machine is rebooted), the
   disk blocks will return to the freelist and du and df will agree.
   Actually it is the unmount and remount of the filesystem that fixes
   this problem.  But obviously if some process has an open file on the
   filesystem, it will be impossible to unmount the filesystem (device busy).
3. Directory mount point containing data.

   As filesystems are mounted on top of directories, if a directory
   mount point contains data, the du process will be unable to see this
   data (seeing only the mounted filesystem), but the underlying
   filesystem will still keep track of this data, consequently df will
   report the extra disk space in use.

   Unmounting the filesystem will reveal the data.  However, if the mounted
   filesystem is being used by running processes it will not be possible
   to unmount it.  Either identify and kill the processes (fuser(1m), etc.),
   or reboot (possibly in single user mode) to check the mount point directory.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP