Linux performance tuning 3: considerations before partitioning and formatting

Source: Internet
Author: User
Talking about linux performance tuning 3: before partitioning and formatting, there is a special situation that may occur in the production environment: an ext3 file partition of the system, when a user writes a file to this partition, the system prompts that the disk space is full. However, when using the df-h command to view the file, the disk usage in this partition is found to be... talking about linux performance tuning 3: before partitioning and formatting, there is a special situation that may occur in the production environment: an ext3 file partition of the system, when a user writes a file to this partition, the system prompts that the disk space is full. However, when you run the df-h command to check whether the disk usage in this partition is 60%, analyze what causes this problem. The answer is that inode is exhausted! Why? Given the structure of an ext * file system, Block and inode must be considered for formatting in Linux. Block is the smallest unit that can be recorded by a disk and is composed of several sectors, therefore, the size is generally n * 512 Bytes, for example, 4 K. So what is inode? A Block is the region where the file content is recorded. inode records the attributes of the file and the information of the Block in which the file is stored. Each inode records the attributes of an archive and the datablock on which the archive is distributed (that is, the pointer we call, and sometimes the index number is also called ). The details are as follows: ● inode number ● used to identify the file type, mode information used for the stat C function ● number of file links ● owner UID ● last access time ● owner group ID (GID) ● file size ● actual number of disk blocks used by the file ● last modification time Summary: inode two functions: recording file attributes and pointers, each file occupies one inode. When the Linux system looks for a file, it first searches for the inode table to find its properties and data storage location, and then finds the Block where the data is stored to retrieve the data. After a partition is formatted as a file system, it will basically have two blocks: inode table and data area. one is used to record the attribute information of the file and the Block stored in the file, the content of a file. A logical concept: Does a block correspond to an inode? The answer is No. although a large file occupies a lot of blocks, only one inode test is used. 1: I add a disk and partition it./dev/sdb5, 100 MB for each 6, 7, and the specified block sizes are 1 k, 2 k, and 4 k. The number of inode structures obtained during 4 k formatting is more than 28000 (-B). conclusion: there is no direct relationship between inode and block! There is a saying on the Internet that "the larger the block, the smaller the inode" is obviously incorrect. 2: I used the-I option to format (-I bytes-per-inode Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. the larger the bytes-per-inode ratio, the fewer inodes will be created. this value generally shouldn't be smaller than the blocksize of the filesystem, since in that case more inodes wocould be made than can ever be used. be Warned that it is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter .) conclusion: The smaller the specified I, the larger the inode. Note that this is irrelevant to the block! It's just the number of custom inode! Note: a file occupies one inode, but at least one block, regardless of the number of blocks, 1 K, 2 K, 4 K. When the file is smaller than blocksize, it occupies one block, the remaining space of this block cannot be used by other files! If multiple blocks are used directly when the file is larger than blocksize, the final conclusion is displayed: (of course, this is not a detailed calculation !) Total partitions/block size> = inode count ------> maximum number of files that can be created = inode count total number of partitions/block size <inode count --------> maximum number of files that can be created = partition total number of files/block size if the partition is provided to large file applications, in general, do not consider the opposite. If the partition is provided to small file applications, you must calculate and format it yourself to avoid inode depletion, ********************************** **************************************** * ***** test 1 data: [root @ shorttop132 ~] # Mkfs. ext3-B 1024/dev/sdb5mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: Linux Block size = 1024 (log = 0) fragment size = 1024 (log = 0) Stride = 0 blocks, Stripe width = 0 blocks 28112 inodes, 112392 blocks5619 blocks (5.00%) reserved for the super userFirst data block = 1 Maximum filesystem blocks = 6737100814 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock back Ups stored on blocks: 8193,245 77, 40961,573 45, 73729 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done [root @ mongotop132 ~] # Mkfs. ext3-B 2048/dev/sdb6mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: Linux Block size = 2048 (log = 1) fragment size = 2048 (log = 1) Stride = 0 blocks, Stripe width = 0 blocks 28160 inodes, 56210 blocks2810 blocks (5.00%) reserved for the super userFirst data block = 0 Maximum filesystem blocks = 576716804 block groups16384 blocks per group, 16384 fragments per group7040 inodes per groupSuperblock back Ups stored on blocks: 16384,491 52 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done [root @ mongotop132 ~] # Mkfs. ext3-B 4096/dev/sdb7mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: Linux Block size = 4096 (log = 2) fragment size = 4096 (log = 2) Stride = 0 blocks, Stripe width = 0 blocks 28128 inodes, 28105 blocks1405 blocks (5.00%) reserved for the super userFirst data block = 0 Maximum filesystem blocks = 293601281 block group32768 blocks per group, 32768 fragments per group28128 inodes per group Writing inode Tables: done Creating journal (1024 blocks): doneWriting superblocks and filesystem accounting information: done *************************************** **************************************** **************************************** * ************************************ test 2 Data: [root @ shorttop132 ~] # Mkfs. ext3-I 1024/dev/sdb5mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: LinuxBlock size = 1024 (log = 0) Fragment size = 1024 (log = 0) stride = 0 blocks, Stripe width = 0 blocks112448 inodes, 112392 blocks5619 blocks (5.00%) reserved for the super userFirst data block = 1 Maximum filesystem blocks = 6737100814 block groups8192 blocks per group, 8192 fragments per group8032 inodes per groupSuperblock backu Ps stored on blocks: 8193,245 77, 40961,573 45, 73729 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or180 days, whichever comes first. use tune2fs-c or-I to override. [root @ shorttop132 ~] # Mkfs. ext3-I 2048/dev/sdb6mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: LinuxBlock size = 1024 (log = 0) Fragment size = 1024 (log = 0) stride = 0 blocks, Stripe width = 0 blocks561_inodes, 112420 blocks5621 blocks (5.00%) reserved for the super userFirst data block = 1 Maximum filesystem blocks = 6737100814 block groups8192 blocks per group, 8192 fragments per group4016 inodes per groupSuperblock backup S stored on blocks: 8193,245 77, 40961,573 45, 73729 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or180 days, whichever comes first. use tune2fs-c or-I to override. [root @ shorttop132 ~] # Mkfs. ext3-I 4096/dev/sdb7mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: LinuxBlock size = 1024 (log = 0) Fragment size = 1024 (log = 0) stride = 0 blocks, Stripe width = 0 blocks28112 inodes, 112420 blocks5621 blocks (5.00%) reserved for the super userFirst data block = 1 Maximum filesystem blocks = 6737100814 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks: 8193,245 77, 40961,573 45, 73729 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or180 days, whichever comes first. use tune2fs-c or-I to override. **************************************** ***************************************
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.