Embedded: jffs2, yaffs2, logfs, and ubifs File System Performance Analysis

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 the Virtual File System (VFS), which provides a unified operation interface and Application Programming Interface for various file systems. When Linux is started, the first must

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. When Linux is started, the first must

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 is to restore 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, a file system that meets the application requirements must be designed for 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 the rapid increase of memory space occupied by jffs to maintain log nodes, 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, it does not support data compression), 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 space at once, only allocate memory for the part actually read before the object, and do not allocate memory space 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.