ubifs



内核选中ubi支持(ubifs也要选择):

<M> Enable UBI
(4096) UBI wear-leveling threshold (NEW)
(1) Percentage of reserved eraseblocks for bad eraseblocks handling (NEW)
< > MTD devices emulation driver (gluebi) (NEW)
*** UBI debugging options ***



mkfs.ubifs -h
Usage: mkfs.ubifs [OPTIONS] target
Make a UBIFS file system image from an existing directory tree

Examples:
Build file system from directory /opt/img, writting the result in the ubifs.img file
mkfs.ubifs -m 512 -e 128KiB -c 100 -r /opt/img ubifs.img
The same, but writting directly to an UBI volume
mkfs.ubifs -r /opt/img /dev/ubi0_0
Creating an empty UBIFS filesystem on an UBI volume
mkfs.ubifs /dev/ubi0_0

Options:
-r, -d, --root=DIR build file system from directory DIR
-m, --min-io-size=SIZE minimum I/O unit size
-e, --leb-size=SIZE logical erase block size
-c, --max-leb-cnt=COUNT maximum logical erase block count
-o, --output=FILE output to FILE
-j, --jrn-size=SIZE journal size
-R, --reserved=SIZE how much space should be reserved for the super-user
-x, --compr=TYPE compression type - "lzo", "favor_lzo", "zlib" or
"none" (default: "lzo")
-X, --favor-percent may only be used with favor LZO compression and defines
how many percent better zlib should compress to make
mkfs.ubifs use zlib instead of LZO (default 20%)
-f, --fanout=NUM fanout NUM (default: 8)
-k, --keyhash=TYPE key hash type - "r5" or "test" (default: "r5")
-p, --orph-lebs=COUNT count of erase blocks for orphans (default: 1)
-D, --devtable=FILE use device table FILE
-U, --squash-uids squash owners making all files owned by root
-l, --log-lebs=COUNT count of erase blocks for the log (used only for
debugging)
-v, --verbose verbose operation
-V, --version display version information
-g, --debug=LEVEL display debug information (0 - none, 1 - statistics,
2 - files, 3 - more details)
-h, --help display this help text

Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,
Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.

If you specify "lzo" or "zlib" compressors, mkfs.ubifs will use this compressor
for all data. The "none" disables any data compression. The "favor_lzo" is not
really a separate compressor. It is just a method of combining "lzo" and "zlib"
compressors. Namely, mkfs.ubifs tries to compress data with both "lzo" and "zlib"
compressors, then it compares which compressor is better. If "zlib" compresses 20
or more percent better than "lzo", mkfs.ubifs chooses "lzo", otherwise it chooses
"zlib". The "--favor-percent" may specify arbitrary threshold instead of the
default 20%.

The -R parameter specifies amount of bytes reserved for the super-user.



UBI生成脚本:

# pagesize 2K = 2048 byte
Page=2048
# block size 128k = 131072 byte
Block=131072
# partition size = 10Mib
#14M
Partition=$((14*1024*1024))

#parameters : e
e=$(($Block-2*$Page))
#parameters : c
c=$(($Partition/$e))

# -e 128k-2*2048bytes=126976bytes -m 2048 ,-c=(10Mib/126976bytes)取整。

echo $Partition $e $c

mkfs.ubifs -r rootfs_small -m 2KiB -e 124KiB -c $c -o ./rootfs.ubifs.img
ubinize -o rootfs.ubi.img -m 2KiB -s 512 -p 128KiB cfg/rootfs.conf
#delete the tmp file
rm -f ./rootfs.ubifs.img
cp -v rootfs.ubi.img /nfs

配置文件
[rootfs]
# Volume mode (other option is static)
mode=ubi
# Source image
image=rootfs.ubifs.img
# 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
vol_size=14MiB


tftp 0x80700000 rootfs.ubi.img
引导问题

[ 2.900000] UBI: attaching mtd3 to ubi0
[ 2.900000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 2.910000] UBI: logical eraseblock size: 129024 bytes
[ 2.920000] UBI: smallest flash I/O unit: 2048
[ 2.920000] UBI: sub-page size: 512
[ 2.930000] UBI: VID header offset: 512 (aligned 512)
[ 2.930000] UBI: data offset: 2048
[ 2.990000] UBI warning: ubi_scan: 54 PEBs are corrupted
[ 3.000000] corrupted PEBs are: 56 57 58 59 60 61 62 63 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
[ 3.030000] UBI error: vtbl_check: volume table check failed: record 0, error 9
[ 3.030000] UBI error: ubi_init: cannot attach mtd3
[ 3.040000] UBI error: ubi_init: UBI error: cannot initialize UBI, error -22


[ 5.110000] UBIFS error (pid 1): ubifs_get_sb: cannot open "ubi0:rootfs", error -19
[ 5.110000] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 5.120000] Please append a correct "root=" boot option; here are the available partitions:
[ 5.130000] 1f00 512 mtdblock0 (driver?)
[ 5.140000] 1f01 512 mtdblock1 (driver?)
[ 5.140000] 1f02 3072 mtdblock2 (driver?)
[ 5.150000] 1f03 14336 mtdblock3 (driver?)
[ 5.150000] 1f04 1024 mtdblock4 (driver?)
[ 5.160000] 1f05 40960 mtdblock5 (driver?)
[ 5.160000] 1f06 4096 mtdblock6 (driver?)
[ 5.170000] 1f07 66560 mtdblock7 (driver?)
[ 5.170000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 5.180000] Backtrace:
[ 5.180000] [<c008d5f4>] (dump_backtrace+0x0/0x114) from [<c03bbe3c>] (dump_stack+0x18/0x1c)
[ 5.190000] r7:00008001 r6:c4015000 r5:c0027808 r4:c04f09b0
[ 5.200000] [<c03bbe24>] (dump_stack+0x0/0x1c) from [<c03bbe94>] (panic+0x54/0x12c)
[ 5.200000] [<c03bbe40>] (panic+0x0/0x12c) from [<c0008fbc>] (mount_block_root+0x1e0/0x220)
[ 5.210000] r3:00000001 r2:c4023eb0 r1:c4023f78 r0:c04566e6
[ 5.220000] [<c0008ddc>] (mount_block_root+0x0/0x220) from [<c000918c>] (prepare_namespace+0x94/0x1c8)
[ 5.230000] r8:00000000 r7:00000000 r6:00000000 r5:c0027808 r4:c0027818
[ 5.240000] [<c00090f8>] (prepare_namespace+0x0/0x1c8) from [<c00084bc>] (kernel_init+0xe4/0x118)
[ 5.240000] r5:00000000 r4:c04f0280
[ 5.250000] [<c00083d8>] (kernel_init+0x0/0x118) from [<c00a1d88>] (do_exit+0x0/0x668)
[ 5.260000] r5:00000000 r4:00000000


错误原因估计是corrupted PEBs,但是网上找不到相关信息

/ # ubimkvol /dev/ubi0 -n 0 -N rootfs -s 4096MiB
ubimkvol: error!: UBI is not present in the system


/ # ubimkvol /dev/ubi0 -n 0 -N rootfs -s 40MiB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值