The file system on Linux is generally EXT2 or EXT3, but this article is not ready to talk about them directly, but I want to combine the Linux operating system and from the foundation of the file system-the hard disk to start, step-by-step understanding of the Linux file system.
1. Physical storage mechanism of mechanical hard disk
Most of the file storage functions of modern computers are provided by such devices as mechanical hard drives. (now the SSD and Flash are both conceptually and logically partially inherited from the mechanical hard drive, so using a mechanical hard drive to understand is no problem)
Mechanical hard disk can realize the function of information storage based on: Magnetic storage media can be magnetized, and after magnetization will remain magnetized state, this magnetized state can be read out, at the same time this magnetization state can be continuously modified, magnetization just have two direction, so can be expressed 0 and 1.
So the hard disk is to make this magnetic storage media into a disk, each disk is distributed on a large number of magnetic storage units, using magnetic Read and write head to write and read the disk (similar to the principle of the black vinyl record playback).
The number of magnetic storage units in a hard drive is hundreds of millions (1T hard disk has about 8 billion), so a set of rules to plan how information is accessed (such as a book that stores information we will be divided into pages, each page from top to bottom read from left to right, as well as chapter program)
Then there are the concepts of physics and logic:
- One hard disk has multiple platters stacked, with different platters numbered
- The storage particles on each platter are arranged in a circular circle, each circle called a track, numbered
- Each track has a lap of storage particles, each 512*8 (512 bytes, 0.5KB) of storage particles as a sector, the sector is the smallest physical unit stored on the hard disk
- N sectors can be clustered, depending on the file system or file system configuration, the cluster is the smallest storage unit in this file system
- The same track on all the disks constitutes a cylinder, called a cylinder, and the cylinder is the smallest unit of the system partition
?
When the head reads and writes files, the first is the partition read-write, by the Inode number (the region's unique number is described later) to find the corresponding track and sector, and then a cylinder on a cylinder to read and write. The read-write control system for mechanical hard drives is an amazing precision engineering (there are hundreds of millions of storage units on a disk, each track has a width of less than dozens of nanometers, disks are tens of thousands of RPM), and the logic of reading and writing has many details (such as sector numbering is not continuous), very interesting, You can search your own articles to expand your reading.
Having a hard disk does not mean that Linux can be used to store it immediately, and that it needs to be combined into a Linux file system for Linux to use.
2.Linux File System
Linux manages the data and hardware resources in the computer in the form of files, that is, everything is completely file, which is reflected in the Linux file type: Ordinary files, directory files (i.e. folders), device files, linked files, pipeline files, socket files (data communication interface) and so on. While these kinds of files are managed by Linux using a directory tree, the so-called directory tree is based on the root directory (/), which presents a branch-like file structure. Unlike a purely ext2 file system, I call it a filesystem, and all of the file and file tree resource management methods together form the Linux file system, so that the Linux operating system can easily use system resources.
Therefore, the file system is much less than the file system, the Linux file system is mainly about the operating system related to the file this carrier implementation: File system mounted on the operating system, the operating system and the entire system is placed in the file system. However, the file system in this paper is not a lot of relevant content, most of the place can be used to replace the filesystem file systems.
File types in Linux
Let's briefly talk about the types of files in Linux, focusing on common files, directory files, and symbolic connection files.
- Normal file (-)
- from a Linux perspective, file types such as MP4, PDF, and HTML are common Files
- Linux users can view, change, and delete regular files based on access rights
- catalog files (d,directory file)
- directory files are not easy to understand for users who are accustomed to Windows, and directories are also a type of file
- directory files contain the text in their respective directories Name and pointers to these files, open the directory is actually open directory files, as long as there is access, you can freely access the files under these directories (normal file execution permissions are the directory file access), but only the kernel process can modify them
- Although cannot be modified, But we can use Vim to view the contents of the catalog file
- Symbolic Link (l,symbolic link)
- This type of file resembles a shortcut in Windows, and is an indirect pointer to another file, which is what I We often say soft links
- block device files (b,block) and character device files (C,char)
- These files are generally hidden in the/dev directory and are used for device reads and peripheral interactions to
- For example, a disk drive is a block device file, the serial device belongs to the character device file
- system, all devices are either block device files, or character device files, without exception
- FIFO (p,pipe)
- Pipeline files are primarily used for interprocess communication. For example, you can use the MKFIFO command to create a FIFO file, enable a process A to read the data from the FIFO file, start process B to write the data in the FIFO, first-out, along with the read-write.
- sockets (S,socket)
- for inter-process network communication or for non-network communication between native
- These files are generally hidden in the/var/run directory, proving the existence of related processes
Linux files are not so-called extensions, a Linux file can be executed and whether it can be executed, as long as you have an X in the permissions, such as [-rwx-r-xr-x] on behalf of the file can be executed, and the filename is not related. The file name extensions that can be executed under Windows are usually different from the. com. exe. bat.
However, it can be performed differently than can be performed successfully. For example, under the root master login Install.log is a text file, modify the permissions to become-rwxrwxrwx after the file can be really successful? Of course not, because its content simply has no data to execute. So, this x represents the ability of the file to execute, but if it succeeds, it will have to look at the content of the file.
Even so, we still want to know what the file is from the extension, so we will generally indicate what kind of file it is with the appropriate extension.
So the file name on the Linux system really just lets you know what the file might be used for, and the actual execution will still require permission specification. For example, a common/bin/ls this command that displays the attributes of a file if the permission is modified to be unenforceable, then LS becomes unenforceable. This problem occurs most often in the process of file transfer. For example, if you download an executable file on the network, but it just can't be done on your Linux system, it's possible that the properties of the file have been changed. And from the network to your Linux system, the properties of the file permissions are actually changed
Linux directory tree
For Linux systems and users, all operational computer resources exist in the logical structure of the directory tree, and access to computer resources can be considered as access to the directory tree. In the case of a hard drive, all access to the hard disk becomes the access to a node in the directory tree, that is, the folder in which it is accessed without knowing whether it is a hard disk or a hard disk.
The logical structure of the directory tree is also very simple, that is, starting at the root (/), continue to expand the sub-directory.
3. Hard disk Partitioning
Hard disk Partitioning is the first step in combining a hard drive into a file system, essentially the "hard disk" concept, which translates into the logical concept of "zone," to prepare for the next format.
So the point itself is not necessary, you can completely put a whole piece of hard disk as a district. However, from the data security and system performance point of view, the partition is still a lot of use, so generally will partition the hard disk.
The partition will have to mention the most important first sector on each hard disk, this sector has the hard drive master boot record (master boot Record, MBR) and partition table (partition table), where the MBR occupies 446 bytes, and the partition table occupies a bytes. Hard drive master boot record has the most basic boot loader, is the system boot the key link, in the Appendix has more detailed description. The partition table is related to the partition, it records the hard disk partition information, but because the partition table only 64bytes, so can only remember login four blocks (partition itself is actually set on the partition table).
Only four districts are too few, so there is the concept of extended partitioning, since the first sector is located in the partition table can only record four data, then I can use the additional sectors to record more partition information.
The normal accessible partition is called the primary partition, and the extended partition is different from the primary partition, and it has no content, and it provides space for further logical partitioning. Once a partition has been designated as an extended partition, the extended partition can be further partitioned into multiple logical partitions. Operating System regulations:
- Each block of four partitions can be either a primary partition or an extended partition
- Extended partitions can have at most one (and no need to have multiple)
- Extended partitions can be further split into multiple logical partitions
- An extended partition is only a logical concept and cannot be accessed by itself, that is, a partition that cannot be formatted as a data access, and only the primary and logical partitions that can be accessed as data
- The number of logical partitions varies by operating system, in Linux systems, the IDE hard disk has a maximum of 59 logical partitions (numbers 5th to 63rd), and SATA hard disks have 11 logical partitions (5th to 15th numbers)
When partitioning a hard disk, it is best to partition an extended partition into a primary partition and then divide the extended partition into n logical partitions.
- Is it possible to avoid the primary partition? I don't know, but it doesn't seem to bother you when you create a partition, you automatically configure the type
- Special, you'd better separate a swap area (memory replacement space), it is a single category, the function is: when the data is stored in the physical memory, but the data is not often taken by the CPU, then these infrequently used programs will be thrown into the swap space of the hard disk, and freeing up faster physical memory space for programs that really need it.
4. Formatting
We know that the Linux operating system supports many different file systems, such as ext2, Ext3, XFS, fat, and so on, while Linux gives access to different file systems to VFS (virtual file system), and VFS can access and manage a wide variety of file systems. So when you have a zone, you need to format it into a specific file system for VFS access.
The standard Linux file system Ext2 is using the Inode-based file system
- We know that the general operating system of file data in addition to the actual contents of the file, but also with a lot of attributes, such as the Linux operating system file permissions (RWX) and file attributes (owner, group, time parameters, etc.), the file system will usually attribute and the actual content of the two parts of the data are stored in different chunks
- In an inode-based file system, permissions and attributes are placed in the inode, and the actual data is placed in a data block block, and the inode and data block are numbered
EXT2 file system on this basis
- File system has a boot sector at the front (boot sector)
- This boot sector can install the boot manager, this design allows us to install different boot loader to the individual file system front-end, without overwriting the entire hard disk unique MBR, that is to achieve multi-boot function
- Divide each block further into blocks (block group), each with an independent Inode/block system
- If the file system is up to hundreds of GB, put all the inode and block together because the number of inode and block is too large to manage easily
- This is really good understanding, because the partition is the user's partition, the actual computer Management also has the most suitable size, so the computer will be further partitioned in the block
- (but would it not be possible for a large document to be put on the issue?) Is there any mechanism for the aftermath? )
- Each block group will actually be divided into 6 parts, in addition to the Inode table and the data block there are 4 sub-modules, to optimize and improve the performance of the system function
So the whole partition is probably divided into this way:
?
Inode table
- The attributes of the primary record file and the block in which the actual data is placed in the file, the information it records has at least these:
- Block numbers for size, real content (one or more)
- Access Mode (Read/write/excute)
- Owners and Groups (Owner/group)
- Various times: time of establishment or state change, last read time, last modified time
- No filename! The file name is in the block of the directory!
- A file occupies an inode, with each inode numbered
- Linux system with inode number exhausted but disk space remaining
- Note that the file here is not just ordinary files, directory files is also a folder is actually a file, there are other also
- The number and size of the inode is fixed at the time of formatting, each inode size is fixed to bytes (new Ext4 and XFS can be set to bytes)
- The number of files the file system can establish is related to the number of inode, where there is enough space but not enough inode
- When the system reads the file, it needs to find the inode and analyze whether the permissions recorded by the inode are consistent with the user, and if so, to begin to actually read the contents of the block.
- Inode to record a lot of information, but only 128bytes, and Inode record a block number to spend 4byte, if I have a file 400MB and each block is 4K, then at least 100,000 block number record! Where does the inode have so much space to store? For this reason, our system is smart. Defines the area of the Inode record block number as 12 direct, one indirect, one double indirect and one three indirect record area (see Appendix for details)
Data block
- Place where the file content data is placed
- Block size is fixed when formatting, and each block is numbered to facilitate Inode records
- In principle, the size and number of blocks cannot be changed after formatting (unless reformatted)
- The block size supported in the Ext2 file system is 1 K, 2K and 4K three, due to the difference in block size, the maximum disk capacity that the file system can support is different from the maximum single file capacity:
- Block size 1KB 2KB 4KB
- Maximum single file limit 16GB 256GB 2TB
- Maximum file system Total capacity 2TB 8TB 16TB
- Only one file can be placed in each block, but one file may be placed in more than one block (large)
- If the file is less than block, the remaining capacity of the block cannot be reused (disk space is wasted)
- So if your files are very small, but your block in the format of the use of the largest 4K, may produce a waste of capacity
- Now that the big block is likely to produce more serious disk capacity waste, will we set the block size to 1K? This is not appropriate, because if the block is smaller, then large files will occupy more blocks, and the inode will also record more block numbers, which may lead to poor file system read and write performance
- In fact, the current disk capacity is too large, so the general choice of 4K block size
Superblock
- Where the information about the entire file system is recorded, the general size is 1024bytes, and the recorded information is mainly:
- Block vs. Inode Total
- Unused and used Inode/block quantity
- A valid bit value, if the file system is mounted, the valid bit is 0 and if not mounted, the valid bit is 1
- Block and Inode size (Block 1, 2, 4k,inode 128bytes or 256bytes);
- Various other file system related information: FileSystem mount time, last write data time, last Test disk (fsck) time
- Superblock is very important, without superblock, there is no file system, so if Superblock dies, your file system may take a lot of time to save
- Each block may contain superblock, but we also say that a filesystem should have only one superblock, what's going on? In fact, in addition to the first block will contain Superblock, the subsequent block does not necessarily contain superblock, and if it contains Superblock, then the superblock is mainly as the first block of Superblock in a backup, This could be a superblock rescue.
Filesystem Description
- File System description
- This section describes the start and end block numbers for each block group, and the number of blocks between each block (Superblock, bitmap, Inodemap, data Block), respectively.
Block bitmap
- Block table
- If you want to add a file, which block will you use to record it? Of course, choose "Empty block" to record. " So how do you know which block is empty? This has to go through block bitmap, it will record which blocks are empty, so our system can quickly find the space to use to record
- Also, when you delete certain files, the block number that the file originally occupies must be released, at this time in block bitmap, the flag of the block number should be changed to "not in use"
Inode bitmap
- With block bitmap is similar to the function, only the block bitmap record is used with unused block numbers, as for Inode bitmap is the record used with unused inode numbers
5. Mounting
After a zone is formatted as a filesystem, it can be used by the Linux operating system, but this time the Linux operating system cannot find it, so we also need to "register" the file system into the Linux operating system file system, this operation is called "Mount" (Mount).
Mount is to use a directory as an entry point (similar to choosing an out-of-the-box directory as a proxy), put the file system in the directory, that is, access to the directory can read the contents of the file system, similar to the entire file system is just a directory tree folder (directory).
The entry point directory is called the "mount point".
Because the root directory is the most important for the entire Linux system, the root directory must be mounted to a partition. Other catalogs can be attached to different points depending on the user's own needs.
Here the Linux file system construction process has been largely finished, summed up is: Hard disk is partitioned and formatted, each zone has become a file system, mount this file system can let the Linux operating system through the VFS access to the hard disk with access to a normal folder. Here is a practical example of reading a file in a directory tree to get a detailed look at the catalog file and the normal file.
6. The reading process of the directory tree
First of all, we need to know
- Each file, whether it is a generic file or a catalog file, consumes an inode
- Allocate one or more blocks to the file based on the size of the file content to use
- After creating a file, the full file information is distributed around 3 places, generating 2 new files:
- The file name is recorded in the block of the directory file where the files are located, and no new files are generated
- File attributes, permission information, block numbers that record specific content are recorded in the Inode, and the inode is the newly generated file
- File specific memory recorded in block, Block is the new generated file
- Because the file name is recorded in the directory block, "Add/Remove/rename filename" is related to the W permission of the Directory
So in Linux/unix, the file name is just a property of the file, called alias or nickname, just for the convenience of user memory and use, but the system does not need to use the file name to set the location of files, so the most intuitive benefit is that you can rename the file you are using, change the directory, Even putting it in the trash will not affect the use of the current file, which is unthinkable in Windows. For example, if you open a Word file and rename it, Windows will tell you that you don't have one, close the file first! But there is no pressure on the Mac because the MAC's operating system also uses the Inode design.
Create a file procedure
When a generic file is created under Ext2, Ext2 allocates an inode with the number of blocks relative to the file size to the file
- For example: Suppose one of my blocks is 4 Kbytes, and I want to create a Kbytes file, then Linux will allocate an inode with 25 block to store the file
- Note, however, that since the inode has only 12 direct points, there is one more block to record as a block number.
Create a Catalog procedure
When a directory is created in the Ext2 file system (a new directory file is created), the filesystem allocates an inode with at least one block to the directory
- The Inode records the permissions and attributes of the directory and records the block number assigned to it
- The block is a file name in this directory that corresponds to the inode number
- The block also automatically generates two records, one for the. Folder record, the inode points to itself, and the other is: Folder records, Inode points to parent folder
Read a file procedure from the catalog tree
- Because the file name is recorded in the directory of the block, so when we want to read a file, we will go through the directory Inode and block, and then be able to find the inode number of the file to be read, and eventually read the correct file block within the data.
- Because the directory tree is started by the root directory, the operating system first through the mount information to find the inode number of the mount point, thereby obtaining the inode content of the root directory, and according to the inode to read the root directory block information, and then read down to the correct file layer.
For example, if I want to read/etc/passwd This file, how is the system read?
First look at this file and the information about the path folder:
$ ll -di / /etc /etc/passwd
128 dr-xr-x r-x . 17 root root 4096 May 4 17:56 /
33595521 drwxr-x r-x . 131 root root 8192 Jun 17 00:20 /etc
36628004 -rw-r-- r-- . 1 root root 2092 Jun 17 00:20 /etc/passwd
The read process for this file is:
- /The Inode:
- The root inode with inode number 128 is found through the information of the mount point, and the permissions provided by the Inode allow us to read the contents of the block (with R and X)
- /BLOCK:
- After the last step, get the block number and find the Inode number that contains the etc/directory (33595521)
- The inode of the etc/:
- Read the No. 33595521 inode to learn about the permissions of R and X, so you can read the block contents of etc/
- Block of etc/:
- After the last step, get the block number and find the Inode number that contains the passwd file (36628004)
- The inode of the passwd:
- Read the No. 36628004 inode to learn about the permissions of R, so you can read the block contents of passwd
- Block of passwd:
- Finally, read the information about the block content.
Appendix: Boot process and HDD master boot record
Can speak a little bit about the boot process and the hard drive master boot record (MBR, or master boot partition)
A functioning computer will set up a boot hard disk in the BIOS, in fact, each hard drive can be used as the boot disk, the hard disk itself is designed to provide this possibility, this will be from the first sector on the hard disk, the sector has a master boot record (master boot record, MBR) and partition table (partition table), where the MBR occupies 446 bytes, while the partitioned table occupies a bytes.
The computer motherboard has a program written to the motherboard Bios,bios is the first program that the computer system will actively execute after booting. The BIOS will analyze what storage devices are in the computer, we take the hard drive as an example, the BIOS will be based on the user's settings to obtain a bootable hard disk, and to the hard disk to read the first sector of the MBR location.
MBR This only 446 bytes hard disk capacity will be placed in the most basic boot loader (boot loader), its purpose is to load the operating system kernel files, because the boot loader is the operating system at the time of installation provided, so it will know the hard disk File system format, Therefore, the operating system kernel files can be read. The next step is the work of the kernel file, which is what everyone knows about the operating system.
So simply say the start-up process is:
- BIOS: Active program on boot, will identify the first device to boot
- mbr-boot loader: The boot loader in the primary boot partition in the first sector of the first bootable device to read the operating system kernel files
- Operating system kernel files: Different operating systems about opening their own programs
By the above instructions we will know that the BIOS and MBR are the hardware itself will support the function, to the MBR boot loader is the operating system written in the upper part of the MBR program. Since the MBR has only 446 bytes, the bootloader is very small and beautiful, and its main tasks are:
- Menu available: Users can choose different boot items, which is also an important function of multi-boot
- Load operating system kernel: direct to the bootable program section to start the operating system
- Transfer Other loader: Transfer the bootloader function to other loader responsible for
- This is interesting, it means that your computer system may have more than two boot loader
- Is it possible? We don't have a single MBR for our hard drive? This is true, but the bootloader can be installed in the boot sector (boot sector) of each partition in addition to the MBR.
- The feature of the boot sector of the partition makes the function of "multi-booting"
- (You can see the bird Brother's book, section fourth, chapter III)
Physical storage structure of mechanical hard disk expand reading
- Giang. Hard drive giant magnetoresistance (GMR) heads: from microns to nanometers [J]. Physics, 2004, 33 (07): 0-0.
- In recent years, the most important factor of the rapid growth of computer hard disk storage density is the application of the spin valve nanometer multilayer membrane structure, namely the giant Magneto Resistance (GMR) reading sensor head. Giant Magneto-resistive head-reading sensors have been converted from microelectronic devices to nano-electronic devices, which include spin electronics, materials science, microelectronics engineering, chemistry, micro-mechanical mechanics and engineering and other disciplines and related micro-processing technology comprehensive challenge limit.
- How disk works Uncover http://www.dostor.com/article/2012-09-07/1712853.shtml
- Most permanent or semi-permanent computer data are implemented by magnetization of a small piece of metal on the disk. These magnetic graphs can then be converted into raw data.
- Mechanical hard disk internal hardware structure and working principle detailed http://blog.csdn.net/coslay/article/details/42215409
- The simplest way to number a sector is to l,2,3,4,5,6 sequential numbers. If the sectors are numbered sequentially around the track, then, during the process of processing a sector's data, the disk rotates too far, exceeding the interval of the sector (the interval is small), and the next sector that the controller reads out or writes to has passed through the head, perhaps a considerable distance. In this case, the disk controller can only wait for the disk to rotate for almost a week before the required sectors reach the head. It's a waste of time. Many years ago, an outstanding engineer at IBM came up with an ingenious way of not using sequential numbering for sectors, but using a crossover factor (Interleave) to number them.
Other details of formatting
We all know that the partition will need to be formatted after the partition is complete before the operating system can use it. Why do I need to "format" it? This is because each operating system sets the file attributes/permissions are not the same, in order to hold the data required for these files, it is necessary to format the partition to become the operating system can take advantage of the file system format.
- From this we can also know that each operating system can use a different file system. For example, the main file system used by Windows 98 's previous Microsoft operating system is FAT (or FAT16), and later versions of Windows 2000 have the so-called NTFS file system, as for Linux's Orthodox file system Ext2 (Linux second E xtended file System, EXT2FS) this one. And in the default case, the Windows operating system will not recognize the Linux Ext2.
- Traditional disk and file system applications, a partition can only be formatted as a file system, so we can say that a filesystem is a partition. But because of the use of new technologies, such as LVM and software disk arrays (software RAID), which we often hear, these technologies can format a partition as multiple file systems and can synthesize multiple partitions into a filesystem, so At this time we are no longer talking about formatting as a partition, and we can usually call a data file system instead of a partition that can be mounted.
The relationship between EXT2 's inode/block and file size (interesting)
We briefly analyze the relationship between EXT2 's inode/block and file size. Inode to record a lot of information, but only 128bytes, and Inode record a block number to spend 4byte, if I have a file 400MB and each block is 4K, then at least 100,000 block number record! Where does the inode have so much space to store? For this reason, our system is smart. Defines the area of the Inode record block number as 12 direct, one indirect, one double indirect with a three indirect record area. What is this? Let's draw the structure of the inode.
The
Leftmost is the Inode itself (bytes), there are 12 directly to the block number of the control, these 12 records can be directly obtained block number! As for the so-called indirect is to take a block to record the block number record area, if the file is too large, you will use the indirect block to record the number. In the case of indirect just take a block to record the extra number. Similarly, if the file continues to grow, then the so-called double-indirect, the first block will only point to the next record number of blocks, the actual record in the second block. And so on, three indirect is to use the third block to record numbers!
How many blocks can this sub-inode specify? We illustrate this with a smaller 1K block, which can be specified as follows:
- 12 Direct points: 12*1k=12k
- As a direct point, a total of 12 records can be recorded, so the total size is as shown above
- Indirect: 256*1k=256k
- Each block number of records will take 4bytes, so the size of 1K can record 256 records, so an indirect can record the size of the file as above;
- Double indirect: 1k=2562 K
- The first block will specify 256 second level, each second layer can specify 256 numbers, so the total size is as above;
- Three indirect: 256*1k=2563 K
- The first block will specify 256 second level, each second layer can specify 256 third layer, each third layer can specify 256 numbers, so the total size is as above;
- Total: Direct, indirect, double indirect, three indirect plus total, get the + + + +-256*256 (K) = 16GB
- At this point we know that when the file system to the block format 1K size, can accommodate the largest file is 16GB, compare the file system limit table results can be found to be consistent!
- However, this method can not be used in 2K and 4K block size calculation, because the block larger than 2K will be limited by the Ext2 file system itself, so the results of the calculation will not be in line with
File system size vs. Disk read performance
About the efficiency of the file system, when one of your file system planning is very large, such as 100GB is so large, because the data on the disk always come and go, so the entire file system above the file usually cannot be written together (block number is discontinuous), Instead, fill in the data into blocks that are not being used. If the file is written to the block really scattered, at this time there will be so-called file data discrete problem occurred.
As mentioned earlier, although our ext2 in the Inode has been recorded in the block number of the file, so the data can be read one time, but if the file is really too discrete, there will still be a low read efficiency problem. Because the disk read head still has to come and go in the entire file system to read frequently! If so, the entire file system can be copied all the data, the file system reformat, and then copy the data to him to solve the problem.
In addition, if the file system is really too large, then when a file is recorded in the first and last block number of the file system, this will cause the disk's mechanical arm movement is too large (not still divided?). ) can also result in low data read performance. The read head also spends more time searching for the entire file system. So zoning planning is not as big as it is, it's really about planning for your mainframe use.
Everything in Linux files
Various things in Linux such as documents, directories (called folders under Mac OS X and Windows), keyboards, monitors, hard drives, removable media devices, printers, modems, virtual terminals, inter-process communication (IPC) and network communication input/ Output resources are byte streams that are defined in file system space.
Everything can be viewed as a file, and the most significant benefit is that the same set of Linux tools, utilities, and APIs are required for the input/output resources listed above. You can use the same set of APIs (read, write) and tools (cat, redirect, pipeline) to handle most of the resources in UNIX.
The ultimate goal of designing a system is to find atomic operations, and once the atomic operations are locked, the design work becomes simple and orderly. "File" as an abstract concept, its atomic operation is very simple, only read and write, this is undoubtedly a very good model. Through this model, the design of the API can be simplified, the user can use a common way to access any resources, their own corresponding middleware to do a good job of adaptation to the bottom.
The modern operating system introduces files to the solution for information that can be stored independently of the process by long-term storage, and the logical unit that the file creates information as a process can be used concurrently by multiple processes. In UNIX systems, the operating system designs a set of common APIs for I/O operations such as text on disk and input devices such as mouse and keyboard, and network interaction, so that they can be processed uniformly using a byte stream. In other words, everything except the process in a UNIX system is a file, and Linux retains this feature. To facilitate file management, Linux also introduces the concept of catalogs (sometimes referred to as folders). Directories allow files to be managed by classification, and the introduction of directories enables Linux file systems to form a hierarchical directory tree.
Resources
- Brother Bird's Linux private cuisine
Linux File system detailed