tune2fs命令允许系统管理员在Linux ext2、ext3或ext4文件系统上调整、设置、查看文件系统参数。tune2fs -l 只会显示 superblock 上的内容。有时候使用tune2fs命令遇到类似“Couldn't find valid filesystem superblock”这样的错误,这个可能是因为你对该命令的一些细节或参数没有注意的缘故。
1:tune2fs -l /dev/xxx tune2fs -l要跟具体的分区,而不是整个硬盘。否则会出现下面错误:
[root@mylnx1 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
ext3 41518344 29366024 10009296 75% /
/dev/sda1 ext3 101086 23532 72335 25% /boot
/dev/mapper/VolGroup02-LogVol00
ext3 82537136 42421272 35923200 55% /u01
/dev/mapper/VolGroup01-LogVol00
ext3 165107052 140918868 15801216 90% /u02
/dev/mapper/VolGroup03-LogVol00
ext3 185749492 130321240 45992708 74% /u03
/dev/mapper/VolGroup04-LogVol00
ext3 123822052 98380964 19151272 84% /u04
/dev/sdg1 ext4 104238720 74221532 24722168 76% /u05
tmpfs tmpfs 2026460 0 2026460 0% /dev/shm
[root@mylnx1 ~]# tune2fs -l /dev/sda
tune2fs 1.39 (29-May-2006)
tune2fs: Bad magic number in super-block while trying to open /dev/sda
Couldn't find valid filesystem superblock.
[root@mylnx1 ~]# tune2fs -l /dev/sda1 #参数是磁盘分区,而不是对应的磁盘
tune2fs 1.39 (29-May-2006)
Filesystem volume name: /boot
Last mounted on: <not available>
Filesystem UUID: 2c1864be-127a-4cf5-98aa-a45affaaee72
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 26104
Block count: 104388
Reserved block count: 5219
Free blocks: 77538
Free inodes: 26064
First block: 1
Block size: 1024
Fragment size: 1024
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2008
Inode blocks per group: 251
Filesystem created: Fri May 8 21:55:36 2015
Last mount time: Sat Apr 25 14:03:18 2020
Last write time: Sat Apr 25 14:03:18 2020
Mount count: 21
Maximum mount count: -1
Last checked: Sun Apr 30 12:55:19 2017
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 3505f19e-b37f-48d2-be11-0cdb80f8fb93
Journal backup: inode blocks
2:如果对磁盘分区做了LVM,那么此时将分区作为tune2fs命令的参数将出现下面错误。
[root@mylnx1 ~]# tune2fs -l /dev/sdg1
tune2fs 1.39 (29-May-2006)
tune2fs: Filesystem has unsupported feature(s) while trying to open /dev/sdg1
Couldn't find valid filesystem superblock.
正确的姿势应该如下:
[root@mylnx1 ~]# pvscan
PV /dev/sdg1 VG VolGroup06 lvm2 [250.00 GB / 0 free]
PV /dev/sdh8 VG VolGroup06 lvm2 [39.12 GB / 0 free]
PV /dev/sdf5 VG VolGroup05 lvm2 [199.97 GB / 0 free]
..........................................................
[root@mylnx1 ~]# tune2fs -l /dev/mapper/VolGroup06-LogVol00
tune2fs 1.39 (29-May-2006)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: a04472bb-c43e-45e8-8c6d-179a9ebcf6e8
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 32768000
Block count: 65534976
Reserved block count: 3275949
Free blocks: 48745374
Free inodes: 32767884
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1008
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Fri Jun 29 20:31:12 2018
Last mount time: Sat Apr 25 14:03:18 2020
Last write time: Sat Apr 25 14:03:18 2020
Mount count: 1
Maximum mount count: 38
Last checked: Sat Apr 25 13:56:09 2020
Check interval: 15552000 (6 months)
Next check after: Thu Oct 22 13:56:09 2020
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 9ae513c5-c38c-4b3a-81f6-3746d2c8f23a
Journal backup: inode blocks
3:tune2fs只能用于ext2、ext3、ext4文件类型,不支持其它文件类型
文件类型为xfs时。报“Couldn't find valid filesystem superblock.”。注意tune2fs只能用于ext2、ext3、ext4文件类型,对于XFS类型,tune2fs不能解读。
[root@KerryDB ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root xfs 52403200 4412324 47990876 9% /
devtmpfs devtmpfs 1886508 0 1886508 0% /dev
tmpfs tmpfs 1899164 0 1899164 0% /dev/shm
tmpfs tmpfs 1899164 8964 1890200 1% /run
tmpfs tmpfs 1899164 0 1899164 0% /sys/fs/cgroup
/dev/sda2 xfs 1038336 145936 892400 15% /boot
/dev/mapper/centos-home xfs 430525040 1543444 428981596 1% /home
tmpfs tmpfs 379836 0 379836 0% /run/user/0
[root@KerryDB ~]# tune2fs -l /dev/sda2
tune2fs 1.42.9 (28-Dec-2013)
tune2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
tune2fs applies only to ext[2-4] filesystems; not to XFS ones. The "Bad magic number in super-block" simply means that tune2fs doesn't understand the filesystem type. As you noted, the fact that your filesystem can be mounted confirms that it's viable.
来源:oschina
链接:https://my.oschina.net/u/4286372/blog/4273134