File system is the most closely related to the user in the entire UNIX system, the user operates the most frequent part, along with the system running time continues, the file system usage efficiency also follows down, this main performance is: The hard disk space reduces, the rubbish information increases, the addressing time increases and so on. This article will introduce several ways to improve the efficiency of file system use, and share with you, welcome corrections and additions:
First, we should have an understanding of the structure of the Unix file system. File systems are files, directories, and the general name of the data structures that govern these files and directories in UNIX systems. The Unix file system includes a boot block, a super block, an I node area, a file storage area, a process swap area, and so on. The boot block occupies the No. 0 physical block and is not part of the file system. If there is more than one file system in the system, only the root file system has the boot program in the boot block, the rest of the file system does not use the boot block, the Super block occupies the 1th physical block, is the file system control block, the Super Block includes: File system size, number of free blocks , free block Index table, Idle I node number, free I node index table, blocking mark, etc. Super block is the basis for the system to allocate storage space for files and reclaim storage space. The I node is a data structure that controls and manages the file. A file corresponds to an I node, each i node has a unique I node number, and the I node consists of 64 bytes, which holds the file's properties and type, the physical block address that holds the contents of the file, the last access time, the most recent modification time, and the time the file was created. Be aware of this: the I node does not include the filename, the file name and the I node number of the I node are placed in the directory entry of the catalog file. The file store is the area where the contents of the file are stored, the use of each block of data in the file store is recorded in the Super block, and the system uses the records in the super block to complete the allocation and blocks. There may also be a process swap at the end of the file system, which retains the image of the process swapped into memory, which is not part of the file system jurisdiction. Believe that through the above text, the brothers should have a general understanding of the file system.
In order to improve the operating efficiency of UNIX system, the file system should maintain a certain free space, theoretically, the free space should occupy at least 15% of the total space of the file system, when the free space is less than 15% of the total space, the UNIX system operation will obviously slow down! Therefore, the system administrator should understand the file system idle time and the use of I node, to ensure the efficient operation of the system. The system administrator can use the DF command to understand the use of free space and I nodes. Using the Df-v File System command, you can display the file system usage: The total number of file system blocks, the number of used data blocks, the number of free blocks, and the percentage of data that is used to make up the total block. Use the-i option if you want to show the total number of I nodes in the file system, the number of idle I nodes, the number of I nodes that have been used, and the percentage of the I node that I used to use. For example, under Solaris, executable: Df-o I (note oh: I before "-", hehe)
When there is less free space in the file system so that the efficiency of the file system is reduced, the following measures can be used:
1. Delete files in temporary directory
Temporary directories are stored in temporary files, and temporary files are created on demand during program execution, but are not deleted in time. Temporary directories in the system typically have/VAR/TMP, TMP, and/usr/tmp. Administrators can delete them manually, or you can create a job schedule to automate the cleanup process. For example, add the following code to the/usr/spool/cron/crontabs/root:
30 2 * * * find /var/tmp –atime 7 –exec rm{} \ ; >/dev/null
30 2 * * * find /usr/tmp –atime 7 –exec rm{} \ ; >/dev/null
30 2 * * * find /tmp –atime 7 –exec rm{} \ ; >/dev/null