查看OS 文件系统的块大小
tune2fs命令允许系统管理员在Linux ext2、ext3或ext4文件系统上调整、设置、查看文件系统参数。tune2fs -l 只会显示 superblock 上的内容。
直接查看整个磁盘是不可行的,因为在该磁盘上创建了多个逻辑分区。查看时应制定具体的逻辑分区。
subGroup]# /sbin/tune2fs -l /dev/sda3 | grep "Block size" /sbin/tune2fs: Bad magic number in super-block while trying to open /dev/sda3 Couldn't find valid filesystem superblock.
tune2fs只能用于ext2、ext3、ext4文件类型,不支持其它文件类型
subGroup]# /sbin/tune2fs -l /dev/mapper/root_vg-varlv | grep "Block size" Block size: 4096 subGroup]# /sbin/tune2fs -l /dev/mapper/root_vg-varlv tune2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: /var Filesystem UUID: 8f768ceb-0bee-48e6-8813-b0ee5a27d534 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: 1966080 Block count: 7864320 Reserved block count: 393216 Free blocks: 1607635 Free inodes: 1961168 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1022 Blocks per group: 32768 #每个块组的block数量 Fragments per group: 32768 Inodes per group: 8192 #每个块组的inode号数量 Inode blocks per group: 512 #每个块组inode占用的块数量,也就是inode表大小 RAID stride: 64 RAID stripe width: 320 Flex block group size: 16 Filesystem created: Mon Oct 1 15:12:05 2018 Last mount time: Thu Dec 12 09:03:56 2019 Last write time: Thu Dec 12 09:03:56 2019 Mount count: 9 Maximum mount count: -1 Last checked: Mon Oct 1 15:12:05 2018 Check interval: 0 (<none>) Lifetime writes: 196 GB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 #文件系统的第一个inode号 Inode size: 256 #每个inode的大小 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: 60a34b23-4f85-4e87-bb92-11533c4c4da3 Journal backup: inode blocks
如果想查看块组的详细内容,例如superblock 、GDT..... ,可以使用dump2fs 查看,其内容包括tune2fs 的内容。
subGroup]# dumpe2fs /dev/mapper/root_vg-varlv|more dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: /var Filesystem UUID: 8f768ceb-0bee-48e6-8813-b0ee5a27d534 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: 1966080 Block count: 7864320 Reserved block count: 393216 Free blocks: 1607635 Free inodes: 1961168 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1022 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8192 Inode blocks per group: 512 RAID stride: 64 RAID stripe width: 320 Flex block group size: 16 Filesystem created: Mon Oct 1 15:12:05 2018 Last mount time: Thu Dec 12 09:03:56 2019 Last write time: Thu Dec 12 09:03:56 2019 Mount count: 9 Maximum mount count: -1 Last checked: Mon Oct 1 15:12:05 2018 Check interval: 0 (<none>) Lifetime writes: 196 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: 60a34b23-4f85-4e87-bb92-11533c4c4da3 Journal backup: inode blocks Journal features: journal_incompat_revoke Journal size: 128M Journal length: 32768 Journal sequence: 0x00fe3e23 Journal start: 11071 Group 0: (Blocks 0-32767) [ITABLE_ZEROED] Checksum 0x3470, unused inodes 8180 Primary superblock at 0, Group descriptors at 1-2 Reserved GDT blocks at 3-1024 Block bitmap at 1025 (+1025), Inode bitmap at 1041 (+1041) Inode table at 1057-1568 (+1057) 23512 free blocks, 8180 free inodes, 2 directories, 8180 unused inodes Free blocks: 9256-32767 Free inodes: 13-8192 Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x95dd, unused inodes 8192 Backup superblock at 32768, Group descriptors at 32769-32770 Reserved GDT blocks at 32771-33792 Block bitmap at 1026 (+4294935554), Inode bitmap at 1042 (+4294935570) Inode table at 1569-2080 (+4294936097) 10368 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 33918-34048, 34050, 34056-34063, 34112-34623, 34640-34815, 34829-35327, 35339-35967, 36029-38079, 38144-38399, 38409-38911, 39132-39135, 39156, 39158-39167, 39420-39423, 40660-40668, 40671, 40695 -40704, 40740-40741, 40835, 40853-40864, 40872, 40874-40885, 40887-40934, 40938-40959, 40970-41471, 41506-41983, 42017-42495, 42529-43007, 50368-50378, 50424-50431, 53919, 53935-53951, 53977-53983, 54010-54015, 59392-59415, 59426-59455, 59469-59595, 59920-60415, 60425-60927, 60937-61439, 63488-63789, 64025-64511, 64522-65023, 65033-65535 Free inodes: 8193-16384 Group 2: (Blocks 65536-98303) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xed64, unused inodes 8192 Block bitmap at 1027 (+4294902787), Inode bitmap at 1043 (+4294902803) Inode table at 2081-2592 (+4294903841) 22498 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 67598, 67602-67615, 67648-67655, 67867-67871, 67904-67923, 67953-68139, 68141-68143, 68154-68233, 68449-68479, 68609-69119, 69317-69631, 74227-74239, 74272-74943, 75008-75263, 75297-76160, 76252- 76287, 76324-76799, 76832-77695, 77824-83967, 84224-84479, 84514-90111, 92160-98303 Free inodes: 16385-24576 Group 3: (Blocks 98304-131071) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xa958, unused inodes 8192 Backup superblock at 98304, Group descriptors at 98305-98306 Reserved GDT blocks at 98307-99328 Block bitmap at 1028 (+4294870020), Inode bitmap at 1044 (+4294870036) Inode table at 2593-3104 (+4294871585) 23873 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 99368-99373, 99376-100864, 100870-100877, 100880-100906, 100912-101487, 101504-101508, 101520-101535, 101543, 101560-101633, 101635-101637, 101640-101759, 101854-102044, 102046-102054, 102056-102 060, 102064-102143, 102450-102513, 102525-102580, 102618-102735, 104592-104628, 104630-104781, 106276-106353, 106375-107007, 107520-108543, 109621-109759, 110080-110890, 111608-112128, 112252-112254, 112282-112 284, 112383-112385, 112394-112396, 112411-112413, 112420-112422, 112460-114687, 115121-115657, 115996-116223, 116244-118783, 118993-131071 Free inodes: 24577-32768
一个完整文件系统的结构
stat / | grep "IO Block" xfs和ext系列的块大小都可以查看。
[root@MiWiFi-R3L-srv ninesun]# stat / | grep "IO Block" Size: 224 Blocks: 0 IO Block: 4096 directory [root@MiWiFi-R3L-srv ninesun]# df -TH Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 493M 0 493M 0% /dev tmpfs tmpfs 510M 0 510M 0% /dev/shm tmpfs tmpfs 510M 9.0M 501M 2% /run tmpfs tmpfs 510M 0 510M 0% /sys/fs/cgroup /dev/mapper/centos-root xfs 19G 5.5G 13G 30% / /dev/sda1 xfs 1.1G 267M 798M 26% /boot