安装:在 /mnt/sda2 上安装 /dev/sda2 失败:参数无效

Eri*_*Ven 4 ext4 mount dd-wrt

我正在关注这个教程。但我卡在了第 9 步,不知何故我无法安装我的 USB。

每次我尝试安装 USB 时都会收到以下错误:

root@OpenWrt:~# mount /dev/sda2 /mnt/sda2
mount: mounting /dev/sda2 on /mnt/sda2 failed: Invalid argument
Run Code Online (Sandbox Code Playgroud)

USB 似乎正常并已连接,但不知何故我无法安装 sda2 (ext4) 分区。

分区似乎也没有问题:

root@OpenWrt:~# blkid
/dev/mtdblock2: TYPE="squashfs"
/dev/sda1: UUID="e39964e8-1b51-4b1f-b034-0147fa394eea" TYPE="swap"
/dev/sda2: UUID="157cfc0d-f33d-4103-950d-6ae01baa7177" TYPE="ext4"
Run Code Online (Sandbox Code Playgroud)

这是我的dmesg输出:

root@OpenWrt:~# dmesg | grep sda
[    9.360000] sd 0:0:0:0: [sda] 7987200 512-byte logical blocks: (4.08 GB/3.80 GiB)
[    9.370000] sd 0:0:0:0: [sda] Write Protect is off
[    9.370000] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[    9.370000] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[    9.400000]  sda: sda1 sda2
[    9.410000] sd 0:0:0:0: [sda] Attached SCSI removable disk
[   41.850000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
[   41.870000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities
[   41.880000] EXT4-fs (sda2): couldn't mount RDWR because of unsupported optional features (400)
[  270.660000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
[  270.670000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities
[  270.670000] EXT4-fs (sda2): couldn't mount RDWR because of unsupported optional features (400)
[  585.040000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
[  585.050000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities
[  585.060000] EXT4-fs (sda2): couldn't mount RDWR because of unsupported optional features (400)
[  586.540000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
[  586.550000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities
[  586.560000] EXT4-fs (sda2): couldn't mount RDWR because of unsupported optional features (400)
[  651.570000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
[  651.580000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities
[  651.590000] EXT4-fs (sda2): couldn't mount RDWR because of unsupported optional features (400)
Run Code Online (Sandbox Code Playgroud)

这是我的fdisk -l输出:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 4089 MB, 4089446400 bytes
255 heads, 63 sectors/track, 497 cylinders, total 7987200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1     7987199     3993599+  ee  GPT
Run Code Online (Sandbox Code Playgroud)

tel*_*coM 6

错误消息来自以下行<Linux kernel source code>/fs/ext4/super.c

        if (ext4_has_unknown_ext4_ro_compat_features(sb)) {
            ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
                     "unsupported optional features (%x)",
                     (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) &
                            ~EXT4_FEATURE_RO_COMPAT_SUPP));
Run Code Online (Sandbox Code Playgroud)

错误消息中的数字的占位符是%x,因此实际错误消息中的数字 400 是十六进制的 0x400。如果特征由EXT4_FEATURE_RO_COMPAT_常量识别,则它是一种。

这些常量的定义可以在<Linux kernel source code>/fs/ext4/ext4.h

#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM    0x0400
Run Code Online (Sandbox Code Playgroud)

dir_nlinksourcejedi提到的特征是0x20,而不是0x400 :

#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK        0x0020
Run Code Online (Sandbox Code Playgroud)

因此,MR3020 无法以读/写模式挂载文件系统,因为其操作系统无法处理 ext4 元数据校验和。因此,您需要使用用于创建 USB 记忆棒的 Linux 系统关闭该功能。将 USB 记忆棒移回该系统(不要挂载 ext4 文件系统)并运行:

tune2fs -O^metadata_csum /dev/sdX2
Run Code Online (Sandbox Code Playgroud)

(将 X 替换为 Linux 系统中 USB 记忆棒的实际标识符。)

成功运行此命令后,该metadata_csum功能将在 USB 记忆棒的 ext4 文件系统中被禁用,并且 MR3020 现在应该能够使用它。