Adjust the number of inode nodes as needed

Source: Internet
Author: User
Article Title: adjust the number of inode nodes as needed. 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.

In Linux, the file structure is quite different from that in Microsoft. In Linux, an inode node structure is used. This inode node records important information such as the file type, size, permission, owner, number of file connections, Creation Time, and update time, another important thing is to point to the data block pointer. In general, if you only process the Linux system as a client or a common server, you only need to use the default configuration of the year. However, if you want to use the Linux operating system as a newsgroup server, Forum server, and other servers, you cannot use the default settings. The system administrator needs to adjust the number of inode nodes and other related configurations according to the actual situation.

 1. Relationship between inode nodes and file storage.

To learn how to configure the number of inode nodes, you must first understand the relationship between the number of nodes and the number of files. In Microsoft, files can be stored as long as there is storage space in the disk partition. But it is different in Linux. Before the disk space is used up, users may not be able to store new files. This is mainly because the inode nodes that can be used are complete. So what is the relationship between them? In fact, there is also an intermediary between them, that is, the relationship between them is the triangular relationship between nodes, data blocks, and the number of files.

The system administrator must first understand that the number of inode nodes is related to the data block. But they are not simply proportional or inverse proportions. For example, there is a 25 KB file, and the size of the data block is 4 kb. In this case, the file occupies seven data blocks, but only one inode node is occupied. There is also a special case, for example, the files in the/proc directory of the system do not actually exist. That is to say, it does not occupy data blocks. However, it still needs to occupy one node. Therefore, there is no proportional relationship between data blocks and inode nodes.

However, the number of inode determines the extent to which data blocks are used. For example, if the number of inode nodes is smaller than the number of data blocks, and the files stored by the user are relatively small (for example, the size of a data block is not large ). In this case, it is clear that the number of inode nodes is earlier than that of data blocks. Although there is still free disk space, the number of inode nodes is used up. No redundant nodes can be used to save information about the file. In this case, you cannot save new files. Some users may wonder why there is still disk space, but they cannot store new files. This Inode node is acting as an exception. On the contrary, if the number of inode nodes is larger than the number of data blocks, but the user stores large files. When the number of nodes is not used up, the hard disk space is used up. At this time, the new file cannot be saved. Except for files that do not actually exist.

Therefore, when deploying a Linux operating system, you should determine the size of the data block and the number of Inode Nodes Based on the possible storage status of the file data during future system running. To maximize the utilization of hard disk space. However, if the LInix operating system has no special purpose and is only used as a common client, you only need to use the default settings of the system.

 2. Set the appropriate number of nodes during file system initialization.

From the above analysis, we can see that the number of inode nodes is related to the number of files that can be stored in the system. If the inode node quantity is not set properly, files may not be stored when the hard disk space is not used up. This kind of thing does not happen in general cases, but it often happens in some special applications. If the system administrator does not use this Linux operating system as a forum, this may happen. Generally, the file storage of Forum servers has a special feature. Files on Forum servers are usually relatively small. For example, most files only need to be saved using one data block. At the same time, the number of files is very large. Therefore, if you use the Linux operating system as a website server such as a forum, if you use the default settings, it is likely that the number of inode nodes is used up first, while the hard disk space is still available. At this time, new files cannot be saved.

Therefore, for special applications such as forum servers, I suggest you set a smaller data block to reduce disk fragments and improve disk utilization. At the same time, set more nodes. For example, you can calculate the number of available data blocks based on the data block size and hard disk capacity. Set the number of inode nodes to be the same as the number of data blocks. In this case, the worst case is that the number of nodes is used up simultaneously with the number of data blocks. In most cases, the server will always have some large files, slices, and so on, which will occupy multiple data blocks for storage. Therefore, hard disk space is usually used up first. Therefore, this setting can improve the disk space utilization. There is no such strange phenomenon that the hard disk space is available but new files cannot be saved.

This setting is not only required for Forum servers. If the Linux operating system is used as an FTP server, email server, or newsgroup server, you also need to set it. Generally, as long as the files on the server meet the two characteristics, that is, the number of files is large and the file capacity is small, you need to manually adjust the number of inode nodes, rather than using the default settings. Otherwise, the exception mentioned above will occur.

If you need to adjust the number of inode, you can use mke2fs and Other Related File System creation commands to set them separately. It should be emphasized that the number of Inode nodes required must be determined before system deployment. And then specify it in the file system creation. When files have been stored on the hard disk, it is too late to make adjustments again, because the re-creation of the file system will clear the original files on the hard disk. Therefore, the file will be lost. Therefore, the author suggests that system administrators should first understand the purpose of the server before using the Linux operating system as a server. And the features of file storage in this application. If the number of files is large but the size of the files is small, you need to change the number of nodes so that the server can store more small-size files.

[1] [2] Next page

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.