Optimization of Btrfs File System on SSD

Source: Internet
Author: User

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:

  1. #<file system><mount point><type><options><dump><pass>
  2. 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:

  1. sudohdparm-I /dev/sdX |grep TRIM
  2. *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 ):

  1. /* devices that don't properly handle queued TRIM commands */
  2. {"Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
  3. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  4. {"Crucial_CT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
  5. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  6. {"Micron_M5[15]0_*"," MU01", ATA_HORKAGE_NO_NCQ_TRIM |
  7. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  8. {"Crucial_CT*M550*","MU01", ATA_HORKAGE_NO_NCQ_TRIM |
  9. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  10. {"Crucial_CT*MX100*","MU01", ATA_HORKAGE_NO_NCQ_TRIM |
  11. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  12. {"Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
  13. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  14. {"FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
  15. ATA_HORKAGE_ZERO_AFTER_TRIM,},
  16. /* devices that don't properly handle TRIM commands */
  17. {"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:

  1. compress=lzo
  2. Or
  3. 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:

  1. Cat/sys/block/sdX/queue/schedue # sdX indicates your device
  2. 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:

  1. /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:

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.