当前位置: 首页 > 工具软件 > SquashFS > 使用案例 >

【Linux】【文件系统】squashfs文件系统挂载失败问题

龚跃
2023-12-01

最近负责将A公司一个比较稳定的代码分支移植到新平台上,新平台中包含了M公司和B公司的代码,这样的一个代码架构方便以后不同公司芯片方案的添加和开发。

在移植的过程中,编译成功后DUT上电,但是出现解压文件系统失败,串口信息:

0.760000] unlzma 632
[    0.760000] unlzma 634
[    0.764000] unlzma 632
[    0.768000] CPU 0 Unable to handle kernel paging request at virtual address c0101f38, epc == 800f02c8, ra == 800f0264
[    0.776000] Oops[#1]:
[    0.776000] Cpu 0
[    0.776000] $ 0   : 00000000 00000000 ffffff38 01000000
[    0.776000] $ 4   : ff0000e0 000000e0 ff000000 000019e3
[    0.776000] $ 8   : 802c0000 00000001 00000001 0000000a

跟进到出错的地方,是kernel中的lib\decompress_unlzma.c中函数unlzma出错,这个函数应该是解压squashfs中的文件。进一步分析原因,发现是制作文件系统使用的压缩方式不一样,在制作文件系统的命令中:

Creating 4.0 filesystem on ../board/model_qca_qca95xx/images/wpa8730v1/ap143-squashfs, block size 1048576.
[===========================================================================================================================================================================================================\] 581/581 100%
Exportable Squashfs 4.0 filesystem, data block size 1048576
        compressed data, compressed metadata, compressed fragments
        duplicates are removed
Filesystem size 3374.85 Kbytes (3.30 Mbytes)
        26.07% of uncompressed filesystem size (12947.50 Kbytes)
Inode table size 5519 bytes (5.39 Kbytes)
        20.41% of uncompressed inode table size (27037 bytes)
Directory table size 8304 bytes (8.11 Kbytes)
        46.53% of uncompressed directory table size (17845 bytes)
Number of duplicate files found 84
Number of inodes 823
Number of files 649
Number of fragments 12
Number of symbolic links  99
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 75
Number of ids (unique uids + gids) 1
Number of uids 1
        root (0)
Number of gids 1
        root (0)

从日志中看到,这里使用了squashfs默认的压缩方式gzib,而squashfs使用lzma压缩的话,信息:

/home/project/plc_platform/board/model_qca_qca95xx/build/../../../util/fakeroot /home/project/plc_platform/board/model_qca_qca95xx/build/../../../util/buildFS_LZ
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on /home/project/plc_platform/board/model_qca_qca95xx/build/../images/wpa8730v1/ap135-squashfs, block size 1048576.
[===========================================================================================================================================================================================================-] 581/581 100%
Exportable Squashfs 4.0 filesystem, lzma compressed, data block size 1048576
        compressed data, compressed metadata, compressed fragments
        duplicates are removed
Filesystem size 3374.96 Kbytes (3.30 Mbytes)
        26.07% of uncompressed filesystem size (12946.99 Kbytes)
Inode table size 5633 bytes (5.50 Kbytes)
        21.26% of uncompressed inode table size (26493 bytes)
Directory table size 8344 bytes (8.15 Kbytes)
        46.70% of uncompressed directory table size (17869 bytes)
Number of duplicate files found 16
Number of inodes 823
Number of files 581
Number of fragments 12
Number of symbolic links  99
Number of device nodes 68
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 75
Number of ids (unique uids + gids) 1


有明显的 lzma compressed标识。

而在kernel的配置中,指定了rootfs的文件系统类型:

CONFIG_CMDLINE="console=ttyS0,115200 root=01:00 rd_start=0x802d0000 rd_size=0x800000 init=/sbin/init mem=64m mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k(uImage),64k(config),64k(radiodata)"

所以导致kernel在解压文件系时使用了lzma的解压方式去解压一个gzib压缩的文件系统,出错。


另外一个挂载失败的现象:

[    0.704000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    0.712000] List of all partitions:
[    0.716000] 1f00             128 mtdblock0 (driver?)
[    0.720000] 1f01            1024 mtdblock1 (driver?)
[    0.724000] 1f02            6976 mtdblock2 (driver?)
[    0.728000] 1f03              64 mtdblock3 (driver?)
[    0.736000] No filesystem could mount root, tried:  squashfs
[    0.740000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)

原因是mtd分区参数中,文件系统是第2个分区(分区从0开始计算),如下:

brw-r--r--    1   31,   0 Mar 28  2016 mtdblock0
brw-r--r--    1   31,   1 Mar 28  2016 mtdblock1
brw-r--r--    1   31,   2 Mar 28  2016 mtdblock2

但是挂载的设备名号 是31:3,错误,应该是31:2.


解决方法:使用squashfs.lzma工具制作文件系统就可以了。

调试过程还有很多值得记录的地方,比如kernel的makefile文件,mtd驱动,升级文件的制作流程等,后续补充。



 类似资料: