在Linux kernel stack中,block driver負責驅動裝置上的硬體,而file system就是對block drvier下讀取和寫入的指令,所以只要能正確驅動平台上儲存裝置的block drvier,那你可以在此block driver上操作任何一種file system
為了這次的demo,必需再修改arch/arm/plat-s3c24xx/common-smdk.c這個檔案,這次把mtd partition調整為4個partition,最後一個partition放squashfs的image,修改範例如下
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "Boot Agent",
.offset = 0,
.size = SZ_256K,
.mask_flags = MTD_CAP_ROM,
},
[1] = {
.name = "S3C2410 flash partition 1(Kernel)",
.offset = SZ_2M,
.size = SZ_4M,
.mask_flags = MTD_CAP_ROM,
},
[2] = {
.name = "S3C2410 flash partition 2(File system)",
.offset = SZ_8M,
.size = /*SZ_4M*//*SZ_50M*/SZ_8M,
//.mask_flags = 0,
},
[3] = {
.name = "S3C2410 flash partition 3(Other file system)",
.offset = SZ_16M,
.size = SZ_8M,
燒寫完kernel後開機可以從/proc/mtd中得知Linux目前mtd分割區的狀態,接下來我們用flash_eraseall把/dev/mtd3整塊抹掉,並把製作好的squashfs的image燒到/dev/mtd3,簡列步驟如下(mtd utility簡介請參考拙作JFFS2 file system-老而彌堅的檔案系統)
(1)flash_eraseall /dev/mtd3
(2)nandwrite -p /dev/mtd3 squashfs.root
燒錄完成後重新開機,修改uboot的bootargs為mem=64M console=ttySAC0 root=/dev/mtdblock3 rootfstype=squashfs,接著啟動Linux,就會發現Linux的root file system已經變為squashfs
留言