Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic principles and common types of Linux file system?

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What are the basic principles and common types of Linux file system? in view of this question, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Before the advent of computers, there was the concept of a file system, which is a system used to manage (store, retrieve, etc.) paper files. After the computer and the invention, the file system gradually refers to the system used to manage the storage medium. It gives users a simple interface and makes it convenient for users to use storage devices.

The same is basically true of file systems under the Linux operating system. When we enter the Linux operating system, the first thing we see are various types of directories (refer to an article to learn about Linux system directory management) and various files. Linux has a concept that "everything is a file". In the Linux operating system, almost all resources are presented in the form of files. For example, the disk is a file, the socket is a file, and the system configuration item is also a file. All of this content is managed through the file system in Linux.

In the operating system, the concept of file system has been extended. Linux file systems fall into two categories, real file systems that store data, and pseudo file systems that do not persist data. Today we will give an overall introduction to the file system under Linux, so that you can have a general understanding of the file system.

Use of the file system

The use of the file system in the Linux operating system is very simple. If you are using an operating system with a graphical interface such as Ubuntu, we can browse the file system through GUI. This is very similar to using Windows and Mac OS operating systems. From the user's point of view, the files of the file system are organized into a tree structure. Users are free to create directories and files.

But if it is a command-line system, then there is no graphical interface convenient. However, in terms of organizational form, it is also a tree structure. It's just not that intuitive. In the picture, we can see the content and structure of the file system through the tree command.

Of course, the above are all scenarios where the file system has been mounted. In some cases, we have a new disk, but it is not mounted. How can we use this disk at this time? The method is also very simple, you only need to do the following steps:

Format disk, because Linux supports many kinds of file systems, we need to use some kind of file system to format before using disk. For example, it is formatted as Ext4 file system, mkfs.ext4 / dev/sdc.

Mounting a file system cannot be used immediately after formatting. It needs to be mounted to the directory tree before it can be used. The specific command is mount / dev/sdc / mnt/ext4_test.

After completing the above steps, the / mnt/ext4_test directory is the root of the new disk, where we can create subdirectories or new files. From the perspective of the average user, it is just a subdirectory and does not perceive that it is a new disk or a specific type of file system. This is quite different from Windows.

The basic principles of the file system

At the operating system level, the file system is one of its most critical subsystems, and its core function is the management of storage resources. In other words, the file system manages the space of the disk (including other types of storage media such as optical discs or tapes). File system management of disk space is actually relatively simple, is to cut large disk space into very small areas (such as 4KB), and then through the allocation and release of these small areas to use disk space.

Although the file system is a tree structure, the space of the disk itself is a flat linear storage space. In Ext4, for example, the file system divides the disk into several block groups, each of which is divided into several disk blocks (which can be specified when formatted, and the default is 1KB).

In order to manage these blocks, some areas are always needed to record which blocks have been used and which have not been used. The data that records this data is usually in a special area of the disk, which we call the metadata of the file system. Through these metadata file systems to achieve the management of disk space, and finally provide users with an easy-to-use interface (using interface, non-API).

Classification of file systems

In the previous article, we introduced the local file system based on storage media and its basic principle. In fact, with the development of file system, its variety is also rich and varied. For example, the normal disk-based local file system includes not only Ext4, but also XFS, ZFS, Btrfs, and so on. Among them, Btrfs and ZFS can not only manage one disk, but also manage multiple disks and achieve redundant data management at the same time, which can avoid data loss caused by disk failure.

On the other hand, in addition to the file system for disk data management, there are some network file systems. In other words, these file systems appear to be local, but the data is actually on remote, dedicated devices. The client transmits data through some network protocols. File systems such as NFS and GlusterFS.

With decades of development, there are so many types of file systems that we have no way to introduce them one by one. Today we will introduce the main file systems according to major categories, and please give us some advice on the shortcomings.

1. Local file system

A local file system is a file system that manages disk space. In terms of presentation form, the file system is a tree-shaped directory structure. We have introduced many concepts before, which in essence is to realize the management of disk space and the conversion between disk linear space and directory structure.

From the point of view of ordinary users, it is mainly convenient for the use of disk space, reduces the difficulty of use, and improves the utilization efficiency. Common local file systems are Ext4, Btrfs, XFS, ZFS, and so on.

two。 Pseudo file system

Pseudo file system is an extension of traditional file system. The pseudo file system does not persist the data, but the file system in memory. It realizes the interaction between user and kernel data in the form of file system. For example, our common pseudo file systems include proc, sysfs, configfs, and so on.

In the Linux operating system, the pseudo file system mainly realizes the interaction between the kernel and the user mode. For example, to get the parameters of the IPv4 protocol, we just need

3. Network (distributed) file system

A network file system is a file system that stores data at the remote end. The network file system is usually divided into the client and the server, in which the client is similar to the local file system, and the server is the system that manages the data. The use of the network file system is no different from that of the local file system, you just need to execute the mount command to mount it. There are also many kinds of network file systems, such as NFS, CephFS, Gluster and so on.

At the user level, the mounted network file system is exactly the same as the local file system, there is no difference, and it is transparent to users. A network file system is like mapping a remote file system to a local file system.

The figure is a schematic diagram of mapping a file system in a file system service to a client. From the user's point of view, it is only a subdirectory, but in fact, read and write requests need to be forwarded to the server through the network for processing.

4. Cluster file system

The cluster file system is also a local file system. It differs from a normal local file system in that its back-end disks are usually network-based SAN devices and are shared (non-absolute) on multiple nodes. The cluster file system can realize the common access of multiple nodes to the disk media.

At the same time, for the cluster file system, its biggest feature is that multiple nodes can provide file system services for the application layer at the same time. This common method is especially suitable for scenarios where the application business is overactive. Highly available cluster mechanisms are provided through the cluster file system to avoid service failures caused by downtime.

The answers to the questions about what are the basic principles and common types of Linux file system are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report