1. Physical structure of the disk
Disc: The disk is made up of a stack of disk faces
Head (Heads): Each head corresponds to a disk face, which is responsible for reading and writing data on the disk surface.
Track: Each disc is divided into concentric circles around the center of the Circle, each of which is called a track
Cylinder (cylinders): The three-dimensional track consisting of the same position on all platters is called a cylindrical surface.
Sector (Sector): Managing disks in Tracks is still too large, so computer predecessors have divided each track into multiple sectors
The size of the disk is generally related to the intensity of the track, and the number of sectors is generally constant.
2. The process of disk I/O
The first is the radial movement of the head to find the track-and-seek time of the data.
Rotation after locating the target track through the disk face, moving the target sector directly below the head and rotating delay
Access time to read or write data to the target sector
So far, one disk IO is complete.
So the single disk IO time = seek time + rotation delay + access time
3. linux File System
A) Superblock
Record the overall information of the filesystem, including the total amount of inode/block, usage, and information about the amount of remaining and file system formats
b) inode
Log file permissions and properties, a file consumes an inode, and the block number where the file's data is recorded
c) block
The contents of the actual record file, if the file content is large, will occupy more than block
Since each inode and block is numbered, each file will only occupy a block number that records the file in a inode,inode. So we just need to find the file corresponding to the inode, we can naturally find the file block number, then you can get the data of the file.
4. Create a Directory
When we create a directory under Linux, the system allocates an inode and at least one block to that directory (if there are too many files in that directory, multiple block blocks may be allocated to log file information). The Inode records the permissions and properties of the directory. The assigned block number is also recorded. In the block, the file name in this directory is stored with the inode number corresponding to the filename, so the process of accessing a file in a directory is described below.
reading the current directory.InodeData -Determine whether you have permission to work with this directory -If you have permission -read the directory'sBlockof Data -To get the file name and files in the current directory .Inodenumber -read the corresponding fileInodeNumber of information -Determine whether you have permission to work with the file -If you have permission -Read theInodein the savedBlockblock of data -Read process complete
5. Create a file
When we create a file under Linux, the system allocates an inode and the number of block blocks (Size/block) relative to the size of the file. If you exceed the direct point of the inode, the system will also allocate an additional indirect block OH. When creating files and directories , we will first determine the permissions, and then find the free inode and block according to bitmap.
6. File sharing
In the process of Linux, when we open a file, a file descriptor is returned. This file descriptor is an array of subscripts, corresponding to the array element as a pointer. Interestingly, this pointer does not directly point to the inode of the file, but instead points to a file table, which, through the table, points to the inode of the target file loaded into memory. For example, a process opens two files
If Dup/dup2 is performed, for example, FD = 4 is generated for DUP (1), then the structure is as follows:
7. Soft links and hard links
To solve the shared use of files, the Linux system introduces two links: Hard link and soft link (also known as symbolic link, soft link or symbolic link). Link for Linux system to solve the shared use of files, but also bring hidden file paths, increase permissions security and save storage and other benefits. If an inode number corresponds to more than one file name, the files are called hard links. In other words, a hard link is a file that uses multiple aliases, and a soft link is equivalent to a shortcut under Windows, but only the file name of the original is saved.
With the above knowledge, understanding soft links and hard links is a piece of cake. Give a picture to illustrate.
Main contents from < Bird's private cuisine > part of the content from the network.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux file system related knowledge collation