df
该命令的常见用法有两种:
[root@mio-254 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_mio254-mio254_1 3.6T 2.4T 1.1T 69% / tmpfs 16G 148K 16G 1% /dev/shm /dev/sdb1 194M 36M 149M 20% /boot
[root@mio-254 ~]# df -Ti Filesystem Type Inodes IUsed IFree IUse% Mounted on /dev/mapper/vg_mio254-mio254_1 ext4 241598464 106122 241492342 1% / tmpfs tmpfs 4111448 6 4111442 1% /dev/shm /dev/sdb1 ext4 51200 39 51161 1% /boot
如此分别查看挂在盘的目录,总容量和使用量,Inode的总量和使用量,以及磁盘文件系统的类型
在使用ext3等非动态调节inode数目的文件系统的时候,关注inode的余额是一件很容易被遗忘的事情,但无果业务类型正好是以小文件为主的情况,发生磁盘容量未满缺无法使用用,一定要检查inode的数目
一般来说,在mkfs格式化的时候,inode数目就被自动分配完成了,Linux会根据文件系统的blocksize和bytes/inode来自动计算,我们也可以在格式化的时候使用-N 参数自己指定这个数值
利用格式化创建一个1G容量,但是有600W个inode的磁盘
[root@MIO-2 ~]# dd if=/dev/zero of=needinode count=1024 bs=1024kB 1024+0 records in 1024+0 records out 1048576000 bytes (1.0 GB) copied, 4.09024 s, 256 MB/s [root@MIO-2 ~]# mkfs.ext4 -N 6000000 -b 1024 -I 128 needinode mke2fs 1.41.12 (17-May-2010) needinode is not a block special device. Proceed anyway? (y,n) y warning: 879 blocks unused. Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 6003480 inodes, 1023121 blocks 51200 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=12427776 735 block groups 1392 blocks per group, 1392 fragments per group 8168 inodes per group Superblock backups stored on blocks: 1393, 4177, 6961, 9745, 12529, 34801, 37585, 68209, 112753, 174001, 338257, 477457, 870001, 1014769 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@MIO-2 ~]# mount -o loop needinode /mnt/ [root@MIO-2 ~]# df -i | grep needinode df: `/mnt/cdrom': No such file or directory /root/needinode 6003480 11 6003469 1% /mnt