Embedded file System detailed

Source: Internet
Author: User
Tags garbage collection

In the embedded field, Flash is a common storage device, flash flash memory as the main storage device of embedded system has its own characteristics. Fash Write operations can only modify the corresponding location of 1 to 0, but not the 0 modified to 1, and erase Fash is the corresponding storage block to restore the contents of 1. Therefore, in general, when writing to fash, you need to erase the corresponding storage interval, which is done in blocks (Bock). Flash memory mainly has nor and NAND two kinds of technology. Because the number of flash memory is limited, NAND Flash has a special hardware interface and read and write timing, so there is a special Flash file system. The more commonly used are jffs2,yaffs2,logfs,ubifs. Traditional file systems such as EXT2, EXT3, NTFS, etc. are designed for mechanical hard disk, used as Fash file system will be a lot of drawbacks.


Under Embedded Linux, MTD (memorytechnology Device, storage technology equipment) provides a unified, abstract interface between the underlying hardware (flash) and the upper layer (file system), where the file system of Flash is based on the MTD drive layer. The main advantage of using the MTD driver is that it is specifically designed for a variety of nonvolatile memory (primarily flash memory), so it has better support for Flash, management, and a sector-based erasure, read/write interface. In addition, a flash chip can be divided into multiple partitions, each partition can use a different file system; Two flash chips can also be merged into one partition, using a file system. That is, the file system is for memory partitions, not storage chips. Depending on the storage device, the embedded file system can be divided into three categories: The file system based on flash, the file system based on memory, the file system based on the network.

(i) the file system based on Flash

(1) jffs2:journalling Flash filesystem jffs file system was first developed by the Swedish Axiscommunications company based on the Linux2.0 kernel for embedded system.
JFFS2 (journalling flash filesystem log Flash file System version 2) is the RedHat of David Woodhouse's improved file system based on Jffs, which is the actual file system for the original flash memory chip for micro embedded devices. The JFFS2 file system is a log-structured, writable file system, so JFFS2 can also be used in Linux,uclinux. The advantages and disadvantages of JFFS2 are as follows:
Advantages:
The compressed file format is used. The most important feature is the read-write operation.
Disadvantages:

JFFS2 file system mounts need to scan the entire JFFS2 file system, so when the JFFS2 file system partition increases, the mount time will be correspondingly longer. Using the JFFS2 format may result in a small amount of wasted Flash space. This is mainly due to the excessive overhead of the log files and the useless storage units used to recycle the system, which is roughly a number of data segments. Another disadvantage of JFFS2 is that the JFFS2 runs quickly when the filesystem is full or near full. This is because of the problem of garbage collection. Note:

(1) The log structure file system does not adopt the local updating method, but adopts the method of asynchronous updating, that is, when a block of data needs to be updated, a new block is found to write the new data, and then the old block is erased.     However, the old data is not immediately erased in flash memory, but rather as a log as a historical record, which lays the groundwork for the recovery operation of the file system. (2) is not suitable for NAND flash memory is mainly because the capacity of NAND flash is generally large, which led to the Jffs for maintenance log node occupied by the memory space quickly increased, and the Jffs file system in the mount need to scan the entire Flash content to find all the log nodes, establish the file structure, A large volume of NAND flash will take a lot of time.

(2) Yaffs:yet Another Flash File System
YAFFS/YAFFS2 is an embedded file system designed specifically for NAND Flash. It is the log structure of the file system, providing the loss of balance and power off protection, can effectively avoid accidental power loss on file system consistency and integrity of the impact. Compared with JFFS2, it reduces some features (such as not supporting data compression), so it is faster, has a short mount time, and consumes less memory. It is Cross-platform file system, in addition to Linux and Ecos, but also support wince, PSOs and THREADX.
The advantages and disadvantages of YAFFS/YAFFS2 are as follows:
Advantages:
Specifically for NAND Flash, software structure is optimized, fast.
Use the hardware spare area region to store file organization information, start with only scanning organization information, start faster.
Multi-strategy garbage collection algorithm can improve the efficiency and fairness of garbage collection, and achieve the goal of loss balance.
Disadvantages:

