Optimizing File System Parameters
Linux supports multiple file systems, and the performance of each file system varies. Therefore, you can select a file system with better performance, for example, XFS. When creating a file system, you can add some parameters for optimization.
In addition, you can add parameters to improve performance when mounting the file partition in Linux.
Optimizing Drive Mounting Mode nobarrier
Principles
In current Linux, a log file system is usually used. If a system error occurs, the file system can be restored using logs to ensure its reliability. A barrier is added to ensure that logs are written first and then the corresponding data is updated to the drives. This ensures the correctness of drive recovery after the system breaks down, but affects the write performance.
If servers use battery-backed RAID controller cards or use other protection methods, log loss caused by unexpected power-off can be avoided. In this case, you can disable the barrier to improve the performance.
Modification Method
If sda is mounted to the /home/disk0 directory, the default fstab entry is as follows:
1 | # mount -o nobarrier -o remount /home/disk0
|
The nobarrier parameter cannot ensure that the file system logs are written to the drives when the system is powered off abnormally. Therefore, this parameter applies only to the scenario where the RAID controller cards with protection are used.
Using the XFS File System with Better Performance
Principles
XFS is a highly scalable, high-performance, and robust journaling file system. It is perfect for processing large files while ensuring smooth data transmission. Therefore, the XFS file system is preferred if possible.
When creating an XFS file system, you can increase the block size of the file system. This method is more suitable for processing large files.
Modification Method
- Format the drive. Assume that sda1 needs to be formatted.
1# mkfs.xfs /dev/sda1 - Change the block size to 8192 B (the default value is 4096 B).
1# mkfs.xfs /dev/sda1 -b size=8192