squashfs需要一个block device。根据block device的方式,kernel command line配置有两种方式:
ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait
ubi.mtd=rootfs
ubi模块的mtd参数,这个选项,在启动的时候自动attach一个ubi分区,rootfs,指定attach名字为rootfs的mtd分区。
root=mtd:ubi_rootfs
使用ubi_rootfs这个mtd分区作为rootfs的mtd分区。
rootwait
等待root分区或device ok,还有类似的rootdelay
需要开启的内核配置:
CONFIG_MTD_UBI_GLUEBI=y
这个配置是为ubi volume创建mtd partition。没开启这个选项,ubi attach之后,没有对应的mtd分区。
CONFIG_MTD_BLOCK=y
这个配置添加mtd block支持,由于squashfs需要block device,因此需要开启这个选项。开启后,有block device:/dev/mtdblock0
ubi.mtd=rootfs ubi.block=0,ubi_rootfs root=/dev/ubiblock0_1 rootwait
ubi.block=0,ubi_rootfs
ubi模块的block参数,为ubi0的ubi_rootfs分区创建block device。
root=/dev/ubiblock0_1
直接指定root使用的device路径,注意此时devtmpfs会自动挂载。
需要开启的内核配置:
CONFIG_MTD_UBI_BLOCK=y
Read-only block devices on top of UBI volumes
支持ubi block device,开启后,可以手动使用ubiblock命令创建block device。
由于nand flash反对使用 mtd block,因此我们第二种方案。
参考:
https://unix.stackexchange.com/questions/455043/using-squashfs-on-top-of-ubi-as-root-file-system