Linux_inode and Block

Source: Internet
Author: User
Tags file permissions

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:

    1. After the disk partition is formatted as a etx4 file system, a certain number of inode and block
    2. Inode holds file property information and pointers to file entities
    3. EXT3/EXT4 file system block storage file actual data
    4. The inode representation is a string of numbers, and the inode corresponding to the file is unique in the OS
    5. 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
    6. Block size generally has 1k,2k,4k, except the boot partition 1k, the other partition is 4k

block Summary:

    1. Disk read data is read by block
    2. A file can occupy multiple blocks, and each block reads a disk IO. To improve IO performance, try to read as many as possible
    3. 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
    4. disk partition format when set, command: Mkfs.ext4-b 2048-i 256  -B Set block size,-I set inode size
    5. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.