Malinux' notes: Difference between revisions

From Roy's somewhat wise thoughts
Jump to navigation Jump to search
Line 67: Line 67:
</syntaxhighlight>
</syntaxhighlight>
You know have changed scheduler to bfq
You know have changed scheduler to bfq
To make this survive a reboot you can add this snippet I borrowed from the arch wiki that
To make this survive a reboot you can add this snippet I borrowed from the [https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler arch wiki] that
set scheduler based on hard drive type. none for nvme, mq-deadline for ssd and none for nvme
set scheduler based on hard drive type. none for nvme, mq-deadline for ssd and none for nvme
Add the snippet to /etc/udev/rules.d/60-ioschedulers.rules
Add the snippet to /etc/udev/rules.d/60-ioschedulers.rules

Revision as of 14:57, 21 November 2021

HDD hacks

Disable NCQ

Disabling NCQ (Native Command Queuing) can in some circumstances improve performance on HDD's

# To check if ncq is already off, its' likely not if you haven't already turned it off
cat /sys/block/sdX/device/queue_depth
# it will return 32 if it's on and 1 if it's turned off
# To turn it off:
echo 1 > /sys/block/sdX/device/queue_depth

To have this survive a reboot and disable ncq for all your hdd's or ssd's we can make a systemd script First we'll make a bash script that the systemd script run

#!/bin/bash
disker=$( lsblk -d | awk '/^sd/ { print $1 }' )
# echo $disker

for disk in $disker
do
    q="/sys/block/$disk/device/queue_depth";
    newq=1;
    echo $newq > $q;
done

Put the script in /usr/local/bin/disable_ncq.sh and make it executable

chmod +x /usr/local/bin/disable_ncq.sh

Then we go on to make the systemd script itself.

Create /etc/systemd/system/disable-ncq.service and add:

# vim:isfname-==
[Unit]
Description=HDD queuing

[Service]
Type=oneshot
ExecStart=/usr/local/bin/disable_ncq.sh

[Install]
WantedBy=multi-user.target

Then we need to enable and start the script:

systemctl enable disable-ncq.sh
systemctl start disable-ncq.sh

BFQ I/O scheduler

I use BFQ btw. BFQ is a bloody fast I/O scheduler, best suitable with HDD's.

 /sys/block/sdX/queue/scheduler
# the output from the cat command now will show
mq-deadline [bfq] none

You know have changed scheduler to bfq To make this survive a reboot you can add this snippet I borrowed from the arch wiki that set scheduler based on hard drive type. none for nvme, mq-deadline for ssd and none for nvme Add the snippet to /etc/udev/rules.d/60-ioschedulers.rules

# set scheduler for NVMe
ACTION=="add|change", KERNEL=="nvme[0-9]n[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}="mq-deadline"
# set scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"

source: https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler