Malinux' notes

From Roy's somewhat wise thoughts
Jump to navigation Jump to search

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

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

for disk in $disker
    echo $newq > $q;

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

chmod +x /usr/local/bin/

Then we go on to make the systemd script itself.

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

# vim:isfname-==
Description=HDD queuing



Then we need to enable and start the script:

systemctl enable
systemctl start

BFQ I/O scheduler

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

# 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"


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 ; vi /etc/bind/ ; rndc thaw ; tail -f /var/log/daemon.log