Everything in Linux is file
What are file attributes?
The information contained in the file itself, including: index node number, file type and permissions, number of hard links (backup function), owner, owning group, file size, modification month, modification date, time division
151387-RW-------. 1 root root 1.2K Nov 7 21:57 anaconda-ks.cfg
index node number, the equivalent of a person's identity card, the only one in the country, Linux system only, the system reads the file, first through the filename to find the node number, and then to read the contents of the file
Ll-hi # View file information in the current directory
In Linux, the existence of files and programs must have users and groups to meet the corresponding needs of existence
Strictly speaking, the filename is not a file attribute
Stat file to see the detailed properties of a file
Echo ' Hello word! ' > Name.txt # Analog Data stat Name.txt # querying file information
Results:
File: ' Name.txt ' size:12 blocks:8 IO block:4096 regular filedevice:803h/2051dinode:151735 Links:1access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) access:2017-11-21 16:11:18.435976522 +0800modify:2017-11-22 15:19:37.993143055 +0800change:2017-11-22 15:19:37.993143055 +0800# contains file names, File size, inode node number, permission information, hard link information, access time, change time, modification time, file permissions, owner, owning group, and other information
What is an index node?
Inode index Node
The hard disk is first partitioned and then formatted to create the file system (ETX4), and after partitioning there are Inode (many) and blocks (many) two pieces of content
Inode: Storing data attribute information (ls-l result), including pointers to file entities, except for filenames
Role: Indexing information for each file
Block: Store file Data contents
Inode is a size, Centos5, non-boot partition 128 bytes, CENTOS6, non-boot partition 256 bytes,/boot partition inode is 128 bytes, partition is formatted after the file system is created, the format cannot change its size, Enterprise environment does not change requirements
How do I query Inode and block usage?
Df-i # Querying the I and the remaining I for each partition already used
Df-h # Query partition block usage
Inode Summary:
- After the disk partition is formatted as a etx4 file system, a certain number of inode and block
- Inode holds file property information and pointers to file entities
- EXT3/EXT4 file system block storage file actual data
- The inode representation is a string of numbers, and the inode corresponding to the file is unique in the OS
- EXT3/EXT4 file system, normally a file is created and can only occupy one inode and occupy at least one block, large files occupy multiple blocks, if a block is not occupied, the remaining space will not be used
- Block size generally has 1k,2k,4k, except the boot partition 1k, the other partition is 4k
block Summary:
- Disk read data is read by block
- A file can occupy multiple blocks, and each block reads a disk IO. To improve IO performance, try to read as many as possible
-
- Span style= "font-family:"microsoft yahei"; Font-size:18px "> According to business requirements, determine the block size, for large file settings block larger, for small file block smaller, you can choose to consume disk space for performance
- disk partition format when set, command: Mkfs.ext4-b 2048-i 256 -B Set block size,-I set inode size
- Enterprise files generally relatively large, EXT3/EXT4 generally set to 4k,centos file system for XFS file system, the production environment file system for 4k
Read the file process?
Find the file name first, and then read the inode, verify that you have permission to view the file through the Inode, and then point to the Inode to read the file data
Linux_inode and Block