Доработка файловой системы на NAND накопителе

Материал из docs.kb-agava.ru
Версия от 16:03, 6 февраля 2023; TaushkanovKV (обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к навигации Перейти к поиску

Форматирование раздела:

root@agava6432_30:~# ubiformat /dev/mtd10 -s 2048 -O 2048
ubiformat: mtd10 (nand), size 33554432 bytes (32.0 MiB), 256 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 255 -- 100 % complete
ubiformat: 256 eraseblocks have valid erase counter, mean value is 3
ubiformat: formatting eraseblock 255 -- 100 % complete

Создание тома на разделе с максимально доступным размером:

root@agava6432_30:~# ubimkvol /dev/ubi1 -N optfs -m
Set volume size to 26918912
Volume ID 0, size 212 LEBs (26918912 bytes, 25.7 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "optfs", alignment 1

Смонтируем два раздела одновременно. Аттач и монтирование первого:

root@agava6432_30:~# ubiattach /dev/ubi_ctrl -m 9 -O 2048
[  155.104000] ubi0: attaching mtd9
[  155.957456] ubi0: scanning is finished
[  155.975810] ubi0: attached mtd9 (name "NAND.file-system", size 214 MiB)
[  155.982484] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  156.024324] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[  156.041109] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[  156.073123] ubi0: good PEBs: 1712, bad PEBs: 0, corrupted PEBs: 0
[  156.089556] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[  156.102847] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1174463929
[  156.114658] ubi0: available PEBs: 0, total reserved PEBs: 1712, PEBs reserved for bad PEB handling: 40
[  156.125597] ubi0: background thread "ubi_bgt0d" started, PID 828
UBI device number 0, total 1712 LEBs (217382912 bytes, 207.3 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
root@agava6432_30:~# mount -t ubifs ubi0:rootfs /media/ram
[  848.465385] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 838
[  848.537802] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  848.545352] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  848.557670] UBIFS (ubi0:0): FS size: 210399232 bytes (200 MiB, 1657 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[  848.569689] UBIFS (ubi0:0): reserved for root: 0 bytes (0 KiB)
[  848.576642] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 13B5E90D-3C04-4CC3-A177-A691A903DAEB, small LPT model

Аттач и монтирование второго:

root@agava6432_30:~# ubiattach /dev/ubi_ctrl -m 10 -O 2048
[  159.661425] ubi1: attaching mtd10
[  159.793666] ubi1: scanning is finished
[  159.808003] ubi1: attached mtd10 (name "NAND.opt-fs", size 32 MiB)
[  159.814239] ubi1: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  159.853010] ubi1: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[  159.869891] ubi1: VID header offset: 2048 (aligned 2048), data offset: 4096
[  159.880333] ubi1: good PEBs: 256, bad PEBs: 0, corrupted PEBs: 0
[  159.887885] ubi1: user volume: 0, internal volumes: 1, max. volumes count: 128
[  159.896402] ubi1: max/mean erase counter: 6/4, WL threshold: 4096, image sequence number: 411538511
[  159.906678] ubi1: available PEBs: 212, total reserved PEBs: 44, PEBs reserved for bad PEB handling: 40
[  159.917388] ubi1: background thread "ubi_bgt1d" started, PID 831
UBI device number 1, total 256 LEBs (32505856 bytes, 31.0 MiB), available 212 LEBs (26918912 bytes, 25.7 MiB), LEB size 126976 bytes (124.0 KiB)
root@agava6432_30:~# mount -t ubifs ubi1:optfs /opt
[  923.223283] UBIFS (ubi1:0): default file-system created
[  923.295157] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 844
[  923.409002] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "optfs"
[  923.422729] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  923.435346] UBIFS (ubi1:0): FS size: 25649152 bytes (24 MiB, 202 LEBs), journal size 1269760 bytes (1 MiB, 10 LEBs)
[  923.446969] UBIFS (ubi1:0): reserved for root: 1211472 bytes (1183 KiB)
[  923.453628] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID B920CD11-CAF7-430F-9199-30BCBA23AC07, small LPT model

Установка параметров rootfs в U-Boot:

setenv nandroot "ubi0:rootfs ro ubi.mtd=NAND.file-system,2048"

Перемонтировать rootfs из режима только чтение в режиме чтение/запись:

mount -o remount,rw /