File system: Manage files to achieve file name access:
Rootfs: Root file system
Leaf node: file (the last level to be unable to store other files)
The file system is provided by the kernel and the data is stored on the hard disk, and the program does not communicate directly with the hardware, initiating the request to the kernel via the kernel-provided interface (System call)
The kernel does the work, but the system calls are too low, and multiple system calls are encapsulated into more advanced interfaces to provide upper-level application use, these packages
After the system calls the library (API), through the library to use some features, such as read write execution delete calls.
MBR: Total 512 bytes (0 sectors of hard disk) boot the operating system on the entire disk
446 bytes: bootloader
64 bytes: Partition table
2 bytes: Whether the disk is bootable
Each partition first two sectors (1024 bytes) boot block: Boot blocks: Used to boot the operating system on the partition
The filesystem will be partitioned into 3 parts, the Boot block index store, and the storage zoning divided into blocks, 1K 2K 4 K, the file system will give
These blocks are numbered (block numbers) and are based on the corresponding relationships within the index to determine which blocks the data is stored in.
Index information (metadata): File size permission is the label of the block corresponding to the time stamp data of the main group (disk block pointer implementation)
Disk Block pointers: If the data is too large to occupy chunks, and the data block label information stored in the inode, resulting in indoe is too large, in order to solve this problem, the use of hierarchical structure:
If it is a small file, the disk block pointer will directly point to the data block (direct pointer), if the file is too large, using a level two pointer to a region, the area indicates that this is an area, this area contains a portion of the disk block designator information, thus saving indoe space
Each file will have an entry, each of which is referred to as: Index node
The entire space is called an index, and each entry is called an index node: inode: File metadata: Not related to data content
For easy lookup, each inode has a number: Inode number
Directory: Path mapping of files: Directories are also files, there are indoe entries, and data is stored on hard disk blocks
Directory disk block data: The type of file name file that corresponds to the indoe number of files in this directory
The directory contains only the first-level subdirectory information in the directory, does not contain the file information in subdirectories, and the file information in subdirectories is stored in subdirectories.
If there is a log directory below/Var, var only need to log the log information, and log the following file information, there is a log record)
Such as: How file system find/var/log/messages this file
1. First, according to the inode number of the root (root will be self-reference), find the root of the inode, through the inode to find the corresponding disk block, this disk block contains var This file's inode number and corresponding file name and type,
2. Through the Var inode number, to find the corresponding indoe, through the Var inode information to find the disk block var this file, through the disk block data to find the log directory inode number and the corresponding file name and type of files
3. Through the inode number of log, find the log indoe to determine the disk block, through the disk block stored in the memssages the file's inode number and corresponding file name, determine which disk block, and finally read the contents of messages
Create a file
1. Find an idle Iode, free disk block
Inode bitmap: One bit for each inode, 0 for idle, 1 for occupancy
Block Inode bitmap: One bit for each block, 0 idle, 1 occupied
Block group: Blocks (the number of blocks in the group is equal)
By dividing too many blocks into different groups, when looking for an idle inode or block, you can scan a set of bitmaps, determine the idle according to the bitmap, and if a group is not enough, you can reference it across groups
Each group is self-managing
The 2nd 1024 byte of the disk is called: Super Block (block Group 0 Super Block)
Super BLOCK: Stores how many groups are on the disk, from which block to the end of each group
GDT: Block Group Description Table: where the block bitmap holds the Inode graph where the inode table holds the free block idle Inode
Each block group has its own: Inode table block bitmap inode bitmap GDT
Tune2fs-l: View Super Block
F
DUMPE2FS: Output ext File System Information
-H: Show Super Block information
Du directory: View the file size and total size of the directory
-S: View only the directory size
-H: Unit conversion, show the more intuitive way
DF: Display disk-related information
-L: Disk information Total capacity block with block idle block using proportional mount point
-H: humanized display
-p:posix-compatible style display
-i:indoe Related Information
Delete
1. Clear the Inode data for the file. Categorize inode to unused
2. The block data is not cleared by default, only the disk block is classified as unused, and if used in the future, directly overwrite
Copy
1. Find free blocks to copy the data into and create a new inode
Move (same partition)
1. Create an entry in the new path that points to the original inode
2. Delete the corresponding entry of the original path, the inode of the file and the database is not moved
Move (not a partition)
1. Create a new file, delete old files
Link files ln-s original file link file
Soft Connect (symbolic Link)
Ls-l file Link file type L
Whether the test file is a soft connection file in bash
1. Can cross-partition, can be created for all files, including directory
2. Delete the original file, the linked file will not be used
3. All linked files, with the original file pointing to different inode, not the same file
Hard Link ln Original file link file
1. Two different paths point to the same inode, using the same disk block
2. Delete a path, not the inode of the file, know the last path on the file to delete
3. Hard connections cannot span partitions and cannot establish hard connections to directories
Ls-l 2nd column shows the number of times the file was hard connected
Ls-i displaying the inode of a file
4. All connections point to the same inode, so they are the same file
Ext System File System: Extended Properties
Lsattr Show Extended Properties
Chattr Modifying Extended Properties
-A: Only append content is allowed
-I: becomes a read-only file for everyone, including root
Compressed Decompression Archive
Compression: TAR-CZVF test.tar.gz/test
-C: Create compression
-Z: Using gzip compression
Zip format zip test.zip test
Zip Format decompression Uzip test.zip
Decompression: TAR-XVF test.tar.gz
-C: Specify the decompression path
DD command
DD if= Original file of= target file
This article is from the "Hanging Sword" blog, please be sure to keep this source http://sublime.blog.51cto.com/8856101/1538528