Optimization of Btrfs File System on SSD
Optimize Mounting Parameters
You can use various parameters to optimize the btrfs attached to an SSD in Linux:
#<file system><mount point><type><options><dump><pass>
UUID = <omitted>/btrfs defaults, ssd, discard, noatime, compress = lzo, subvol = @ 01
These parameters have their own advantages and disadvantages. Add them as needed.
Ssd
The btrfs file system has optimized the SSD and added it to the mount parameters.ssdYou can. TRIM/discard is not automatically enabled for this parameter.
Discard
Run the following command to check whether SSD supports TRIM:
sudohdparm-I /dev/sdX |grep TRIM
*DataSetManagement TRIM supported (limit 8 blocks)
If SSD supports the TRIM command, you can enable it in/etc/fstab.discardParameters. We recommend that youdiscardMount parameters are the first choice. According to debian wiki, some SSDS, including Samsung, micron, and inventec, have problems with discard/TRIM and cannot properly handle TRIM commands. The source code of the linux kernel () is as follows ):
/* devices that don't properly handle queued TRIM commands */
{"Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"Crucial_CT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"Micron_M5[15]0_*"," MU01", ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"Crucial_CT*M550*","MU01", ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"Crucial_CT*MX100*","MU01", ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
{"FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
ATA_HORKAGE_ZERO_AFTER_TRIM,},
/* devices that don't properly handle TRIM commands */
{"SuperSSpeed S238*", NULL, ATA_HORKAGE_NOTRIM,},
This parameter is not required and can be customized for periodic operation.fstrimCommand to replace this parameter. before using this command, make sure that SSD supports TRIM. Otherwise, data may be lost. This parameter is not required when the SSD has enough free space or (unallocated) available space.
Noatime
Mount parameters can be addednoatimeBy disabling update of access records, you can reduce unnecessary write operations to improve performance. This option also improves HDD performance. The default btrfs configuration isrelatime.
Compress
Enabling the compression function is usually conducive to improving the transmission performance (not absolute) and saving storage space. Add the following mount parameters:
compress=lzo
Or
compress=zlib
The lzo speed is faster, and the zlib compression rate is higher. Check whether the SSD master is a non-compression master. If the master is a compression Master, this parameter is not recommended.
Write Cache
If the SSD has a Cache, enabling the Write Cache can improve the performance: Disks-> Drive Setting-> Enable Write Cache, but data may be lost when a sudden power failure occurs.
I/O Scheduling
The SSD structure is different from traditional hard disks, and the addressing time is short. The I/O scheduling algorithm can be selected.noopTo reduce latency. Run the following command to view and modify the Scheduler:
Cat/sys/block/sdX/queue/schedue # sdX indicates your device
sudotee/sys/block/sdX/queue/scheduler <<< noop
Note that the above method is not persistent and will be reset after restart. If SSD is the only storage device in the system, consider usingelevator=noopSet kernel parameters to the I/O scheduler. You can also use the udev rule to modify the scheduler, which is also valid for multiple storage devices:
/Etc/udev/rules. d/60-ssd-scheduler.rules # create this file
The file content is as follows:
# set deadline scheduler for non-rotating disksACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="noop"
How to install the desktop environment of workora 21 Workstation Cinnamon on the computer of the Btrfs File System
Makefile Analysis of Btrfs in Linux File System
Kconfig Analysis of Btrfs in Linux File System
Application of Btrfs File System in CentOS
Btrfs details: click here
Btrfs: click here
Https://memo.ink/btrfs-on-ssd/ Author: @ alim0x
Original: Linux https://linux.cn/article-6408-1.html China
This article permanently updates the link address: