问题:
开发环境:ubuntu18.04
芯片:全志V3S
开发方式:主线Uboot + Bsp 内核 + Buildroot
场景:TF卡烧录uboot+kernel+Buildroot,内核已开启支持ext4格式,但是ext4无法挂载
描述:TF内存大小已经识别到了,第一分区内核启动没问题,第二分区根文件系统无法挂载
[ 1.408987] Waiting for root device /dev/mmcblk0p2...
[ 1.416117] mmc0: new high speed SDHC card at address b368
[ 1.422801] mmcblk0: mmc0:b368 NCard 29.1 GiB
[ 1.429420] mmcblk0: p1 p2
[ 1.433574] mmcblk mmc0:b368: Card claimed for testing.
[ 1.439519] mmc0:b368: NCard 29.1 GiB
[ 1.443958] platform reg-20-cs-dcdc2: Driver reg-20-cs-dcdc2 requests probe deferral
[ 1.452844] *******************sd init ok*******************
[ 1.459429] platform reg-20-cs-dcdc3: Driver reg-20-cs-dcdc3 requests probe deferral
[ 1.468206] platform reg-20-cs-ldo1: Driver reg-20-cs-ldo1 requests probe deferral
[ 1.476889] platform reg-20-cs-ldo2: Driver reg-20-cs-ldo2 requests probe deferral
[ 1.485564] platform reg-20-cs-ldo3: Driver reg-20-cs-ldo3 requests probe deferral
[ 1.494131] platform reg-20-cs-ldo4: Driver reg-20-cs-ldo4 requests probe deferral
[ 1.502809] platform reg-20-cs-ldoio0: Driver reg-20-cs-ldoio0 requests probe deferral
[ 1.521184] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[ 1.531350] EXT4-fs (mmcblk0p2): couldn't mount as ext2 due to feature incompatibilities
[ 1.541544] EXT4-fs (mmcblk0p2): couldn't mount RDWR because of unsupported optional features (400)
[ 1.557801] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,2)
[ 1.567448] Backtrace:
[ 1.570447] [<c00132b0>] (dump_backtrace+0x0/0x104) from [<c034bc58>] (dump_stack+0x18/0x1c)
[ 1.580057] r7:c04a2814 r6:c183d024 r5:c04df9f0 r4:c183d024
[ 1.586980] [<c034bc40>] (dump_stack+0x0/0x1c) from [<c034c024>] (panic+0x78/0x1bc)
[ 1.595731] [<c034bfac>] (panic+0x0/0x1bc) from [<c0476d4c>] (mount_block_root+0x248/0x280)
[ 1.605239] r3:00000000 r2:80000000 r1:c1821f48 r0:c03fbdfe
[ 1.612158] r7:c04a2814
[ 1.615221] [<c0476b04>] (mount_block_root+0x0/0x280) from [<c0476ddc>] (mount_root+0x58/0x6c)
[ 1.625027] [<c0476d84>] (mount_root+0x0/0x6c) from [<c0476f20>] (prepare_namespace+0x130/0x190)
[ 1.635018] r5:c0493dd8 r4:c04de864
[ 1.639368] [<c0476df0>] (prepare_namespace+0x0/0x190) from [<c047696c>] (kernel_init+0x170/0x1b0)
[ 1.649551] r5:00000096 r4:00000008
[ 1.653905] [<c04767fc>] (kernel_init+0x0/0x1b0) from [<c0031df8>] (do_exit+0x0/0x624)
[ 1.662931] r7:00000013
[ 1.665994] Rebooting in 5 seconds..
[ 6.670357] Restarting Linux version 3.4.39 (pjw@pjw-virtual-machine) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #11 Fri Feb 26 16:20:22 CST 2021
原因:
新的操作系统上使用系统自带的 mkfs.ext4 对文件系统进行了格式化,默认会使用一些新的的特性,这些新的特性在旧的系统上是无法使用的,即在旧的内核上不支持。
解决:
sudo fdisk -l # 首先查看电脑上已插入的TF卡的设备号
sudo umount /dev/sdb2 # 卸载已挂载的分区,根据rootfs的分区选择sdb1,还是sdb2
sudo tune2fs -O ^metadata_csum /dev/sdb2
# 执行禁用校验值命令
# tune2fs是调整和查看ext2/ext3/ext4文件系统的文件系统参数的
# 执行后会提示:Please run e2fsck -f on the filesystem.
sudo e2fsck -f -a -v /dev/sdb2
# 按照提示执行 e2fsck 进行磁盘检查
# e2fsck命令是磁盘修复命令。用于检查使用 Linux ext2 档案系统的 partition 是否正常工作。
sudo tune2fs -O ^metadata_csum /dev/sdb2
# 再次执行禁用校验值命令
- 如果执行以上命令有报错,最干脆的办法就是重新分区就可以了。
- 执行完以上命令再启动系统,根文件系统就挂载成功了。
执行日志:
步骤一:
pjw@pjw-virtual-machine:~$ sudo tune2fs -O ^metadata_csum /dev/sdb2
tune2fs 1.44.1 (24-Mar-2018)
This operation requires a freshly checked filesystem.
Please run e2fsck -f on the filesystem.
步骤二:
pjw@pjw-virtual-machine:~$ sudo e2fsck -f -a -v /dev/sdb2
11 个已使用的inode(0.00%,总共 1908736)
0 个不连续的文件(0.0%)
0 个不连续的目录(0.0%)
# 一次/二次/三次链接块数:0/0/0
Extent深度直方图: 3
163855 个已使用的块(2.15%,总共 7624960)
0 个坏块
1 个大文件
0 个普通文件
2 个文件夹
0 个字符设备文件
0 个块设备文件
0 个队列文件
0 个链接
0 个符号链接 (0 个直接符号链接)
0 个套接字文件
------------
2 个文件
步骤三:
pjw@pjw-virtual-machine:~$ sudo tune2fs -O ^metadata_csum /dev/sdb2
tune2fs 1.44.1 (24-Mar-2018)
禁用校验值需要花费一段时间。
无论如何也要继续(或等待 5 秒)?(y,N) y<处理中>