File System
File System Types
You can use the -T
option of the df
command to view the Type field.
EXT4
The most commonly used Linux file system, which combines stability and performance.
- Maximum file size is 2 TB.
- Maximum partition size is 32 TB.
- The default logging mode is Ordered Mode.
- Supports multiple logging modes.
Vfat
Linux support for the FAT file system, commonly used for data sharing with Windows systems.
Tmpfs
A virtual file system based on memory, with fast read and write capabilities.
File Metadata - Inode
In the ext file system, metadata is stored using inode.
Using ls -i
to View
This will output the inode number of the foo file.
Using the stat
Command
Displays detailed information about the file.
Inode Usage
Creating a new file consumes an inode, as shown in the following command.
As can be seen, the IFree of /dev/vda3
has decreased by 1. If all inodes are used up, no new files can be created.
Log Mode Types
File systems are generally divided into 3 types of log modes:
- Writeback: Writeback mode.
- Ordered: Ordered mode.
- Journal: Full journal mode.
Writeback - Writeback Mode
Features: The file system only logs metadata, and the actual data write operations and metadata updates are performed asynchronously. That is, data may be written to the disk before or after metadata.
Advantages: Higher performance, as the order of data writes is not strictly limited.
Disadvantages: Due to the possible inconsistency in the write order between data and metadata, if the system crashes, it may lead to inconsistencies between metadata and data, resulting in the risk of data corruption.
Order - Ordered Mode
Features: The file system ensures that all data blocks are written to the disk before the metadata is updated. In other words, the write of data must be completed before the metadata is updated.
Advantages: Much safer than writeback mode, as it reduces the risk of data and metadata inconsistencies, while maintaining good performance.
Disadvantages: Slightly lower performance than writeback mode, but still a good balance point for many scenarios.
Journal - Full Journal Mode
Features: The file system not only logs metadata but also logs the data itself. All data and metadata are logged to the journal before being written to the disk.
Advantages: This mode provides the highest security, as data and metadata can always be recovered from the journal, ensuring data integrity even if the system crashes.
Disadvantages: Lower performance, as each write requires two write operations (one to the journal and one to the actual data).