1、准备一张TF卡启动盘,将核心板设为从TF卡启动

2、从TF卡启动后,确认文件系统位置

Target
root@phyboard-wega-am335x-1:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00020000 "xload"
mtd1: 00020000 00020000 "xload_backup1"
mtd2: 00020000 00020000 "xload_backup2"
mtd3: 00020000 00020000 "xload_backup3"
mtd4: 00080000 00020000 "barebox"
mtd5: 00080000 00020000 "barebox_backup"
mtd6: 00040000 00020000 "bareboxenv"
mtd7: 07e40000 00020000 "root"

经确认,mtd7为文件系统所在位置。

3、为ubi分区建立链接

Target
root@phyboard-wega-am335x-1:~# ubiattach -p /dev/mtd7
[   68.899327] ubi0: default fastmap pool size: 50
[   68.904339] ubi0: default fastmap WL pool size: 25
[   68.909384] ubi0: attaching mtd7
[   69.223429] ubi0: scanning is finished
[   69.252200] ubi0: attached mtd7 (name "root", size 126 MiB)
[   69.258063] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[   69.265345] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[   69.272411] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[   69.279521] ubi0: good PEBs: 1010, bad PEBs: 0, corrupted PEBs: 0
[   69.285924] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
[   69.293519] ubi0: max/mean erase counter: 5/1, WL threshold: 4096, image sequence number: 17740
[   69.302650] ubi0: available PEBs: 0, total reserved PEBs: 1010, PEBs reserved for bad PEB handling: 20
[   69.315121] ubi0: background thread "ubi_bgt0d" started, PID 226
UBI device number 0, total 1010 LEBs (130314240 bytes, 124.2 MiB), available 0 LEBs (0 bytes), LEB size 129024 bytes (126.0 KiB)

从以上信息可知,mtd7被链接到了ubi0。


以下是ubi0信息:

Target
root@phyboard-wega-am335x-1:~# ubinfo /dev/ubi0
ubi0
Volumes count:                           3
Logical eraseblock size:                 129024 bytes, 126.0 KiB
Total amount of logical eraseblocks:     1010 (130314240 bytes, 124.2 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  20
Current maximum erase counter value:     5
Minimum input/output unit size:          2048 bytes
Character device major/minor:            246:0
Present volumes:                         0, 1, 2
root@phyboard-wega-am335x-1:~# ubinfo /dev/ubi0_0
Volume ID:   0 (on ubi0)
Type:        static
Alignment:   1
Size:        66 LEBs (8515584 bytes, 8.1 MiB)
Data bytes:  6544856 bytes (6.2 MiB)
State:       OK
Name:        kernel
Character device major/minor: 246:1
root@phyboard-wega-am335x-1:~# ubinfo /dev/ubi0_1
Volume ID:   1 (on ubi0)
Type:        static
Alignment:   1
Size:        9 LEBs (1161216 bytes, 1.1 MiB)
Data bytes:  42703 bytes (41.7 KiB)
State:       OK
Name:        oftree
Character device major/minor: 246:2
root@phyboard-wega-am335x-1:~# ubinfo /dev/ubi0_2
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        909 LEBs (117282816 bytes, 111.8 MiB)
State:       OK
Name:        root
Character device major/minor: 246:3

从以上信息可知,ubi0_2为文件系统所在位置。

4、挂载ubi文件系统分区

在/mnt下新建子目录/ubi

Target
root@phyboard-wega-am335x-1:~# mkdir /mnt/ubi

将ubi0_2挂载到/mnt/ubi下

Target
root@phyboard-wega-am335x-1:~# mount -t ubifs /dev/ubi0_2 /mnt/ubi/
[  602.169963] UBIFS (ubi0:2): background thread "ubifs_bgt0_2" started, PID 242
[  602.245243] UBIFS (ubi0:2): UBIFS: mounted UBI device 0, volume 2, name "root"
[  602.252968] UBIFS (ubi0:2): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  602.263504] UBIFS (ubi0:2): FS size: 115863552 bytes (110 MiB, 898 LEBs), journal size 9033728 bytes (8 MiB, 71 LEBs)
[  602.274717] UBIFS (ubi0:2): reserved for root: 0 bytes (0 KiB)
[  602.280904] UBIFS (ubi0:2): media format: w4/r0 (latest is w5/r0), UUID A280BFE4-2479-4F2E-A3B7-D2836E73594A, small LPT model
root@phyboard-wega-am335x-1:~# ls /mnt/ubi/
bin    boot   dev    etc    home   lib    media  mnt    proc   run    sbin   srv    sys    tmp    usr    var

5、导出

Target
root@phyboard-wega-am335x-1:~# tar -czvf rootfs.tar.gz /mnt/ubi/

6、将TF卡中rootfs.tar.gz复制到PC上,完成。

  • No labels