Linux的磁盘空间

2019-07-23  本文已影响0人  beeworkshop

Linux系统对磁盘空间的占用分为三个部分:

查看命令行参数限制
getconf ARG_MAX

法一
rm [a-n]* -rf
rm [o-z]* -rf

法二
find /var/spool/clientmqueue -type f -print -exec rm -f {} \;

法三(shell 脚本)
#!/bin/bash
RM_DIR='/var/spool/clientmqueue'
cd $RM_DIR
for F in `ls` ; do
  rm -f $F
done

注:cron执行的程序有输出内容时,就会发送邮件给执行cron进程的用户。发送邮件第一步先把邮件复制到/var/spool/clientmqueue目录下,然后等待MTA(Mail Transfer Agent)来处理。MTA会把上述目录中的邮件文件移动到/var/spool/mqueue目录下,然后通过sendmail服务发送出去(暂存的邮件文件将得到删除清理)。

相关命令:

du -h file    单个文件的磁盘占用
du -sh dir/    目录及其文件的磁盘总占用
du -sh /tmp/* | sort -nr | head 3    查看特定目录下头三个最占空间的文件
df -h    磁盘分区的可用空间和挂载点
df -i    磁盘可用的inode占用磁盘空间
ls -i    可以查看文件名对应的inode编号
查看某个磁盘分区的inode总数:
[root@node01 ~]# dumpe2fs -h /dev/sda2 
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          db3b6032-c405-4f02-bc03-bb138959b8a1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1954064          <--------inode总数
Block count:              7810560
Reserved block count:     390528
Free blocks:              7279466
Free inodes:              1922062
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8176
Inode blocks per group:   511
Flex block group size:    16
Filesystem created:       Mon Jul 22 09:29:25 2019
Last mount time:          Wed Jul 24 08:54:48 2019
Last write time:          Wed Jul 24 08:54:47 2019
Mount count:              4
Maximum mount count:      -1
Last checked:             Mon Jul 22 09:29:25 2019
Check interval:           0 (<none>)
Lifetime writes:          3900 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      a7418af3-d164-4d0b-aa23-3cee4c078524
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke journal_64bit
Journal size:             128M
Journal length:           32768
Journal sequence:         0x00000eb1
Journal start:            1
查看文件inode详细信息
[root@node01 ~]# stat anaconda-ks.cfg 
  File: ‘anaconda-ks.cfg’
  Size: 1602            Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d      Inode: 659056      Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-07-24 08:55:56.892995017 +0800
Modify: 2019-07-22 09:36:51.289957494 +0800
Change: 2019-07-22 09:36:51.289957494 +0800
 Birth: -
上一篇 下一篇

猜你喜欢

热点阅读