ll 文件比磁盘空间大? linux

处理运维问题的时候发现,文件比磁盘空间大

  1. 用 ll 查看文件的时候发现文件有400G,而文件系统只有200G,感觉很奇怪,就去做了个实验
[root@lin ~]# nohup dd if=/dev/zero of=test bs=1M count=100000 &
[1] 3497
[root@lin ~]# nohup: ignoring input and appending output to ‘nohup.out’
^C
[root@lin ~]# ll test 
-rw-r--r-- 1 root root 3767242752 Sep 12 18:30 test
[root@lin ~]# du -sh test 
12G	test
[root@lin ~]# > test 
[root@lin ~]# du -sh test 
1.8G	test
[root@lin ~]# ll test 
-rw-r--r-- 1 root root 18232692736 Sep 12 18:31 test
[root@lin ~]# kill 3497
  1. 日志清理大小,一般为了不终止服务,会选择使用 > 的方式去填空文件,逻辑大小没有改变,所有会造成这个假象
test
原始:
0101010100101010
> 后 :
/      空洞     /0101
# 后面追加的内容会写到置空前的后面
  1. 结论:
    ll: 看的是文件的逻辑大小
    du:看的是文件在磁盘上实际所占的block数
    实际是看 du 的值
posted @ 2020-09-12 18:40  运维之爪  阅读(425)  评论(0编辑  收藏  举报