Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the role of Inode and Block in Centos

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces what is the role of Inode and Block in Centos. The content is very detailed. Interested friends can use it for reference. I hope it will help you.

Knowledge of inode and block of linux:

1 > after the Linux system partition formats the file system, the system is divided into two parts: Inode and Block:

1) Inode is the attribute information of the system file (the result of ls-l) and a pointer to the file entity, but it does not store the file name, usually in the Block in the parent directory.

2) Block is used to store data. Ext3/ext4 is generally 1k, 2k, 4k, and generally defaults to 4k.

3) No matter how large a file is, it takes at least one Inode and one Block, a Block can only store the contents of one file, the number of block is greater than the number of Inode, and multiple files can occupy the same inode (hard link).

4) access the file through file-- > inode (verify permissions)-> blocks.

5) inode generally defaults to 256B MagneBlock size 1k, 2kMagne4k, and 4k by default. Note that special partitions such as boot partitions are excluded.

6) check the quantity and usage of inode through df-I, and check the size and quantity of inode and block by dumpe2fs / dev/sda1.

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

8) the bigger the block, the better. Choose according to the file size of the business. Generally, the default is 4k.

9) you can change the size of inode and block when formatting, using mkfs.ext4-b 2048-I 1024 / dev/sdb2

2 > the function of the df command in Linux is to check the disk space usage of the file system of the linux server. You can use this command to get information such as how much space the hard disk is occupied and how much space is left.

1. Command format:

Df [options] [File]

two。 Parameters:

Df-I to check the number of parameters

[root@techW] # df-iFilesystem Inodes IUsed IFree IUse% Mounted on/dev/mapper/vg_techw-lv_root 1152816 55846 1096970 / tmpfs 125596 1 125595 / dev/shm/dev/sda1 128016 38 127978 1 / boot

Df-h view disk size:

[root@techW ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_techw-lv_root 18G 1.5G 15G 9% / tmpfs 491M 0491M 0% / dev/shm/dev/sda1 477M 36M 416M 8% / boot

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

[root@techW ~] # dumpe2fs / dev/sda1 | grep-I "block size" dumpe2fs 1.41.12 (17-May-2010) Block size: 1024 [root@techW ~] # [root@techW ~] # [root@techW ~] # dumpe2fs / dev/sda1 | grep-I "inode size" dumpe2fs 1.41.12 (17-May-2010) Inode size: 128 # boot partition is 128 The regular partition is 256 [root@techW ~] # [root@techW ~] # [root@techW ~] # dumpe2fs / dev/sda1 | grep-I "inode count" dumpe2fs 1.41.12 (17-May-2010) Inode count: 128016 [root@techW ~] # [root@techW ~] # 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 Inode and Block, mount and check the number of Inode and Block of the hard disk:

1) add a 5G disk, set it to / dev/sdb,fdisk partition for convenience, and then format it with mkfs.ext4

(add a 5G hard disk to the virtual machine, partition, format)

[root@techW] # 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 # to make a distinction Select 2First cylinder (1-652, default 1): Using default value 1Last cylinder, + cylinders or + size {K Magna M Magi 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.

Parameter commands when partitioning:

A toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitionl list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only) [root@techW ~] # mkfs.ext4 / dev/sdb2mke2fs 1.41.12 (17-May-2010) Filesystem label=OS Type: LinuxBlock size=4096 (log=2) # 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 (32768blocks): 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) # # the size of the inode ranges from 128 to 2048, and the size of the inode ranges from 1024 to 4096.

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

[root@techW] # 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,11468,147456,409600,4423688028161327104 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 Inode and Block:

[root@techW ~] # dumpe2fs / dev/sdb2 | grep "Inode size" dumpe2fs 1.41.12 (17-May-2010) Inode size: 2048 # size changed successfully [root@techW ~] # s / dev/sdb2 | grep "Block size" dumpe2fs 1.41.12 (17-May-2010) Block size: 2048 # about the role of Inode and Block in Centos I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report