1
0
Fork 0
knowledge-base/KB/Linux/Disk Speed.md

2.3 KiB

creation date tags
2022-01-08
note
linux
disk
archlinux

Setting ext4 commit frequency to 60

Arch Wiki reference: https://wiki.archlinux.org/index.php/Ext4#Improving_performance

Another way to improve performance on not-so-fast SSDs is increasing the ext4 commit frequency from every 5 seconds up to 60. Just add commit=60 to the mount options for the boot partition in /etc/fstab:

/dev/sda5    /    ext4    rw,relatime,commit=60    0    1

OR enable fast commit

tune2fs -l /dev/nvme0n1p4 | grep features
tune2fs -O fast_commit /dev/nvme0n1p4

Maintenance for SSD

  • systemctl enable --now fstrim.timer to trim SSD weekly

Using the BFQ scheduler

Arch Wiki reference: https://wiki.archlinux.org/index.php/Improving_performance#Changing_I/O_scheduler

Linux notoriously gets very slow with I/O intensive operations such as moving a lot of files at once and swapping. If you have a spinning hard drive or a not-so-fast SSD, the BFQ scheduler can help improve system responsiveness during I/O intensive operations. I still use a SATA SSD for lack of a faster connector on my laptop and I have perceived significantly better overall performance by using the BFQ I/O scheduler. If your boot disk is a fast NVme SSD it's generally not the best idea to use the bfq scheduler for it, but since the I/O scheduler is set per-disk, it might be a good idea to use it for any spinning hard disk permanently connected to the computer (e.g. a secondary disk to store games and movies).

To set the BFQ scheduler, you need to specify some udev rules to tell Linux what scheduler to use on what kind of disks. For example, you could use the mq-deadline scheduler on your NVme drives and the bfq scheduler on your SSDs. I decided to set my rules in such a way that no scheduler is used for NVme SSDs, but bfq is used for everything else. To do this, create the file /etc/udev/rules.d/60-ioschedulers.rules and fill it in as below:

# set scheduler for NVMe
ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
# set scheduler for SSD and eMMC
ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq"
# set scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"