Comparison of file systems in Embedded Systems

Source: Internet
Author: User

Linux supports multiple file systems, including ext2, ext3, vfat, NTFS, iso9660, jffs, romfs, and NFS. to centrally manage various file systems, linux introduces Virtual File System (VFS), which provides a unified operation interface and Application Programming Interface for various file systems.

    

During Linux Startup, the first file system must be mounted. If the system cannot mount the root file system from a specified device, the system will exit the startup due to an error. You can then automatically or manually Mount other file systems. Therefore, different file systems can exist in a system at the same time.

    
Different file system types have different characteristics, so there are different application scenarios based on the hardware characteristics and system requirements of storage devices. In Embedded Linux applications, the main storage devices are Ram (DRAM, SDRAM) and Rom (flash memory is often used). Commonly Used file system types based on storage devices include: jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/tmpfs, etc.

1. Flash-based File System

As the main storage medium of embedded systems, flash memory has its own characteristics. The Flash write operation can only change 1 of the corresponding position to 0, but not 0 to 1 (flash erased restores the content of the corresponding storage block to 1). Therefore, generally, when writing content to flash, you must first erase the corresponding storage range. This erasure is performed in blocks.

Flash Memory mainly includes the nor and NAND technologies (for a simple comparison, see the appendix ). Flash Memory has a limited number of writes. nand flash memory also has special hardware interfaces and read/write time series. Therefore, you must design a file system that meets application requirements based on flash hardware features. Traditional file systems such as ext2 have many drawbacks when used as Flash file systems.

