Malinux' notes: Difference between revisions

From Roy's somewhat wise thoughts
Jump to navigation Jump to search
Line 5: Line 5:
# To check if ncq is already off, its' likely not if you haven't already turned it off
# 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
cat /sys/block/sdX/device/queue_depth
# it will return 32 if it's on
# it will return 32 if it's on and 1 if it's turned off
# To turn it off:
# To turn it off:
echo 1 > /sys/block/sdk/device/queue_depth
echo 1 > /sys/block/sdX/device/queue_depth


</syntaxhighlight>
</syntaxhighlight>
To have this survive a reboot and work for all your hdd's or ssd's we can make a systemd script
First we make a bash script that the systemd script run
<syntaxhighlight lang="bash">
#!/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
</syntaxhighlight>
Put the script in /usr/local/bin/disable_ncq.sh and make it executable
<syntaxhighlight lang="bash">
chmod +x /usr/local/bin/disable_ncq.sh
</syntaxhighlight>
Then we go on to make the systemd script itself.
Create /etc/systemd/system/disable-ncq.service and add:
<syntaxhighlight lang="bash">
# vim:isfname-==
[Unit]
Description=HDD queuing
[Service]
Type=oneshot
ExecStart=/usr/local/bin/disable_ncq.sh
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
Then we need to enable and start the script:
<syntaxhighlight lang="bash">
systemctl enable disable-ncq.sh
systemctl start disable-ncq.sh
</syntaxhighlight>
===BFQ I/O scheduler
I use BFQ btw. BFQ is a bloody fast I/O scheduler, best suitable with HDD's.
source: https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler

Revision as of 03:54, 21 November 2021

Disable NCQ

Disabling NCQ (Native Command Queuing) can in some circumstances improve performance

# 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 work for all your hdd's or ssd's we can make a systemd script First we 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. source: https://wiki.archlinux.org/title/Improving_performance#Changing_I/O_scheduler