ubifslinux挂载根文件系统统挂载失败,该怎么处理

UBIFS文件系统(含如何制作mtd工具集走指引)
介绍UBIFS文件系统,鄙人已经亲身制作并使用的ti DM3730
linux平台上。ubifs文件系统挂载速度相对快,相比其他类型文件系统,综合性能狠强啊,不过鄙人实践及官方也坦白一个事实,就是ubifs文件系统对系统异常/突然掉电的容忍性不好,数据可能会严重损坏。
refer to :
&&&&&&&&&&
中文介绍:
----------------------------
flash sub-pages
前面提到所有的写操作都需要对齐,对于NAND则是针对page大小,虽然有些SLC的flash允许更小的单位,在MTD这一层我们称之为sub-pages,并不是所有的NAND都有sub-pages
MLC NANDs do not have sub-pages, at least
to the date of writing of this piece of documentation (April
SLC NANDs usually do have sub-pages.
E.g., 512-byte NAND pages usually consist of 2x256-byte sub-pages,
and 2048-byte NAND pages consist of 4x512-byte
sub-pages.
SLC OneNAND chips with 2048 bytes NAND
page size have 4x512-byte sub-pages.
比如,对于128KiB的block大小,2048-byte
page的flash,如果没有sub-pages,EC header 存于第一个page,VID
header存储于2048偏移处,LEB大小为128KiB-4KiB。如果有sub-pages,那么EC
header存储于第一个sub-page,VID
header存储于512偏移处(第二个sub-page),LEB大小变为128KiB-KiB
in case of NOR flash which has 1 byte
min. I/O unit, the VID header resides at offset 64;
in case of NAND flash which does not have
sub-pages, the VID header resides at the second NAND
in case of NAND flash which has
sub-pages, the VID header resides at the second
Sub-pages只是UBI内部用于存储头信息,UBI的API不允许用户访问sub-pages,因为为了写一个sub-page的数据,驱动需要对整个page做写操作,比如写4个sub-page的时间会4倍于一个page的时间。
----------------------------
UBIFS may be considered as the next generation of the JFFS2
file-system.
JFFS2 file system works on top of MTD devices, but UBIFS works
on top of UBI volumes and cannot operate on top of MTD devices. In
other words, there are 3 subsystems involved:
MTD subsystem, which provides uniform interface to access flash
chips. MTD provides an notion of MTD devices (e.g., /dev/mtd0)
which basically
UBI subsystem, which is a wear-leveling and volume management
syst UBI works on top of MTD devices and
provides a notion of UBI UBI volumes are higher level
entities than MTD devices and they are devoid of many unpleasant
issues MTD devices have (e.g., wearing and bad blocks); see here
UBIFS file system, which works on top of UBI volumes.
For more information on MTD, refer
&&A class="external free"
href="http://www.linux-mtd.infradead.org/doc/general.html"
rel=nofollow
target=_blank&http://www.linux-mtd.infradead.org/doc/general.html&
For more information on UBI, refer
&&A class="external free"
href="http://www.linux-mtd.infradead.org/doc/ubi.html" rel=nofollow
target=_blank&http://www.linux-mtd.infradead.org/doc/ubi.html&
For more information on UBIFS, refer
&&A class="external free"
href="http://www.linux-mtd.infradead.org/doc/ubifs.html"
rel=nofollow
target=_blank&http://www.linux-mtd.infradead.org/doc/ubifs.html&
UBIFS User-space tools
UBI user-space tools, as well as other MTD user-space tools, are
available from the the following git repository:
git://git.infradead.org/mtd-utils.git
The repository contains the following UBI tools:
ubinfo - provides information about UBI devices and volumes
ubiattach - attaches MTD devices (which describe raw flash) to UBI and creates corresponding UBI
ubidetach - detaches MTD devices from UBI devices (the opposite to what ubiattach does);
ubimkvol - creates UBI volumes on UBI
ubirmvol - removes UBI volumes from UBI
ubiupdatevol - updates UBI this tool uses the UBI volume update feature which leaves the volume in
"corrupted" state if the up additionally, this tool may be used to wipe
ubicrc32 - calculates CRC-32 checksum of a file with the same initial seed as UBI
ubinize - generates UBI
ubiformat - formats empty flash, erases flash and preserves erase counters, flashes UBI images to MTD
mtdinfo - reports information about MTD devices found in the system.
All UBI tools support "-h" option and print sufficient usage
information.
UBIFS Implementation
The UBIFS file system is supported with 8-bit BCH ECC scheme by
default. The 8-bit BCH ECC scheme is aligned across ROM, U-boot and
Both UBIFS and 8-bit BCH scheme are enabled in the Uboot and
Kernel by default.
Configuration
Note: The following configuration is enabled in the kernel by
To enable UBIFS support, start the Linux Kernel
Configuration tool:
$ make menuconfig
Select Device Drivers from the main menu.
Power management options ---&
[ ] Networking support ---&
Device Drivers ---&
Select Memory Technology Device (MTD) Supportas shown
& & Connector - unified userspace &-& kernelspace linker
&*& Memory Technology Device (MTD) support
& & Parallel port support
Select Enable UBI - Unsorted block images as shown
&*& Enable UBI - Unsorted block images
Select Device Drivers from the main menu.
Power management options ---&
[ ] Networking support ---&
Device Drivers ---&
Select Memory Technology Device (MTD) Supportas shown
& & Connector - unified userspace &-& kernelspace linker
&*& Memory Technology Device (MTD) support
& & Parallel port support
Select NAND Device Support as shown here:
[ ] NAND ECC Smart Media byte order
&*& NAND Device Support
Deselect Verify NAND page writes from the main menu.
[ ] Verify NAND page writes
Select File Systems from the main menu.
Device Drivers ---&
File systems
Select Miscellaneous filesystemsas shown
Pseudo filesystems
[*] Miscellaneous filesystems
[*] Network File Systems
Select UBIFS file system support' as shown
&*& UBIFS file system support
[ ] Extended attributes support
[ ] Advanced compression options
[ ] Enable debugging support
Compilling UBIFS Tools
The MTD and UBI user-space tools are available from the the
following git repository:
git://git.infradead.org/mtd-utils.git
As of writing this wiki, the mtd-utils version is 1.4.8.
For instructions on compiling MTD-utils, refer .
Creating UBIFS file system
From information on how to create a UBIFS image. refer
mkfs.ubifs
mtd-utils# mkfs.ubifs/mkfs.ubifs -r filesystem/ -F -o ubifs.img -m 2048 -e 126976 -c 1580
-m 2KiB (or 2048)The minimum I/O size
of the underlying UBI and MTD devices. In our case, we are running
the flash with no sub-page writes, so this is a 2KiB
page.-e 124KiB (or 126976)
Erase Block Size: UBI requires 2 minimum I/O units out of each
Physical Erase Block (PEB) for overhead: 1 for maintaining erase
count information, and 1 for maintaining the Volume ID information.
The PEB size for the XO flash is 128KiB, so this leads to each
Logical Erase Block (LEB) having 124KiB available for data.
The maximum size, in LEBs, of this file system. See calculation
below for how this number is determined.
-r filesystem
Use the contents of the 'filesystem/' directory to generate the
initial file system image.
File-system free space has to be fixed up on first mount
-o ubifs.img
Output file.
On AM335x, -F option is required when creating ubifs image. If
this option is not used, Kernel may crash while loading the
Filesystem from UBI partition.
The output of the above command, ubifs.img is fed into
the 'ubinize' program to wrap it into a UBI image.
The images produced by mkfs.ubifs must be further fed to the ubinize tool to create a UBI image which must be put to the raw flash to be used a UBI partition.
Create ubinize.cfg file and write the contents into
mtd-utils# vi ubinize.cfg
&== Section header
&== Volume mode (other option is static)
image=ubifs.img
&== Source image
&== Volume ID in UBI image
vol_size=192MiB
&== Volume size
vol_type=dynamic
&== Allow for dynamic resize
vol_name=rootfs
&== Volume name
vol_flags=autoresize
&== Autoresize volume at first mount
[See calculations below to determine the value associated with
'vol_size']
mtd-utils# ubi-utils/ubinize -o ubi.img -m 2048 -p 128KiB -s 512 -O 2048 ubinize.cfg
-o ubi.img
Output file
-m 2KiB (or 2048)
Minimum flash I/O size of 2KiB page
Size of the physical eraseblock of the flash this UBI image is
created for
-O 2048 offset if the VID header from start of the
physical eraseblock
The output of the above command, 'ubi.img' is the
required image.
Calculations
Usable Size Calculation
As documented , UBI reserves a certain amount of space
for management and bad PEB handling operations. Specifically:
2 PEBs are used to store the UBI volume table
1 PEB is reserved for wear-
1 PEB is reserved for the atomic LEB
a % of PEBs is reserved for handling bad EBs. The default for
NAND is 1%
UBI stores the erase counter (EC) and volume ID (VID) headers
at the beginning of each PEB. 1 min I/O unit is required for each
To calculate the full overhead, we need the following
Value for XO test case
128KiB - 2 * 2KiB = 124 KiB
Total number of PEBs on the MTD device
200MiB / 128KiB = 1600
Number of PEBs reserved for bad PEB handling
1% of P = 16
The overhead related to storing EC and VID headers in bytes,
i.e. O = SP - SL
UBI Overhead = (B + 4) * SP + O * (P - B - 4)
= (16 + 4) * 128Kib + 4 KiB * (1600 - 16 - 4)
= 8880 KiB
= 69.375 PEBs (round to 69)
This leaves us with 1531 PEBs or 195968KiB available for user
Note that we used "-c 1580" in the above mkfs.ubifs command line
to specify the maximum filesystem size, not "-c 1531" The reason
for this is that mkfs.ubifs operates in terms of LEB size (124
KiB), not PEB size (128Kib). 195968KiB / 124 Kib = 1580.39 (round
Volume size = 195968KiB (~192MiB)
Using UBIFS file system
Preparing NAND partition
Kindly erase the NAND partition before using it for UBI file
system. The partition can be erased from either u-boot or from
Follow below steps to erase.
From U-boot. Assuming NAND partition to be erased starts from
"0x780000" and is of size "0xF880000".
u-boot# nand erase 0xxF880000
From Linux. Assuming MTD partition 7 needs to be erased and
used for UBI file system.
root@arago-armv7:~# flash_eraseall /dev/mtd7
Flashing UBIFS image to a NAND
We can Flash UBIFS image from either Linux Kernel or U-Boot.
Follow steps mentioned
to create an UBIFS image.
From U-Boot,
Get the UBIFS image to U-Boot from tftp or MMC/SD or UART. Lets
consider an example of MMC card.
Since we copy the data to NAND, Empty/Erase the required RAM.
Then, get the UBIFS image to U-Boot
u-boot# mw.b 0xxFF
&=== filesystem image size is upward aligned to NAND block size,
This is required to get rid of "Empty Flash" JFFS2 during kernel boot.
u-boot# mmc rescan
u-boot# fatload mmc 0 0x ubi.img
Next, erase the and flash the UBIFS image to correct NAND
partition.
On flashing UBIFS image from U-Boot, make sure that ECC selected is
in sync with Linux
NAND partition to be erased starts from "0x780000",
NAND partition of size "0xF880000" and
File system image size to be flashed is 0xFC0000 which is
upward aligned to NAND block size
u-boot# nand erase 0xxF880000
u-boot# nand write 0xxxFC0000
From Linux,
Flash the UBI file system image (ubi.img) to MTD partition
ubiformat /dev/mtd -f ubi.img -s
Here subpage size depends MTD driver. Find subpage size of MTD
partition using
mtdinfo /dev/mtd
Assuming 7th mtd partition with 2048 byte subpage size,
we can use the following command to flash the ubifs image to
partition 7.
#ubiformat /dev/mtd7 -f ubi.img -s 2048 -O 2048
Using UBIFS image as root file system
Set up the bootargs environment variable as below to use the
UBIFS file system image present in a MTD partition:
setenv bootargs 'console=ttyO0, noinitrd ip=off mem=256M rootwait=1 rw ubi.mtd=X,YYYY rootfstype=ubifs root=ubi0:rootfs init=/init'
Where X is the MTD partition number being used for file system
and YYYY is the NAND page size. make sure that an UBI file system
is flashed into this partition before passing it as a boot
partition for Linux.
Assuming 7th mtd partition,
#setenv bootargs 'console=ttyO0, noinitrd ip=off mem=256M rootwait=1 rw ubi.mtd=7,2048 rootfstype=ubifs root=ubi0:rootfs init=/init'
On booting with UBIFS as rootfs, the first boot happens
successfully. Before subsequent boot-ups, it is recommended to do a
manual "sync" from the console. This allows UBIFS meta data
properly updated on the partition. This initial sync will help
later recovery.
Mounting UBIFS image as a regular NAND
Assuming UBIFS image is already flashed to a NAND Partition,
follow below steps to mount the same.
Attach MTD device to UBI
ubiattach /dev/ubi_ctrl -m
Where "X" is the MTD partition number
Mtd device number 7 can be attached to ubi
#ubiattach /dev/ubi_ctrl -m 7 -O 2048
Mount the UBIFS image
mount -t ubifs ubiX:NAME /mount/point
Where "X" - UBI device number and "NAME" - UBI volume name from
ubinize.cfg file.
Assuming ubi device 0 and rootfs is the volume
name given in ubinize.cfg, ubifs image can be mounted to
/media/card using
#mount -t ubifs ubi0:rootfs /media/card
On mounting UBIFS as regular partition, it is recommended to do a
manual "sync" from the console after mounting. This allows UBIFS
meta data properly updated on the partition. This initial sync will
help later recovery.
Mounting a NAND partition using UBIFS
We can mount a particular NAND partition with UBIFS file system
in the following way
Format and attach the MTD partition
ubiformat /dev/mtd -s
ubiattach /dev/ubi_ctrl -m
Where "X" is the MTD partition number and "subpagesize"
determined using mtdinfo command
MTD partition number 7 with 2048 subpage size can be formatted
and attched using
ubiformat /dev/mtd7 -s 2048 -O 2048
#ubiattach /dev/ubi_ctrl -m 7 -O 2048
Create an UBI volume - the created volume will be empty
ubimkvol /dev/ubi0 -N
Where "XX" is the size of the partition to be mounted and
"label" is the name for the volume.
10 MB ubi volume can be created with label
ubifs_volume as
ubimkvol /dev/ubi0 -N ubifs_volume -s 10MiB
Also, user can create a UBI volume with volume size set to
maximum available size
ubimkvol /dev/ubi0 -N
where "label" is the name for the volume.
ubimkvol /dev/ubi0 -N ubifs_volume &m
Mount the MTD partition
mount -t ubifs ubi0: /mount/point
Make sure that the "label" used during ubimkvol is passed as an
argument here.
Mounting of ubi volume can be achieved using
#mount -t ubifs ubi0:ubifs_volume /media/card
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。UBIFS文件系统
我的图书馆
UBIFS文件系统
UBIFS&本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来吧!无序区块镜像文件系统(Unsorted Block Image File System, UBIFS)是用于固态存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一。简介真正开发于2007年,并于2008年10月第一次加入稳定版本于Linux核心2.6.27版。2006年,UBIFS由IBM与的工程师Thomas Gleixner,Artem Bityutskiy所设计,专门为了解决MTD(Memory Technology Device)设备所遇到的瓶颈。由于Nand Flash容量的暴涨,等皆无法操控大的Nand Flash空间。UBIFS通过子系统UBI处理与MTD device之间的动作。与JFFS2一样,UBIFS 建构于MTD device 之上,因而与一般的block device不兼容。UBIFS在设计与性能上均较、更适合MLC NAND FLASH。[1]例如:UBIFS 支持 凑数(write-back), 其写入的数据会被缓存起来, 直到有必要写入时才写到flash, 这样大大降低分散小区块数量,并提高读写效率。UBIFS文件系统目录存储在flash上,UBIFS 挂载时不需要扫描整个存储器来重新创建文件目录。支持实时压缩,而且可选择性压缩部份文件。另外UBIFS使用日志(journal),可减少对flash index的更新频率。UBIFS 目前是&&智能手机上的默认文件系统。==============================================================
TA的最新馆藏
喜欢该文的人也喜欢安全检查中...
请打开浏览器的javascript,然后刷新浏览器
< 浏览器安全检查中...
还剩 5 秒&您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
ubifs文件系统挂载及同步.docx 12页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
&#xe600;下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
需要金币:150 &&
ubifs文件系统挂载及同步
你可能关注的文档:
··········
··········
UBIFS分区制作及UBIFS烧写和启动 (转载)相关命令工具ubiattach?version?1.0?-?a?tool?to?attach?MTD?device?to?UBI.Usage:?ubiattach??&UBI?control?device?node?file?name&?[-m?&MTD?device?number&]?[-d?&UBI?device?number&][--mtdn=&MTD?device?number&]?[--devn?&UBI?device?number&]Example?1:?ubiattach?/dev/ubi_ctrl?-m?0?-?attach?MTD?device?0?(mtd0)?to?UBIExample?2:?ubiattach?/dev/ubi_ctrl?-m?0?-d?3?-?attach?MTD?device?0?(mtd0)?to?UBI?andand?create?UBI?device?number?3?(ubi3)-d,?--devn=&UBI?device?number&??the?number?to?assign?to?the?newly?created?UBI???????device(the?number?is?assigned?automatically?if?this?is?not?specified)-m,?--mtdn=&MTD?device?number&??MTD?device?number?to?attach-O,?--vid-hdr-offset????????????VID?header?offset?(do?not?specify?this?unless?you?really?know?what?you?do?and?the?optimal?defaults?will?be?used)-h,?--help??????????????????????print?help?message-V,?--version???????????????????print?program?versionubimkvol?version?1.0?-?a?tool?to?create?UBI?volumes.Usage:?ubimkvol?&UBI?device?node?file?name&?[-h]?[-a?&alignment&]?[-n?&volume?ID&]?[-N?&name&]?[-s?&bytes&]?[-S?&LEBs&]?[-t?&static|dynamic&]?[-V]?[-m]?[--alignment=&alignment&][--vol_id=&volume?ID&]?[--name=&name&]?[--size=&bytes&]?[--lebs=&LEBs&]?[--type=&static|dynamic&]?[--help]?[--version]?[--maxavsize]Example:?ubimkvol/dev/ubi0?-s?20MiB?-N?config_data?-?create?a?20?Megabytes?volumenamed?&config_data&?on?UBI?device?/dev/ubi0.-a,?--alignment=&alignment&???volume?alignment?(default?is?1)-n,?--vol_id=&volume?ID&??????UBI?volume?ID,?if?not?specified,?the?volume?IDwill?be?assigned?automatically-N,?--name=&name&?????????????volume?name-s,?--size=&bytes&????????????volume?size?volume?size?in?bytes,?kilobytes?(KiB)or?megabytes?(MiB)-S,?--lebs=&LEBs?count&???????alternative?way?to?give?volume?size?in?logicaleraseblocks-m,?--maxavsize???????????????set?volume?size?to?maximum?
正在加载中,请稍后...}

我要回帖

更多关于 linux挂载根文件系统 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信