In Embedded Linux, MTD (memory technology device, storage technology device) provides a unified abstract interface between the underlying hardware (flash memory) and the upper layer (File System, that is, the Flash file system is based on the MTD driver layer (see the file system structure diagram in Linux above ). The main advantage of using the MTD driver is that it is specially designed for a variety of non-volatile memory (mainly flash memory, therefore, it provides better support, management, and sector-based erasure and read/write operations for flash.

By the way, a flash chip can be divided into multiple partitions, and different file systems can be used for each partition. The two flash chips can also be combined into one partition and used in one file system. That is, the file system is for memory partitions, rather than storage chips.

(1) jffs2

Jffs is a file system first developed by Swedish axis communications based on the Linux kernel for embedded systems. Jffs2 is a flash file system developed by RedHat Based on jffs. It was originally an embedded file system developed for the RedHat embedded product ECOs. Therefore, jffs2 can also be used in Linux and uClinux.

Jffs2: log flash File System Version 2 (Journalling flash filesystem V2)

It is mainly used for nor-type flash memory and is based on the MTD driver layer. It features read/write, data compression, and hash-table-based log file systems, it also provides crash/power-down security protection and "Write balance" support. The main drawback is that when the file system is full or near full, jffs2 is greatly slowed down due to the spam relationship.

Jffs3 is currently under development. For more information about how to use the jffsseries file system, see mtd-jffs-howto.txt in the mtdpatch.

Jffsx is not suitable for nand flash memory because the capacity of nand flash memory is generally large, which leads to a rapid increase in the memory space occupied by jffs to maintain log nodes. In addition, when mounting a jffsx file system, you need to scan the entire Flash content to find all log nodes and create a file structure. It takes a lot of time for large-capacity nand flash memory.

(2) yaffs: yet another flash File System

Yaffs/yaffs2 is a log file system designed for embedded systems to use nand flash memory. Compared with jffs2, jffs2 reduces some features (for example, data compression is not supported), so it is faster, has a short Mount time, and consumes less memory. In addition to Linux and ECOs, it also supports wince, PSOs, and threadx.

Yaffs/yaffs2 comes with a NAND chip driver and provides APIs for direct access to the file system for embedded systems. You can directly operate the file system without using MTD and VFS in Linux. Of course, yaffs can also be used with MTD drivers.

The main difference between yaffs and yaffs2 is that the former only supports small pages (512 bytes) NAND Flash, while the latter supports large pages (2 kb) NAND Flash. In addition, yaffs2 significantly improves the memory space usage, garbage collection speed, and read/write speed.

(3) cramfs: Compressed ROM file system

Cramfs is a read-only compressed file system developed by Linux founder Linus Torvalds. It is also based on the MTD driver.

In the cramfs file system, each page (4 kb) is compressed separately and can be accessed by random pages. The compression ratio is as high as, saving a lot of flash storage space for the embedded system, this allows the system to store the same file through a lower-capacity FLASH, thus reducing system costs.

The cramfs file system stores data in Compressed Mode and decompress the data during running. Therefore, applications cannot run in xip mode. All applications must be copied to ram for running, however, this does not mean that the ram space required by ramfs is larger, because cramfs uses paging compression to store files. When reading files, it will not consume too much memory at once, only allocate memory for the part currently actually read. No memory space is allocated for the part that has not been read. When the file we read is not in the memory, the cramfs file system automatically calculates the location of the compressed data and decompress it to ram.

In addition, it is fast and efficient. Its read-only feature is conducive to protecting the file system from damages and improving the system reliability.

Thanks to the above features, cramfs is widely used in embedded systems.

However, its read-only attribute is also a major defect, making it impossible for users to expand their content pairs.

Cramfs images are usually stored in flash, but they can also be stored in other file systems. Using loopback devices, you can install them in other file systems.

(4) romfs

The traditional romfs file system is a simple, compact, and read-only file system. It does not support dynamic erasure and storage, and stores data in sequence, therefore, you can run applications in xip (execute in place, In-chip operation) mode to save Ram space during system operation. Generally, the uClinux system uses the romfs file system.

Other file systems: fat/FAT32 can also be used for extended memory (SD cards for actual embedded systems, such as PDA, smartphone, and digital cameras ), this is mainly for better compatibility with the most popular Windows desktop operating systems. Ext2 can also be used as an embedded Linux File System, but using it in flash memory has many drawbacks.

2. Ram-based File System

(1) ramdisk

Ramdisk uses some fixed-size memory as a partition. It is not an actual file system, but a mechanism to load the actual file system into the memory, and can be used as the root file system. By placing some frequently accessed files (such as the read-only root file system) in the memory through ramdisk, the system performance can be significantly improved.

In the Linux Startup phase, initrd provides a mechanism to load the kernel image and the root file system into the memory.

(2) ramfs/tmpfs

Ramfs is a memory-based file system developed by Linus Torvalds. It works on the VFS layer and cannot be formatted. Multiple file systems can be created, you can specify the maximum memory size that can be used during creation. (In fact, VFS is essentially a memory file system, which unifies the representation of files in the kernel and caches the disk file system .)

The ramfs/tmpfs file system stores all the files in Ram, so read/write operations occur in Ram. You can use ramfs/tmpfs to store temporary or frequently-modified data, for example, the/tmp and/var directories avoid the read/write loss of flash memory and increase the data read/write speed.

Ramfs/tmpfs differs from the traditional ramdisk in that it cannot be formatted and the file system size can change with the size of the contained file.

One disadvantage of tmpfs is that all data is lost when the system is rebooted.

3. Network File System (NFS)

NFS is a technology developed and developed by Sun to share files through networks between different machines and operating systems. In the development and debugging phase of an embedded Linux system, you can use this technology to establish an NFS-based root file system on the host and mount it to an embedded device, so that you can easily modify the content of the root file system.

All of the above discussions are based on the memory-based file system of storage devices, which can be used as the root file system of Linux. In fact, Linux also supports logical or pseudo file systems, such as procfs (proc file system), for obtaining system information, and devfs (Device File System) and sysfs, used to maintain device files.

 

Appendix: Comparison between nor flash and NAND Flash

Nor flash
NAND Flash

The interface time series is the same as that of SRAM, which is easy to use.
Address/data line multiplexing, narrow data bit

Fast Reading Speed
Slow reading speed

The erasure speed is slow. The unit is 64-128kb.
Fast erasure, measured in 8-32 KB Blocks

Write speed is slow (because it usually needs to be erased first)
Fast write speed

The random access speed is fast and supports xip (execute in place, In-chip execution) and is suitable for code storage. Embedded systems are often used to store boot programs and root file systems.
Fast sequential reading speed and slow random access speed, suitable for data storage (such as large-capacity multimedia applications ). Embedded systems are often used to store user file systems.

Small Single-Chip capacity, 1-32 MB
Large Single-Chip capacity, 8-128 MB, increased unit density

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.