zoukankan      html  css  js  c++  java
  • ubifs文件系统添加squashfs文件系统,实现文件系统只读,overlay可写的这种方式

    1、内核启用功能

    Device Drivers ->
       Memory Technology Device (MTD) Support ->
          Enable UBI - Unsorted block images ->
             Read-only block devices on top of UBI volume
    CONFIG_SQUASHFS=y
    CONFIG_SQUASHFS_LZO=y
    CONFIG_MTD=y
    CONFIG_MTD_BLOCK=y
    CONFIG_MTD_UBI=y
    CONFIG_UBIFS_FS=y

    2、创建 SquashFS

    mksquashfs rootfs rootfs.squashfs -nopad -noappend -root-owned -b 256k -comp xz -processors 2
     

    3、将rootfs.squashfs + overlay 打包成ubifs镜像文件

       ubinize -o p2002ac-loongson32-ls1b-squashfs-rootfsdata.ubifsze -m 2048 -p 128KiB -s 2048 ubinize-squashfs.cfg

      文件ubinize-squashfs.cfg如下:

    [ubi]
    # Volume mode (other option is static)
    mode=ubi
    # Source image
    #image=p2002ac-loongson32-ls1b-squashfs.ubifs
    image=p2002ac-loongson32-ls1b-root.squashfs
    # Volume ID in UBI image
    vol_id=0
    # Allow for dynamic resize
    vol_type=dynamic
    # Volume name
    vol_name=rootfs
    # Autoresize volume at first mount
    vol_flags=autoresize
    [data]
    mode=ubi
    vol_id=1
    vol_type=dynamic
    vol_name=rootfs_data
    vol_size=8MiB

    4、进行分区的擦除与创建块设备

    ubidetach -p /dev/mtd2
    ubiformat /dev/mtd2
    ubiattach /dev/ubi_ctrl -m 2
    ubimkvol /dev/ubi2 -N ubifs -m
    ubiblock -c /dev/ubi2_0

    创建成功会在/dev下有ubiblock2_0   

    5、分区写入与挂载

    flash_eraseall /dev/mtd2;nandwrite -p /dev/mtd2 /mnt/huangzhigang/p2002ac-loongson32-ls1b-squashfs-rootfsdata.ubifsze

    mount -t squashfs -o ro /dev/ubiblock2_0 /mnt
    挂载成功后会/mnt目录下有文件系统的完整目录,说明系统能正常识别和操作

    6、将分区作为开机的启动分区
    在uboot终端命令写入:

    setenv bootargs 'console=ttyS1,115200 root=/dev/ubiblock2_0 ubi.mtd=1,2048  mtdparts=ls1x-nand:8M(kernel),214M(ubi),32M(web),2M(factory);spi-flash:496k(uboot),16k(env) rootfstype=squashfs  rootflags=sync video=ls1xfb:800x480-16@60 product_id=2'

    boot

    实现作为分区启动,
    系统日志输出, 成功创建启动

    [    3.333705] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    [    3.341459] ehci-platform: EHCI generic platform driver
    [    3.348409] ehci-platform ehci-platform: EHCI Host Controller
    [    3.357008] ehci-platform ehci-platform: new USB bus registered, assigned bus number 1
    [    3.367336] ehci-platform ehci-platform: irq 40, io mem 0x1fe00000
    [    3.386996] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
    [    3.396014] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
    [    3.403280] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    [    3.410958] usb usb1: Product: EHCI Host Controller
    [    3.416263] usb usb1: Manufacturer: Linux 4.14.206 ehci_hcd
    [    3.422276] usb usb1: SerialNumber: ehci-platform
    [    3.432978] hub 1-0:1.0: USB hub found
    [    3.438605] hub 1-0:1.0: 1 port detected
    [    3.453735] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    [    3.461159] ohci-platform: OHCI generic platform driver
    [    3.467557] ohci-platform ohci-platform: Generic Platform OHCI controller
    [    3.477519] ohci-platform ohci-platform: new USB bus registered, assigned bus number 2
    [    3.487408] ohci-platform ohci-platform: irq 41, io mem 0x1fe08000
    [    3.557981] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001
    [    3.565269] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    [    3.572955] usb usb2: Product: Generic Platform OHCI controller
    [    3.579321] usb usb2: Manufacturer: Linux 4.14.206 ohci_hcd
    [    3.585329] usb usb2: SerialNumber: ohci-platform
    [    3.596366] hub 2-0:1.0: USB hub found
    [    3.601989] hub 2-0:1.0: 1 port detected
    [    3.618579] usbcore: registered new interface driver usb-storage
    [    3.644354] rtc-sd2068 0-0032: rtc core: registered sd2068 as rtc0
    [    3.653414] i2c /dev entries driver
    [    3.668185] ls1x-wdt ls1x-wdt: Loongson1 Watchdog driver registered
    [    3.679914] NET: Registered protocol family 17
    [    3.687527] can: controller area network core (rev 20170425 abi 9)
    [    3.695868] NET: Registered protocol family 29
    [    3.720809] ubi0: attaching mtd1
    [    4.785354] ubi0: scanning is finished
    [    4.843524] ubi0: volume 0 ("rootfs") re-sized from 118 to 1601 LEBs
    [    4.859173] ubi0: attached mtd1 (name "ubi", size 214 MiB)
    [    4.865328] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
    [    4.873380] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
    [    4.880853] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
    [    4.888466] ubi0: good PEBs: 1712, bad PEBs: 0, corrupted PEBs: 0
    [    4.895000] ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128
    [    4.902682] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1921414063
    [    4.912499] ubi0: available PEBs: 0, total reserved PEBs: 1712, PEBs reserved for bad PEB handling: 40
    [    4.922353] ubi0: background thread "ubi_bgt0d" started, PID 600
    [    4.941144] block ubiblock0_0: created from ubi0:0(rootfs)
    [    4.955220] ubiblock: device ubiblock0_0 (rootfs) set to be root filesystem
    [    4.973244] rtc-sd2068 0-0032: setting system clock to 2000-01-15 00:31:21 UTC (947896281)
    [    4.997119] UBIFS: parse sync
    [    5.039594] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.
    [    5.056147] Freeing unused kernel memory: 192K
    [    5.066924] This architecture does not have kernel memory protection.
    [    7.975971] init: Console is alive
    [    7.988402] init: - watchdog -
    [    8.837389] kmodloader: loading kernel modules from /etc/modules-boot.d/*
    [    9.039662] softdog: initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
    [    9.127253] sdhci: Secure Digital Host Controller Interface driver
    [    9.143162] sdhci: Copyright(c) Pierre Ossman
    [    9.163311] sdhci-pltfm: SDHCI platform and OF driver helper
    [    9.198641] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    [    9.223629] init: - preinit -
    Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    [   12.968734] random: procd: uninitialized urandom read (4 bytes read)
    [   12.986153] UBIFS (ubi0:1): default file-system created
    [   12.999293] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 641
    [   13.127697] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
    [   13.136013] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
    [   13.146425] UBIFS (ubi0:1): FS size: 7237632 bytes (6 MiB, 57 LEBs), journal size 1015809 bytes (0 MiB, 6 LEBs)
    [   13.156999] UBIFS (ubi0:1): reserved for root: 341850 bytes (333 KiB)
    [   13.163901] UBIFS (ubi0:1): media format: w4/r0 (latest is w5/r0), UUID 68723DFE-84EF-4E8C-88BE-0E803CBE5E80, small LPT model
    [   13.183544] mount_root: overlay filesystem has not been fully initialized yet
    [   13.203230] mount_root: switching to ubifs overlay
    [   13.271372] urandom-seed: Seed file not found (/etc/urandom.seed)
    [   13.712859] procd: - early -
    [   13.716792] procd: - watchdog -
    [   15.621926] procd: - watchdog -
    [   15.629340] procd: - ubus -
    [   16.096778] random: ubusd: uninitialized urandom read (4 bytes read)
    [   16.557844] random: jshn: uninitialized urandom read (4 bytes read)
    [   16.587610] random: ubusd: uninitialized urandom read (4 bytes read)
    [   16.620396] procd: - init -
    [   18.892882] kmodloader: loading kernel modules from /etc/modules.d/*
    [   19.079389] kmodloader: done loading kernel modules from /etc/modules.d/*
    [   19.943121] random: crng init done
    [   19.946683] random: 6 urandom warning(s) missed due to ratelimiting
    [   40.971030] stmmaceth stmmaceth.0 eth0: PTP not supported by HW

    参考链接:

    https://www.cxybb.com/article/qq_15031263/94476655#patch_18  新唐ARM9 NU980 移植OpenWrt LEDE_传琦5858的博客-程序员宝宝
    http://souktha.github.io/misc/squashfs-ubi/   UBI block and read-only NAND FS
    https://www.cxybb.com/article/MengXP/108810071 squashfs重打包和ubi重打包_MengXP的博客-程序员宝宝_squashfs打包

    https://unix.stackexchange.com/questions/455043/using-squashfs-on-top-of-ubi-as-root-file-system Using squashfs on top of ubi as root file system

  • 相关阅读:
    最长回文子串 leetcode
    leetcode Plus one
    n的阶乘末尾有几个0?
    求两数的最大公约数和最小公倍数
    汉诺塔
    求n的阶乘
    svn book
    求斐波那契数列第n项
    判断一个数是否是素数
    <C Traps and Pitfalls>笔记
  • 原文地址:https://www.cnblogs.com/hzijone/p/15180878.html
Copyright © 2011-2022 走看看