想要了解 XFS 的奇特之处

想要了解 XFS 的奇特之处

我发现一个 XFS 分区的行为非常奇怪。它在一个系统下可以正常安装,但在其他系统下却无法安装——其中就包括我的主系统。由于我是 XFS 新手,因此在我忘记 XFS 之前,我很想听听比我更有经验的用户的意见。

  • 硬件很好:SMART 显示三个月前的 1TB 2.5 英寸 Momentus 很好;所有属性都像 WORST=VALUE。HDD 处于英特克外部铝制机架,通过 USB 连接至我的任意一台笔记本电脑。
  • 分区布局非常简单,MBR 有四个主分区,XFS 分区是我存储所有媒体资料(库)的地方。三个月前,我在Arch i686(内核 3.19-ck)下使用创建了分区parted。在该系统下访问它没有任何问题。但在Fedora 16 i686较旧的内核下,即使运行后也无法挂载xfs_repair
  • 此外,在我运行的任何 Linux 下,我都可以毫无问题地在该驱动器上安装其他(ext4 / swap)分区。
  • 现在我无法Arch x86_64在这里安装替换主笔记本电脑上的 i686 版本的 XFS 分区。除了操作系统版本外,没有更改任何内容。
  • 如果我下一分钟尝试Slackware 14.1使用 linux-3.17.4 (i686) 挂载同一个分区,它就……挂载了?!

这是磁盘布局

# fdisk -l /dev/sdb

Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x531843f8

Device     Boot    Start        End    Sectors   Size Id Type
/dev/sdb1           8192     212991     204800   100M 83 Linux
/dev/sdb2         212992    8200191    7987200   3.8G 82 Linux swap / Solaris
/dev/sdb3        8200192   20488191   12288000   5.9G 83 Linux
/dev/sdb4       20488192 1953523711 1933035520 921.8G 83 Linux

按照我的用户给出的提示进行挂载尝试:

$ mount /media/momedia/
mount: mount /dev/sdb4 on /media/momedia failed: Structure needs cleaning

然后以 root 身份

# mount /media/momedia/
mount: wrong fs type, bad option, bad superblock on /dev/sdb4,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

dmesg

# dmesg | tail
[274136.490862] sd 9:0:0:0: [sdb] 1953525168 512-byte logical blocks: 

(1.00 TB/931 GiB)
[274136.490876] sd 9:0:0:0: [sdb] 4096-byte physical blocks
[274136.491965] sd 9:0:0:0: [sdb] Write Protect is off
[274136.491980] sd 9:0:0:0: [sdb] Mode Sense: 43 00 00 00
[274136.493079] sd 9:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[274136.519478]  sdb: sdb1 sdb2 sdb3 sdb4
[274136.523459] sd 9:0:0:0: [sdb] Attached SCSI disk
[274162.463851] XFS (sdb4): Version 5 superblock detected. This kernel has EXPERIMENTAL support enabled!
                Use of these features in this kernel is at your own risk!
[274162.463864] XFS (sdb4): Superblock has unknown read-only compatible features (0x1) enabled.
[274162.463869] XFS (sdb4): Attempted to mount read-only compatible filesystem read-write.
                Filesystem can only be safely mounted read only.
