Play Linux, first understand the file system

Linux supports a variety of file systems, including ext2, ext3, vfat, ntfs, iso9660, jffs, romfs, and nfs. In order to manage all kinds of file systems, Linux introduced the virtual file system VFS (Virtual File System) for each. The class file system provides a unified operator interface and application programming interface.

The file system structure under Linux is as follows:

When Linux starts, the first one must be mounted on the root file system; if the system cannot mount the root file system from the specified device, the system will exit with an error. Other file systems can then be mounted automatically or manually. Therefore, different file systems can exist in one system at the same time.

Different file system types have different characteristics, so there are different applications depending on the hardware characteristics of the storage device and system requirements. In embedded Linux applications, the main storage devices are RAM (DRAM, SDRAM) and ROM (usually FLASH memory). Common file system types based on storage devices include: jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/ Tmpfs and so on.

1. FLASH-based file system

Flash (Flash) is the main storage medium for embedded systems and has its own characteristics. Flash write operation can only change the corresponding position 1 to 0, but can not change 0 to 1 (erasing Flash is to restore the content of the corresponding memory block to 1), therefore, in general, write content to Flash When it is necessary to erase the corresponding storage interval, the erasure is performed in units of blocks.

Flash memory mainly has two technologies, NOR and NAND (see Appendix for a simple comparison). Flash memory has a limited number of erases and writes, and NAND flash has special hardware interfaces and read and write timing. Therefore, you must design a file system that meets the application requirements for the hardware features of Flash; traditional file systems such as ext2, etc., have many drawbacks when used as a file system for Flash.

Under embedded Linux, MTD (Memory Technology Device) provides a unified abstract interface between the underlying hardware (flash) and the upper layer (file system), that is, the file system of Flash is based on the MTD driver layer ( See the file system structure diagram under Linux above). The main advantage of using the MTD driver is that it is designed for a variety of non-volatile memories (based on flash memory), so it has better support for Flash, management and sector-based erasure, reading. / Write operation interface.

By the way, a Flash chip can be divided into multiple partitions, each partition can use a different file system; two Flash chips can also be combined into one partition, using a file system. That is, the file system is for the memory partition, not the memory chip.

(1) jffs2

The JFFS file system was originally developed as a file system for embedded systems by the Linux 2.0-based kernel of Axis CommunicaTIons, Sweden. JFFS2 is a flash file system developed by RedHat based on JFFS. It was originally an embedded file system developed for RedHat's embedded product eCos, so JFFS2 can also be used in Linux, uCLinux.

Jffs2: Log Flash File System Version 2 (Journalling Flash FileSystem v2)

Mainly used for NOR type flash memory, based on MTD driver layer, featuring: readable and writable, hash-based log file system supporting data compression, and providing crash/power-down security protection, providing "write balance" Support and so on. The disadvantage is that when the file system is full or nearly full, jffs2 runs much slower because of garbage collection.

Currently jffs3 is under development. For detailed documentation on the use of the jffs series file system, refer to the mtd-jffs-HOWTO.txt in the MTD patch package.

Jffsx is not suitable for NAND flash. The main reason is that the capacity of NAND flash is generally large, which causes jffs to increase the memory space occupied by the maintenance log node. In addition, the jffsx file system needs to scan the entire FLASH content when it is mounted. To find out all the log nodes and establish a file structure, it takes a lot of time for large-capacity NAND flash.

(2) yaffs : Yet Another Flash File System

Yaffs/yaffs2 is a log-type file system designed for embedded systems using NAND-type flash memory. Compared to jffs2, it reduces some features (such as not supporting data compression), so it is faster, has a shorter mount time, and consumes less memory. In addition, it is a cross-platform file system, in addition to Linux and eCos, also supports WinCE, pSOS and ThreadX.

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

The main difference between yaffs and yaffs2 is that the former only supports small page (512 Bytes) NAND flash, while the latter supports large page (2KB) NAND flash. At the same time, yaffs2 has greatly improved memory space usage, garbage collection speed, read/write speed and so on.

(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 (4KB) is compressed separately and can be accessed randomly. Its compression ratio is up to 2:1, which saves a lot of Flash memory space for embedded systems, enabling the system to pass lower capacity FLASH storage. The same file, which reduces system costs.

The Cramfs file system is stored in a compressed manner and decompressed at runtime, so applications are not supported to run in XIP mode. All applications are required to be copied to RAM to run, but this does not mean that the RAM space is larger than Ramfs requires. One point, because Cramfs uses paging compression to store files, when reading files, it will not use too much memory space at once, only allocate memory for the part that is actually read, and there is still no read part. Allocating memory space, when the file we read is not in memory, Cramfs file system automatically calculates the location of the compressed data, and then decompresses it into RAM.

In addition, it is fast and efficient, and its read-only feature helps protect the file system from damage and improves system reliability.

Due to the above characteristics, Cramfs is widely used in embedded systems.

However, its read-only property is also a major flaw in it, making it impossible for users to expand their content.

Cramfs images are usually placed in Flash, but can also be placed in other file systems. They can be installed in other file systems using loopback devices.

(4) Romfs

The traditional Romfs file system is a simple, compact, read-only file system that does not support dynamic erase and write, storing data in order, thus supporting applications running in XIP (eXecute In Place) mode. Save RAM space while the system is running. The uC linux system usually uses the Romfs file system.

Other file systems: fat/fat32 can also be used for expansion memory of real embedded systems (such as SD cards for PDAs, Smartphones, digital cameras, etc.), mainly for better compatibility with the most popular Windows desktop operating systems. Ext2 can also be used as a file system for embedded Linux, but there are a number of drawbacks to using it for FLASH flash.

Smart Watch

16+ Years Experience Smart Watch manufacturer, ITOPNOO Provide One-stop Smart Wearable devices Solutions For You.


Our Smart Wearable products include android smart watches, Watch For iPhone, Bracelet and Wristband etc.

Leading healthcare navigation services for individuals and families who are generally healthy or face serious medical issues, and health services for employers.

The Trends New Watches Designs. Custom smart watch products designed with the vision of our clients' brands in mind.





Wholesale smart watches,Best Smart Watches,Gifts Wholesalers, smart watch manufacturer

TOPNOTCH INTERNATIONAL GROUP LIMITED , https://www.micbluetooth.com

This entry was posted in on