Malinux' notes: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== HDD hacks == | |||
=== Disable NCQ === | === Disable NCQ === | ||
Disabling NCQ (Native Command Queuing) can in some circumstances improve performance | Disabling NCQ (Native Command Queuing) can in some circumstances improve performance on HDD's | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 54: | Line 55: | ||
=== BFQ I/O scheduler === | === BFQ I/O scheduler === | ||
I use BFQ btw. BFQ is a bloody fast I/O scheduler, best suitable with HDD's. | I use BFQ btw. BFQ is a bloody fast I/O scheduler, best suitable with HDD's. | ||
<syntaxhighlight lang="bash" | |||
# check what scheduler is in use | |||
cat /sys/block/sdX/queue/scheduler | |||
# you might get a result like this with brackets around the current scheduler: | |||
[mq-deadline] bfq none | |||
# to change this | |||
echo bfq > /sys/block/sdX/queue/scheduler | |||
# the output from the cat command now will show | |||
mq-deadline [bfq] none | |||
</syntaxhighlight> | |||
You know have changed scheduler to bfq | |||
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 | |||
Add the snippet to /etc/udev/rules.d/60-ioschedulers.rules | |||
<syntaxhighlight lang="bash"> | |||
# 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" | |||
</syntaxhighlight> | |||
source: https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler | source: https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler | ||
==DNS with bind== | |||
<syntaxhighlight lang="bash"> | |||
# one liner to edit/add a dns name and make the change persistent and to see in the log afterwards that it works | |||
rndc freeze domain.no ; vi /etc/bind/domain.no.zone ; rndc thaw domain.no ; tail -f /var/log/daemon.log | |||
</syntaxhighlight> |
Latest revision as of 12:33, 10 December 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
DNS with bind
# one liner to edit/add a dns name and make the change persistent and to see in the log afterwards that it works
rndc freeze domain.no ; vi /etc/bind/domain.no.zone ; rndc thaw domain.no ; tail -f /var/log/daemon.log