Overview of the log file system in Linux

Source: Internet
Author: User
Article Title: Overview of the log file system in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

As we all know, file systems are the most important part of the operating system. Each operating system has its own file system. The file system directly affects the stability and reliability of the operating system. There are two types of file systems in Linux: log file systems and non-log file systems. The following describes two types of file systems.

1. Non-Log File System

When a non-log file system is working, it does not record changes to the file system.

The file system stores data on disks by allocating file blocks to files. Each file occupies more than one disk sector on the disk. The job of the file system is to maintain the storage of files on the disk and record which sectors the file occupies. In addition, the sector usage should be recorded on the disk. When reading and writing a file, the file system first finds the fan area number used by the file and then reads the file content. If you want to write a file, the file system first finds the available sector for data appending. Update the file sector usage information at the same time. Different file systems use different methods to allocate and read file blocks. For example, dos/windows uses the fat file system, while windows NT uses the NTFS file system.

Non-log file systems can work very stably, but they have many problems. For a common log file system, such as the Ext2 file system, if the system just writes the disk partition usage information (meta-data) of the file to the disk partition, before writing the file content to the disk, an accident occurred: the system was powered off, and the result would be: the file content is still old, And the meta-data information is new, the two are inconsistent.

Let's take a look at how fsck works in Linux: Generally, when a Linux system is started, run fsck first, it scans all local file systems listed in the/etc/fstab file. Fsck is used to ensure that the metadata of the file system to be loaded is usable. When the system is disabled, fsck transfers all the buffer data to the disk and ensures that the file system is completely detached to ensure that the system can be used normally at the next startup.

However, unexpected power loss or other faults will cause the system to crash and restart. In this case, the operating system Cannot uninstall the file system. After the restart, fsck thoroughly scans the disk, comprehensively checks the metadata, and does its utmost to fix all errors found during the check. It is extremely time-consuming to thoroughly check all metadata. The larger the file system, the longer it takes to complete a thorough scan. Fsck will also encounter a disk error that cannot be repaired. In this case, the file is simply deleted or saved as a file. In a high-density data center, fsck may cause great damage to data files. Linux can be used only after fsck completes scanning, checking, and repairing. Of course, if there is serious file or data loss, the system may not be able to restart!

Types of non-log file systems:

Linux supports a wide variety of file systems. Almost all Linux distributions use ext2 as the default file system. Ext2 is a non-log file system. In addition, other non-log file systems supported by Linux include FAT, VFAT, HPFS (OS/2), NTFS (Windows NT), and Sun UFS.

Ii. Log File System

The log file system adds the log records of file system changes on the basis of non-log file systems.

Log files are designed to track changes in the file system and record the changes to logs. The idea of a log file system comes from a large database system. Database Operations are composed of multiple related and interdependent sub-operations. Failure of any sub-operation means that the entire operation is ineffective. Therefore, any changes to the data must be returned to the previous status. Log File systems adopt similar technologies.

The log file system stores log records in the disk partition. Write operations are performed on the record files first. If the entire write operation is interrupted due to some reason (such as power loss), when the system restarts, the write operation before interruption will be restored Based on the log records. This process takes seconds to minutes.

How does the log file system work?

In the log file system, all changes, additions, and changes to the file system are recorded in the "log" (that is, the data that records the metadata information of the file. At a certain time, the file system writes the updated file metadata and file content to the disk, and then deletes the logs. Start a new log.

Before any changes to the metadata, the file system driver writes an entry to the log describing what it will do. Then, it continues and modifies the metadata. In this way, the log file system has a history record of recently modified metadata. When the consistency problem of the file system is detected, you only need to check the data modification history. That is, in addition to storing data and metadata, the log file system also stores a log, which we can call metadata ).

The log file system makes data and files more secure, but the system overhead increases. Write synchronization is required for each update and most log operations, which requires more disk I/O operations. Starting from the principle of log files, it is a good idea to use the log file system on the partitions that require frequent write operations.

In Linux, the log file system or non-log file system can be used together. Logs increase the file operation time. However, from the perspective of file security, the security of disk files has been greatly improved. The author tests the log file system. The performance of the log file system is not much inferior to that of the ext2 file system. Some log file systems use B + tree algorithm, when operating large files, the opposite performance is better than that of non-log file systems.

What are the advantages of using a log file system?

The file security is improved, the probability of file destruction is reduced, the disk scan time is shortened, and the number of scans is reduced. When the system goes down unexpectedly, there will be no file content loss, at least the file should be kept in the previous version; When a log file system is used, the system usually restarts 20-30 times each time, to scan the disk as a whole, reducing the number of scans.

Log File System in Linux

XFS File System: xfs http://oss.sgi.com/projects/xfs/ of SGI

JFS File System: jfs http://oss.software.ibm.com/developerworks/opensource/jfs/ for IBM

Reiserfs File System: http://www.namesys.com

EXT3 File System: linux/ext3/"> http://www.zip.com.au /~ Akpm/linux/ext3/

GFS File System: http://linux4u.jinr.ru/LinuxArchive/Ftp/kernel/gfs/4.2/

Vertas File System: http://www.veritas.com/products ...... RoductId = filesystem

Related Article

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.