Linux 磁盘和目录的容量
磁盘与目录的容量
- df 列出文件系统的整体磁盘使用量
df [-ahikHTm] [目录或文件名]
-a: 列出所有的文件系统,包括系统特有的/proc等文件
-h: 以较阅读的GBytes, MBytes, KBytes等格式列出
-i: 不靠磁盘容量,而已inode的数量显示
-k: 以KBytes的容量显示文件系统
-m: 以MBytes的容量显示文件系统
-H: 以M=1000k替代M=1024k的进位方式
-T: 连同该partition的filesystem名称(例如xfs)也列出;
# 将系统的所有filesystem列出来
vagrant@homestead:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 988820 0 988820 0% /dev
tmpfs 204084 7584 196500 4% /run
/dev/mapper/homestead--vg-root 56422560 6456392 47070296 13% /
tmpfs 1020408 28 1020380 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 1020408 0 1020408 0% /sys/fs/cgroup
/dev/mapper/homestead--vg-mysql--master 65531436 269804 61889808 1% /homestead-vg/master
vagrant 61679940 15690224 45989716 26% /vagrant
home_vagrant_share 61679940 15690224 45989716 26% /home/vagrant/share
home_vagrant_share_blog 61679940 15690224 45989716 26% /home/vagrant/share/blog
home_vagrant_share_Sample 61679940 15690224 45989716 26% /home/vagrant/share/Sample
home_vagrant_share_readLaravel 61679940 15690224 45989716 26% /home/vagrant/share/readLaravel
home_vagrant_share_baidu_prophet-data_poc-scripts 61679940 15690224 45989716 26% /home/vagrant/share/baidu/prophet-data/poc-scripts
home_vagrant_share_baidu_knowledge-base_admin-server 61679940 15690224 45989716 26% /home/vagrant/share/baidu/knowledge-base/admin-server
tmpfs 204080 0 204080 0% /run/user/1000
# 以易读的方式列出容量格式
vagrant@homestead:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 966M 0 966M 0% /dev
tmpfs 200M 7.5M 192M 4% /run
/dev/mapper/homestead--vg-root 54G 6.2G 45G 13% /
tmpfs 997M 28K 997M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 997M 0 997M 0% /sys/fs/cgroup
/dev/mapper/homestead--vg-mysql--master 63G 264M 60G 1% /homestead-vg/master
vagrant 59G 15G 44G 26% /vagrant
home_vagrant_share 59G 15G 44G 26% /home/vagrant/share
home_vagrant_share_blog 59G 15G 44G 26% /home/vagrant/share/blog
home_vagrant_share_Sample 59G 15G 44G 26% /home/vagrant/share/Sample
home_vagrant_share_readLaravel 59G 15G 44G 26% /home/vagrant/share/readLaravel
home_vagrant_share_baidu_prophet-data_poc-scripts 59G 15G 44G 26% /home/vagrant/share/baidu/prophet-data/poc-scripts
home_vagrant_share_baidu_knowledge-base_admin-server 59G 15G 44G 26% /home/vagrant/share/baidu/knowledge-base/admin-server
tmpfs 200M 0 200M 0% /run/user/1000
# 将目前各个partition当中可用的inode数量列出
vagrant@homestead:~$ df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 242K 422 241K 1% /dev
tmpfs 250K 2.3K 247K 1% /run
/dev/mapper/homestead--vg-root 3.5M 209K 3.3M 6% /
tmpfs 250K 5 250K 1% /dev/shm
tmpfs 250K 3 250K 1% /run/lock
tmpfs 250K 18 250K 1% /sys/fs/cgroup
/dev/mapper/homestead--vg-mysql--master 4.0M 326 4.0M 1% /homestead-vg/master
vagrant 1000 0 1000 0% /vagrant
home_vagrant_share 1000 0 1000 0% /home/vagrant/share
home_vagrant_share_blog 1000 0 1000 0% /home/vagrant/share/blog
home_vagrant_share_Sample 1000 0 1000 0% /home/vagrant/share/Sample
home_vagrant_share_readLaravel 1000 0 1000 0% /home/vagrant/share/readLaravel
home_vagrant_share_baidu_prophet-data_poc-scripts 1000 0 1000 0% /home/vagrant/share/baidu/prophet-data/poc-scripts
home_vagrant_share_baidu_knowledge-base_admin-server 1000 0 1000 0% /home/vagrant/share/baidu/knowledge-base/admin-server
tmpfs 250K 11 250K 1% /run/user/1000
- du 评估文件系统的磁盘使用量
du [-ahskm] 文件或目录名称
-a: 列出所有文件和目录容量
-h: 以易读的容量格式(G/M)列出
-s: 列出总量, 而不列出每个各别的目录容量
-S: 不包括子目录的容量统计
-k: 以KBytes列出容量显示
-m: 以MBytes列出容量显示
# 列出当前目录下的所有文件大小
vagrant@homestead:~$ du
# 根目录下每个目录所占的容量
vagrant@homestead:~$ du -sm /*
16 /bin
143 /boot
1 /dev
du: cannot read directory '/etc/lvm/backup': Permission denied
du: cannot read directory '/etc/lvm/archive': Permission denied
du: cannot read directory '/etc/ssl/private': Permission denied
du: cannot read directory '/etc/polkit-1/localauthority': Permission denied
12 /etc
... 中间省略...