Knowledge about Inode and Block in Centos

Source: Internet
Author: User

Knowledge about Inode and Block in Centos

This experience is handled in CentOSrelease6.7 (Final). If you have any knowledge, please criticize and correct it.

Linux inode and block knowledge:

1> After partitioning and formatting a file system in Linux, the system will be divided into Inode and Block:

1) Inode is the property information (ls-l result) of the system file and the pointer to the file object, but it does not store the file name, which is generally in the Block in the parent directory.

2) Block is used to store data. ext3/ext4 is generally 1 k, 2 k, and 4 k. The default value is 4 k.

3) No matter how large a file occupies at least one Inode and one Block, one Block can only store the content 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 the file through the file --> inode (authentication permission) ---> blocks.

5) inode: Generally, the default value is 256B. The block size is 1 k, 2 k, and 4 k. The default value is 4 k. Note that except for special partitions such as boot partitions.

6) Run df-I to check the inode quantity and usage, and run dumpe2fs/dev/sda1 to check the inode and block size and quantity.

7) a block can only be used by one file. If a small block is too large, the remaining space is wasted and cannot be used by other files.

8) the larger the block, the better. Select the block based on the file size of the business. Generally, the default value is 4 kb.

9) The inode and block size can be changed during formatting. mkfs. ext4-B 2048-I 1024/dev/sdb2

2> in Linux, the df command is used to check the disk space occupied by the file system of the linux server. You can use this command to obtain the space occupied by the hard disk and the remaining space.
1. Command Format:
Df [Option] [file]

2. parameters:

Df-I: Check the number of parameters.

[root@techW~] #df-i FilesystemInodesIUsedIFreeIUse%Mountedon /dev/mapper/vg_techw-lv_root 11528165584610969705%/ tmpfs12559611255951% /dev/shm /dev/sda1 128016381279781% /boot

Df-h:

[root@techW~] #df-h FilesystemSizeUsedAvailUse%Mountedon /dev/mapper/vg_techw-lv_root 18G1.5G15G9%/ tmpfs491M0491M0% /dev/shm /dev/sda1 477M36M416M8% /boot

View the total Inode and Block usage of the current system partition:

[root@techW~] #dumpe2fs/dev/sda1|grep-i"blocksize" dumpe2fs1.41.12(17-May-2010) Blocksize:1024 [root@techW~] # [root@techW~] # [root@techW~] #dumpe2fs/dev/sda1|grep-i"inodesize" dumpe2fs1.41.12(17-May-2010) Inodesize:128 ### The boot partition is 128, and the general partition is 256. [root@techW~] # [root@techW~] # [root@techW~] #dumpe2fs/dev/sda1|grep-i"inodecount" dumpe2fs1.41.12(17-May-2010) Inodecount:128016 [root@techW~] # [root@techW~] #dumpe2fs/dev/sda1|grep-i"blockcount" dumpe2fs1.41.12(17-May-2010) Blockcount:512000 Reservedblockcount:25600

3> Add a disk, format it, change the size of Inode and Block, and mount it to view the number of Inode and Block of the hard disk:

1) Add a 5g disk. For convenience, set it to/dev/sdb, fdisk partition, and then format mkfs. ext4.

(Add a 5G hard disk, partition, and format to the VM)

[root@techW~] #fdisk/dev/sdb DevicecontainsneitheravalidDOSpartitiontable,norSun,SGIorOSFdisklabel BuildinganewDOSdisklabelwithdiskidentifier0x2d37eabe. Changeswillremain in memoryonly, until youdecidetowritethem. Afterthat,ofcourse,thepreviouscontentwon'tberecoverable. Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite) WARNING:DOS-compatiblemodeisdeprecated.It'sstronglyrecommendedto switchoffthemode( command 'c' )andchangedisplay units to sectors( command 'u' ). Command(m for help):n ###addanewpartition Commandaction eextended pprimarypartition(1-4) p Partitionnumber(1-4):2 ### For differentiation, select 2 Firstcylinder(1-652,default1): Usingdefaultvalue1 Lastcylinder,+cylindersor+size{K,M,G}(1-652,default652): Usingdefaultvalue652 Command(m for help):w ###writetabletodiskandexit Thepartitiontablehasbeenaltered! Callingioctl()tore- read partitiontable. Syncingdisks. Command for partitioning parameters: atoggleabootableflag beditbsddisklabel ctogglethedoscompatibilityflag ddeleteapartition llistknownpartitiontypes mprintthismenu naddanewpartition ocreateanewemptyDOSpartitiontable pprintthepartitiontable qquitwithoutsavingchanges screateanewemptySundisklabel tchangeapartition'ssystem id uchangedisplay /entry units v verifythepartitiontable wwritetabletodiskand exit xextrafunctionality(expertsonly)

[root@techW~] #mkfs.ext4/dev/sdb2 mke2fs1.41.12(17-May-2010) Filesystemlabel= OS type :Linux Blocksize=4096(log=2) ### The default Block size is 4096 Fragmentsize=4096(log=2) Stride=0blocks,Stripewidth=0blocks 327680inodes,1309289blocks 65464blocks(5.00%)reserved for thesuperuser Firstdatablock=0 Maximumfilesystemblocks=1342177280 40block groups 32768blockspergroup,32768fragmentspergroup 8192inodespergroup Superblockbackupsstoredonblocks: 32768,98304,163840,229376,294912,819200,884736 Writinginodetables: done Creatingjournal(32768blocks): done Writingsuperblocksandfilesystemaccountinginformation: done Thisfilesystemwillbeautomaticallycheckedevery26mountsor 180days,whichevercomesfirst.Usetune2fs-cor-itooverride.

2) ### the inode size range is 128-2048, and the block size range is 1024-4096 ####

3) change the size of both the Block and Inode to 2048:

[root@techW~] #mkfs.ext4-b2048-I2048/dev/sdb2 mke2fs1.41.12(17-May-2010) Filesystemlabel= OS type :Linux Blocksize=2048(log=1) Fragmentsize=2048(log=1) Stride=0blocks,Stripewidth=0blocks 326400inodes,2618578blocks 130928blocks(5.00%)reserved for thesuperuser Firstdatablock=0 Maximumfilesystemblocks=540016640 160block groups 16384blockspergroup,16384fragmentspergroup 2040inodespergroup Superblockbackupsstoredonblocks: 16384,49152,81920,114688,147456,409600,442368,802816,1327104, 2048000 Writinginodetables: done Creatingjournal(32768blocks): done Writingsuperblocksandfilesystemaccountinginformation: done Thisfilesystemwillbeautomaticallycheckedevery30mountsor 180days,whichevercomesfirst.Usetune2fs-cor-itooverride.

4) run the dumpe2fs command to query the Inode and Block sizes:

[root@techW~] #dumpe2fs/dev/sdb2|grep"Inodesize" dumpe2fs1.41.12(17-May-2010) Inodesize:2048 ### Size changed successfully [root@techW~] # s /dev/sdb2 | grep "Blocksize" dumpe2fs1.41.12(17-May-2010) Blocksize:2048 ### Size changed successfully

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.