LINUX View and modify the block size of the file system

Check the size of the block

tune2fs-l /dev/sda1 | grep "Block size" #Use the tune method

The "block size" of Linux here refers to 1024 bytes, and Linux uses 1024-byte blocks as the basic unit of the buffer cache. But the block of the linux file system is indeed different. For example, ext3, 4 system, the block size is 4096. Use the df command to view

E.g:

stat -f . #View the information of this directory

File:"."

    ID: a333db0bd4c06027 Namelen: 255     Type: ext2/ext3

Blocksize: 4096       Fundamental block size:4096

Blocks:Total: 2409635    Free: 2200914    Available: 2078508

Inodes: Total: 613200     Free: 589791

As can be seen, blocksize is 4096 bytes.

Conclusion: For ext3 and ext4 file systems, the default block size is 4096 bytes, which generally does not need to be modified.

 

Modify the size of the block:

When creating a file system, you can specify the block size. If there are some larger files in your file system in the future, using a larger block size will get better performance. Adjusting the block size of the ext2 filesystem to 4096bytes instead of the default 1024bytes reduces file fragmentation, speeds up fsck scans, and speeds up file deletion and read operations. In addition, in the ext2 file system, 5% of the space is reserved for the root directory. For a large file system, unless it is used as a log file, 5% is a bit too much. command can be used

mke2fs -b 4096 -m 1 /dev/hda6 #Change it to 1% and create a filesystem with a block size of 4096byte.

    The size of the block to be used should be confirmed according to the actual work needs. If there are many small files smaller than 4K, consider modifying the block size. However, since the capacity of the hard disk is now very large, and the price is not very expensive, even if it is a mail server, the proportion of files smaller than 4K and larger than 4K is not very different, so it is generally not necessary to modify it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325935309&siteId=291194637