Optimize the linux file system and increase the read/write speed

Source: Internet
Author: User
Article Title: optimize the linux File System to improve read/write speed. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Recently I have made something to burn an electronic disk. Suddenly found. After all, this is the first time you know, so you can extract records.

1. The optimized block size indicates the smallest storage unit.

Suppose: Block size 1 K

After each partition is formatted, many blocks are created.

If a file contains 4 kb, four blocks are required.

Even if one block is less than 1 K, one block is used.

Suppose: Block size 4 K

If a file contains 4 kb, only one block is used.

Even if a block is less than 4 K, one block will be used, and the next block will not be used until it is filled up.

In this way, we can see that if your file is large and the data block is small, the file will be split into many very small blocks, the split time and addressing time will take a lot of time. On the contrary, if the data block is larger, the corresponding time will be reduced! But the larger the block, the better! If your block size is 4 K, and your file size is only 1 K, this will waste 3/4 of the space, so it will be determined based on time.

Mkfs. ext3? B 1024/dev/sdb2

The size of each data block is 1024 bytes.

To increase the size of data blocks

Mkfs. ext3? B 4096/dev/sdb2

(The default size behind-B is 4096)

2. node block Optimization

When we read and write data, all the data must be written into the data block. when addressing the data block, it is found based on the number of the data block, assume that there are four data blocks: 1, 2, 3, and 4. If file1 occupies two data blocks, 2 nodes will be allocated in the index area, when reading file1, two nodes are read. If we merge two data blocks, the reading speed can be improved. file1 only needs to find the address once,

-I indicates the size of data blocks used by nodes.

Mkfs. ext3? B 4096-I 8192/dev/sdb2

Each data block represents 4096, and each two data blocks has a number, 4096*2 = 8192

This accelerates the addressing of large files.

Or Mkfs. ext3? B 4096-I 4096/dev/sdb2

A data block is coded with a number.

Can I use tune2fs for instance comparison? L/dev/sdb2 | more View

Inode count node number

Number of Block count

Let's look at the differences between the two commands.

3. Optimization of reserved Blocks

Reserved block-the disk management space reserved by the Administrator. The default value is 5% of the total data block, and this space can only be occupied by the Administrator.

Use: Mkfs. ext3? B 4096-I 8192? M 2/dev/sdb2

Set the percentage of the number of reserved blocks to 2

Example Comparison:

Mkfs. ext3? B 4096-I 8192? M 5/dev/sdb2

Mkfs. ext3? B 4096-I 8192? M 2/dev/sdb2

Use tune2fs? L/dev/sdb2

View reserved block count: The number is different.

In this way, the use of large hard disk space will save a lot of space (3%)

4) tune2fs tool for adjusting ext2/ext3 file system features

-L <device> View File System Information

-C Set the number of mounting times for force self-check

Use tune2fs? L/dev/sdb2 check maximum mount count is 27 by default. Each mount conut is added with 1. After mounting, the system will force self-check.

Use tune2fs? C-1/dev/sdb2

Set negative 1 to avoid

You can also perform manual self-check using fsck.

-I Set the interval for force self-check

Use tune2fs? L/dev/sdb2 check interval the default value is 6 months.

Use tune2fs? C-1-I 0/dev/sdb2

Set to 0

-M Percentage of reserved Blocks

-J: Convert the ext2 file to the ext3 format

The file data format conversion command parameters are not damaged.

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.