linux命令之文件系统(一)

查看文件系统信息:dumpe2fs

格式

 dumpe2fs [-h] 设备名称
选项与参数:
-h :仅列出 superblock 的数据,不会列出其他详细内容,这样方便查看

步骤

  1. 先用 df 找出电脑上有哪些设备

  1. 用dumpe2fs查看对应设备的信息

举例

[root@VM-0-14-centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  1.8G   45G   4% /
tmpfs          1003M   24K 1003M   1% /dev/shm
[root@VM-0-14-centos ~]# dumpe2fs -h /dev/vda1
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          22785f64-6c43-450f-8ea6-be91302eecc6
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 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:              3276800
Block count:              13106775
Reserved block count:     655198
Free blocks:              12499875
Free inodes:              3226398
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      636
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Tue Jan 11 19:52:56 2022
Last mount time:          Fri Jan 13 14:50:11 2023
Last write time:          Tue Jan 11 19:54:40 2022
Mount count:              15
Maximum mount count:      -1
Last checked:             Tue Jan 11 19:52:56 2022
Check interval:           0 (<none>)
Lifetime writes:          43 GB
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:      5f630c4b-b5c4-467b-9275-e4d486c76d95
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke
Journal size:             128M
Journal length:           32768
Journal sequence:         0x000b8b2b
Journal start:            24106

解释

看看这些比较常用的参数

Inode count: 3276800,这里说明有3276800个inode,要知道,一个inode对应一个文件,那么这个文件系统最多可以创建3276800文件

Block count: 13106775,这个是block的数量,block是实际存储数据的地方,一个inode可以对应一个或者多个block,这个就要看文件的大小了

Block size: 4096,这个是每个block的大小,这东西太大不行,太小也不行,具体要看你系统的应用,太大了会浪费,太小了会产生很多细小数据块。

Inode size: 256,这个是inode的大小。

上面的例子是只查看superblock的数据,如果还要查看更详细的信息,可以不用-h参数

Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          22785f64-6c43-450f-8ea6-be91302eecc6
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 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:              3276800
Block count:              13106775
Reserved block count:     655198
Free blocks:              12499875
Free inodes:              3226398
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      636
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Tue Jan 11 19:52:56 2022
Last mount time:          Fri Jan 13 14:50:11 2023
Last write time:          Tue Jan 11 19:54:40 2022
Mount count:              15
Maximum mount count:      -1
Last checked:             Tue Jan 11 19:52:56 2022
Check interval:           0 (<none>)
Lifetime writes:          43 GB
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:      5f630c4b-b5c4-467b-9275-e4d486c76d95
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke
Journal size:             128M
Journal length:           32768
Journal sequence:         0x000b8b2b
Journal start:            24106


Group 0: (Blocks 0-32767) [ITABLE_ZEROED]
  Checksum 0x5225, unused inodes 0
  Primary superblock at 0, Group descriptors at 1-4
  Reserved GDT blocks at 5-640
  Block bitmap at 641 (+641), Inode bitmap at 657 (+657)
  Inode table at 673-1184 (+673)
  21801 free blocks, 0 free inodes, 1049 directories
  Free blocks: 10876-10883, 10917-11430, 11442-11447, 11471-15099, 15123-15130, 15132-32767
  Free inodes: 
Group 1: (Blocks 32768-65535) [ITABLE_ZEROED]
  Checksum 0xeb98, unused inodes 0
  Backup superblock at 32768, Group descriptors at 32769-32772
  Reserved GDT blocks at 32773-33408
  Block bitmap at 642 (+4294935170), Inode bitmap at 658 (+4294935186)
  Inode table at 1185-1696 (+4294935713)
  20716 free blocks, 0 free inodes, 765 directories
  Free blocks: 33664-33791, 35328-35455, 35462-35463, 35478-35487, 35518-35583, 35663, 35680-35850, 35868-35871, 35904-35935, 35951, 36000-36031, 36144-36146, 36192-55295, 56320-56831, 57088-57279, 57888
-57919, 58112-58367, 63501, 63504-63515, 63848-63855, 63872-63891, 63894
  Free inodes: 
Group 2: (Blocks 65536-98303) [ITABLE_ZEROED]
  Checksum 0x8e9d, unused inodes 3456
  Block bitmap at 643 (+4294902403), Inode bitmap at 659 (+4294902419)
  Inode table at 1697-2208 (+4294903457)
  4633 free blocks, 3457 free inodes, 90 directories, 3456 unused inodes
  Free blocks: 66185-66249, 69811-70042, 70251-70655, 76471-77061, 77181-77220, 78005-78331, 78371-78499, 79153-79237, 81010-81011, 81032-81439, 85008-85026, 86729-86869, 87072-87212, 90112-92159
  Free inodes: 21120-24576
...
...
...
...
...
Group 399: (Blocks 13074432-13106774) [ITABLE_ZEROED]
  Checksum 0x0de8, unused inodes 0
  Block bitmap at 13105902 (+31470), Inode bitmap at 13105903 (+31471)
  Inode table at 13074432-13074943
  31829 free blocks, 8192 free inodes, 0 directories
  Free blocks: 13074944-13105901, 13105904-13106774
  Free inodes: 3268609-3276800

这里会列出blockgroup的信息,在每个blockgroup里都会列出改group的block信息,以下是我经常看到的信息:

Primary superblock at 0, Group descriptors at 1-4 【本group的superblock所在的位置】

Block bitmap at 641 (+641), Inode bitmap at 657 (+657)【block bitmap和inode bitmap所在的位置】

Inode table at 673-1184 (+673)【inode表所在的位置】

21801 free blocks, 0 free inodes, 1049 directories【空闲block和空闲inode的数量,没有空闲inode,就创建不了新文件了】

Free blocks: 10876-10883, 10917-11430, 11442-11447, 11471-15099, 15123-15130, 15132-32767【空闲block位置】

Free inodes:【空闲inode数量,这里是0】

在第一个group之外的group有这个信息:

Backup superblock at 32768, Group descriptors at 32769-32772

以为一般来说,一个文件系统就一个superblock,每个superblock位于block group里面,如果除了第一个group有superblock,其他的group的superblock是对第一个的备份。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值