[274162.463878] ffff880079931000: 58 46 53 42 00 00 10 00 00 00 00 00 0e 66 f9 00  XFSB.........f..
[274162.463884] ffff880079931010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[274162.463889] ffff880079931020: ed 2d 1b 3d be 8e 4a 99 94 48 1e 50 b3 63 8a 3b  .-.=..J..H.P.c.;
[274162.463895] ffff880079931030: 00 00 00 00 08 00 00 08 00 00 00 00 00 00 00 60  ...............`
[274162.463901] XFS (sdb4): Internal error xfs_sb_read_verify at line 730 of file fs/xfs/xfs_mount.c.  Caller 0xffffffffa0714635

[274162.463910] CPU: 0 PID: 81 Comm: kworker/0:1H Not tainted 3.10.94-1-lts310-ck #1
[274162.463915] Hardware name: Dell Inc. Inspiron 1012/00D2K7, BIOS A11 11/12/2010
[274162.463942] Workqueue: xfslogd xfs_buf_iodone_work [xfs]
[274162.463947]  0000000000000001 ffff880078f25d88 ffffffff814bec2d ffff880078f25dc8
[274162.463956]  ffffffffa07172d3 ffffffffa0714635 ffffffffa0795945 ffff88007002a100
[274162.463963]  0000000000000016 ffff88007985d800 0000000000001000 ffff880078f25e08
[274162.463971] Call Trace:
[274162.463985]  [<ffffffff814bec2d>] dump_stack+0x19/0x1b
[274162.464007]  [<ffffffffa07172d3>] xfs_corruption_error+0x93/0xa0 [xfs]
[274162.464028]  [<ffffffffa0714635>] ? xfs_buf_iodone_work+0x75/0xa0 [xfs]
[274162.464059]  [<ffffffffa076da02>] xfs_sb_read_verify+0x112/0x130 [xfs]
[274162.464081]  [<ffffffffa0714635>] ? xfs_buf_iodone_work+0x75/0xa0 [xfs]
[274162.464102]  [<ffffffffa0714635>] xfs_buf_iodone_work+0x75/0xa0 [xfs]
[274162.464112]  [<ffffffff8107558a>] process_one_work+0x17a/0x4e0
[274162.464120]  [<ffffffff81076093>] worker_thread+0x123/0x430
[274162.464128]  [<ffffffff814c2dc3>] ? preempt_schedule+0x43/0x60
[274162.464137]  [<ffffffff81075f70>] ? manage_workers.isra.8+0x290/0x290
[274162.464144]  [<ffffffff8107c6f0>] kthread+0xc0/0xd0
[274162.464152]  [<ffffffff8107c630>] ? kthread_worker_fn+0x170/0x170
[274162.464161]  [<ffffffff814cbe48>] ret_from_fork+0x58/0x90
[274162.464168]  [<ffffffff8107c630>] ? kthread_worker_fn+0x170/0x170
[274162.464174] XFS (sdb4): Corruption detected. Unmount and run xfs_repair
[274162.464193] XFS (sdb4): SB validate failed with error 22.

file -s 标识文件系统整洁清晰

[root@gwenael ~]# file -s /dev/sdb4
/dev/sdb4: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)

我检查了分区开头的数据,发现它很整洁(但我对十六进制并不熟悉)

[root@gwenael ~]# dd if=/dev/sdb4 bs=512 count=64 iflag=direct | hexdump -C
64+0 records in
64+0 records out
32768 bytes (33 kB) copied, 0.0252469 s, 1.3 MB/s
00000000  58 46 53 42 00 00 10 00  00 00 00 00 0e 66 f9 00  |XFSB.........f..|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  ed 2d 1b 3d be 8e 4a 99  94 48 1e 50 b3 63 8a 3b  |.-.=..J..H.P.c.;|
00000030  00 00 00 00 08 00 00 08  00 00 00 00 00 00 00 60  |...............`|
00000040  00 00 00 00 00 00 00 61  00 00 00 00 00 00 00 62  |.......a.......b|
00000050  00 00 00 01 03 99 be 40  00 00 00 04 00 00 00 00  |.......@........|
00000060  00 01 cc df bc a5 10 00  02 00 00 08 6d 6f 6d 65  |............mome|
00000070  64 69 61 73 00 00 00 00  0c 0c 09 03 1a 00 00 19  |dias............|
00000080  00 00 00 00 00 03 f8 00  00 00 00 00 00 00 01 22  |..............."|
00000090  00 00 00 00 09 77 78 90  00 00 00 00 00 00 00 00  |.....wx.........|
000000a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
000000b0  00 00 00 00 00 00 00 04  00 00 00 00 00 00 00 00  |................|

下次尝试挂载时,输出变回我的用户原来的输出

# mount -t xfs /dev/sdb4 /media/momedia/
mount: mount /dev/sdb4 on /media/momedia failed: Structure needs cleaning

安全检查发现超级块

# xfs_repair -n /dev/sdb4
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - found root inode chunk
         <SNIP SNIP>
        - moving disconnected inodes to lost+found ...
Phase 7 - verify link counts...
Maximum metadata LSN (1:402600) is ahead of log (1:8).
Would format log to cycle 4.

由于它没有安装,我使用xfs_repair /dev/sdb4与上面相同的输出运行,但是

Phase 5 - rebuild AG headers and trees...
        - reset superblock...

但我也安装不了

# mount -t xfs /dev/sdb4 /media/momedia/
mount: wrong fs type, bad option, bad superblock on /dev/sdb4,
       missing codepage or helper program, or other error

然后我运行, xfs_repair /dev/sdb4结果是一样的。

我第一次遇到这样的敏感的FS 那么,您知道我该怎么做才能以更标准/兼容的方式安装它吗?


已编辑以在 mount 命令上显示完整的系统日志。此外,按照日志的建议在 Arch 上将其设置为只读失败:

# mount -t xfs -o ro /dev/sdb4 /mnt/tmp/
mount: mount /dev/sdb4 on /mnt/tmp failed: Structure needs cleaning

答案1

mkfs.xfs(从 xfsprogs 3.2.4 版开始)最近默认使用版本 5 超级块,并增加了许多新功能,例如元数据 CRC 校验和。版本 5 超级块需要 3.16 或更高版本的内核。此错误很常见,您尝试在不支持 v5 超级块的内核(即版本低于 3.16 的内核)上安装卷。

在较旧的内核中使用较新版本的 xfsprogs 时要小心。您必须使用这些选项来创建 v4 文件系统:

mkfs.xfs -m crc=0,finobt=0 /your/device

请注意,finobt 选项可能不是必需的。

另一方面,如果您需要检查或修复文件系统,最好使用最新的 xfsprogs 版本。因此,我建议使用尽可能高版本的 xfsprogs,但需要注意的是,在创建新文件系统时,您可能需要使用上一个命令行,以确保它与正在运行的内核兼容。

有关 RH/CentOS 7.x 的其他信息

有一个例外:RedHat/CentOS v. 7.x 提供了支持 XFS v5 的版本 xfsprogs,并且它们的内核(尽管默认版本假装是 3.10.x)也支持 XFS v5。

但是 RH/CentOS 的 mkfs.xfs 已修补为默认 XFS v4。因此,如果您运行的是 RedHat/CentOS v7.x,您可能需要使用

mkfs.xfs -m crc=1,finobt=1 /your/device

以利用新功能。

相关内容