The compressed file format is not in use. YAFFS2 mirror files are larger than JFFS2 mirrored files when the content is the same.Note:
The main difference between yaffs and YAFFS2 is that the former supports only a small page (Bytes) NAND flash, while the latter can support a large page (2KB) NAND flash. At the same time, YAFFS2 in the memory space occupancy, garbage collection speed, read/write speed and so on are greatly improved. Compared with JFFS2, it reduces some features (such as not supporting data compression), so it is faster, has a short mount time, and consumes less memory.

(3) cramfs:compressed ROM File System
Cramfs is a read-only compressed file system that Linux founder Linustorvalds participates in developing. It is also based on the MTD driver. In the Cramfs file system, each page (4KB) is compressed individually, can be random page access, its compression ratio up to 2:1, for the embedded system to save a lot of flash storage space, so that the system can store the same file through a lower volume of flash, thereby reducing system costs.
The Cramfs file system is stored in compression, uncompressed at run time, so the application is not supported to run XIP, all applications require to be cuffed to ram, but that does not mean a little more RAM than the RAMFS requirement. Because Cramfs is to use the way of paging compression file, in reading files, will not consume too much memory space, only for the current actual reading of the partial allocation of memory, not yet read the part does not allocate memory space, when we read the file is not in memory, The Cramfs file system automatically calculates the location of the compressed data and then instantly unzip it into RAM. In addition, it is fast and efficient, its read-only feature is conducive to protect the file system from damage, improve the reliability of the system.
Because of the above characteristics, CRAMFS is widely used in embedded systems.but its read-only attribute is also a major flaw, making it impossible for users to extend their content。 Cramfs images are usually placed in flash, but can also be placed in other file systems, using loopback devices to install it in other file systems.

(4) Romfs
The traditional Romfs file system is a simple, compact, read-only file system that does not support dynamic erase and store data sequentially, thus enabling applications to run in the XIP (EXecute in places, in-chip operation) to save RAM space while the system is running. Uclinux systems typically use Romfs file systems.
Other file systems: Fat/fat32 can also be used for extended storage of real-world embedded systems (such as pda,smartphone, digital cameras, etc.), mainly for better compatibility with Windows desktop operating systems. Ext2 can also be used as an embedded Linux file system, but there are many drawbacks to using it in Flash flash.

(ii) RAM-based file systems

(1) Ramdisk RAMDisk is to use a portion of the fixed size of memory as a partition. It is not an actual file system, but a mechanism for loading the actual filesystem into memory and can be used as the root file system. The performance of the system can be significantly improved by placing some files that are frequently accessed without changing, such as a read-only root file system, in memory through RAMDisk.
In the Linux startup phase, INITRD provides a mechanism to load the kernel image with the root file system in memory.

(2) Ramfs/tmpfs
Ramfs is a memory-based file system developed by Linustorvalds that works on the virtual file system (VFS) layer, cannot be formatted, can create multiple, and can specify the maximum amount of memory it can use at creation time. (In fact, the VFS is essentially a memory file system that unifies the way files are represented in the kernel and buffers the disk File system.) )
The Ramfs/tmpfs file system puts all the files in RAM, so read/write operations occur in RAM, and you can use RAMFS/TMPFS to store some temporary or frequently modified data, such as the/TMP and/var directories, so as to avoid the loss of read and write to flash memory , and also improves the data reading and writing speed.
The difference between R Amfs/tmpfs and traditional ramdisk is that it cannot be formatted, and the file system size can vary with the content of the file contained.
One drawback of TMPFS is that all data is lost when the system reboots.

(iii) Network filesystem NFS (Network File system)

NFS is a technology developed and developed by Sun to share files across a network between different machines and different operating systems. In the development and commissioning stage of embedded Linux system, this technology can be used to build the root file system based on NFS on the host, mount to the embedded device, can easily modify the contents of the root file system.


All of these are based on the storage-device file system (Memory-basedfile system), which can be used as a Linux root file system. In fact, Linux also supports logical or pseudo file systems (logical Orpseudo file system), such as Procfs (proc filesystem), for system Information and DEVFS (device file system) and SYSFS for maintenance of device files.



Reference Documentation:

https://blog.csdn.net/firstlai/article/details/50631278

Http://blog.chinaunix.net/uid-26833883-id-4574720.html








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.