Knowledge of the inode and block related to Linux CentOS

Source: Internet
Author: User

This experience is CentOSrelease6.7 (Final), such as the lack of knowledge welcome criticism.

Knowledge about the Inode and block of Linux:

1> Linux system partition format file system, the system will be divided into inode and block two parts:

1) The inode is the system file's attribute information (the result of ls-l) and pointer to the file entity, but does not store the file name, usually in the upper directory block.

2) block for storing data, EXT3/EXT4 General is 1k,2k,4k, general default 4k

3) A file regardless of the size of at least one inode and a block, a block can only hold the contents of one file, the number of blocks is greater than the number of inode, multiple files can occupy the same inode (hard link).

4) Access to the file, through file-->inode (verify permissions)--->blocks.

5) Inode general case default 256b,block size 1k,2k,4k, default 4k, note, boot partition, etc. except for special partitions.

6) dumpe2fs/dev/sda1 View the size and number of inode and block by Df-i to see the number and usage of inode.

7) A block can only be used by one file, if a file is very small block too large, the remaining space is wasted, can not continue to be used by other files.

8) block is not the bigger the better, according to the size of the business file selection, is generally the default 4k.

9) You can change the size of the Inode and block when formatting, using Mkfs.ext4-b 2048-i 1024/DEV/SDB2

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/82/23/wKiom1dMSqnRBvnMAABPsZruOSo170.jpg-wh_500x0-wm_3 -wmp_4-s_1569217546.jpg "title=" 4.JPG "alt=" Wkiom1dmsqnrbvnmaabpszruoso170.jpg-wh_50 "/>






The function of the DF command in 2>linux is used to check the disk space usage of the Linux server's file system. You can use this command to get information about how much space the hard disk is taking up, and how much space is left.
1. Command format:
DF [Options] [file]

2. Parameters:

Df-i view the number of parameters

[Email protected] ~]# df-ifilesystem inodes iused IFree iuse% mounted On/dev/mapper/vg_techw-lv_root             1152816 55846 1096970 5%/tmpfs 125596 1 125595 1%/dev/shm/dev/sda1 128016 127978 1%/boot

Df-h View disk Size:

[Email protected] ~]# df-hfilesystem Size used Avail use% mounted On/dev/mapper/vg_techw-lv_root 18G 1.5G 15G 9%/tmpfs 491M 0 491M 0%/dev/shm/dev/sda1 477M 36M 416 M 8%/boot



View the total and usage of the inode and block for the current system partition:

[[email protected] ~]# dumpe2fs  /dev/sda1 | grep -i  "block  Size "dumpe2fs 1.41.12  (17-may-2010) block size:                1024[[email protected] ~]# [[email protected]  ~]# [[email protected] ~]# dumpe2fs  /dev/sda1 | grep -i   "Inode size" dumpe2fs 1.41.12  (17-may-2010) inode size:                128    ## #boot分区为128, regular partition is 256[ [email protected] ~]# [[email protected] ~]# [[email protected] ~]#  dumpe2fs  /dev/sda1 | grep -i  "Inode count" dumpe2fs 1.41.12   (17-may-2010) inode count:               128016[[email protected] ~]# [[email protected] ~]# dumpe2fs  /dev/sda1 |  grep -i  "Block count" dumpe2fs 1.41.12  (17-may-2010) block count:               512000reserved block count:      25600

3> add a disk, format, change the size of the Inode and block, mount the number of inode and block to view the hard disk:

1) Add a 5G disk, set the/dev/sdb,fdisk partition for ease of differentiation, and then MKFS.EXT4 format

(Virtual machine Add a 5G hard disk, partition, format)

[[email protected] ~]# fdisk  /dev/sdbdevice contains neither a  Valid dos partition table, nor sun, sgi or osf disklabelbuilding  a new dos disklabel with disk identifier 0x2d37eabe. changes will remain in memory only, until you decide to  Write them. After that, of course, the previous content won ' t be recoverable. warning: invalid flag 0x0000 of partition table 4 will be  Corrected by w (rite) warning: dos-compatible mode is deprecated. it ' s  strongly recommended to         switch off  the mode  (command  ' C ')  and change display units to          sectors  (command  ' u '). command  (m for help):   n ### add a new partitioncommand  action   e   extended   p   primary  partition  (1-4) ppartition number  (1-4): 2  ###  for making a distinction, select 2first cylinder   (1-652, default 1):  using default value 1last cylinder, + cylinders or +size{k,m,g}  (1-652, default 652):  using default value  652Command  (m for help):  w   ###  write table to  disk and exitthe partition table has been altered! Calling ioctl ()  to re-read partition table. Syncing disks. The parameter command:   a   toggle a bootable flag  when partitioning   b   edit bsd d isklabel   c   toggle the dos compatibility flag    d   delete a partition   l   list  known partition types   m   print this menu    n   add a new partition   o   create a  new empty dos partition table   p   print the  partition table   q   quit without saving changes    s   create a new empty Sun disklabel    t   change a partition ' s system id   u    change display/entry units   v   verify the partition  table   w   write table to disk and exit   x   extra  functionality  (experts only)


[[email protected] ~]# mkfs.ext4 /dev/sdb2mke2fs 1.41.12  (17-May-2010) Filesystem  label=OS type: LinuxBlock size=4096  (log=2)     ### The default block size is 4096fragment size=4096  (log=2) stride=0 blocks, stripe width=0  blocks327680 inodes, 1309289 blocks65464 blocks  (5.00%)  reserved for  the super userfirst data block=0maximum filesystem blocks=134217728040  block groups32768 blocks per group, 32768 fragments per group8192  inodes per groupSuperblock backups stored on blocks:          32768, 98304, 163840, 229376, 294912, 819200,  884736Writing inode tables: done                             creating journal  (32768 blocks):  donewriting superblocks and filesystem accounting information: donethis  filesystem will be automatically checked every 26 mounts or180  days, whichever comes first.  use tune2fs -c or -i to  override.


2) # # #inode的大小范围为128 -2048,block size range is 1024-4096####


3) Change the block and inode size to 2048:

[[email protected] ~]# mkfs.ext4 -b 2048 -i 2048 /dev/sdb2mke2fs  1.41.12  (17-may-2010) filesystem label=os type: linuxblock size=2048  (log=1) fragment size=2048  (log=1) stride=0 blocks, stripe width=0 blocks326400  inodes, 2618578 blocks130928 blocks  (5.00%)  reserved for the super  userFirst data block=0Maximum filesystem blocks=540016640160 block  Groups16384 blocks per group, 16384 fragments per group2040 inodes  per groupSuperblock backups stored on blocks:          16384, 49152, 81920, 114688, 147456, 409600, 442368,  802816, 1327104,         2048000writing inode  tables: done                             Creating journal  (32768 blocks): donewriting  Superblocks and filesystem accounting information: donethis filesystem will  be automatically checked every 30 mounts or180 days, whichever  comes first.  use tune2fs -c or -i to override.


4) Use the DUMPE2FS command to query the size of the Inode and block:

[Email protected] ~]# DUMPE2FS/DEV/SDB2 | grep "inode size" dumpe2fs 1.41.12 (17-may-2010) inode size:2048 # # #大小更改成功 [[email protected] ~]# S/dev/sdb 2 | grep "Block Size" dumpe2fs 1.41.12 (17-may-2010) block size:2048 # # #大小更改成功


This article is from "Tao" blog, please be sure to keep this source http://xtao16.blog.51cto.com/911643/1784999

Knowledge of the inode and block related to Linux CentOS

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.