Understanding Deadline IO Scheduler Tunables

Today we’re going to talk about a topic that’s near and dear to our hearts deadlines. No, not the ones you have for your work or school projects (although those are important too). We’re talking about Linux kernel deadline IO schedulers.

Now, if you’re like me, you might be thinking “what in the world is a deadline IO scheduler?” Well, let us enlighten you! A deadline IO scheduler is a fancy way of saying that it’s a method used by the Linux kernel to manage how data is read and written from your hard drive.

But why do we need this? Why can’t we just leave things as they are? Well, let me tell ya if you have ever experienced slow disk performance or stuttering video playback on your system, it might be because of the default IO scheduler that comes with Linux (which is called ‘noop’).

So, how do we fix this problem and make our systems run faster? By tuning the deadline IO scheduler! Here’s a step-by-step guide to help you out:

Step 1: Open up your terminal or command prompt. If you’re on Ubuntu, press Ctrl + Alt + T to open it up.

Step 2: Run this command to check which IO scheduler is currently in use:

// This code script checks the current IO scheduler in use by accessing the scheduler file in the queue directory of the sda block device.
cat /sys/block/sda/queue/scheduler

Replace ‘sda’ with the name of your hard drive (if you have multiple drives, repeat for each one). If it says ‘noop’, then that means you need to tune things up.

Step 3: Run this command to change the IO scheduler to deadline:


# This script changes the IO scheduler to deadline for the specified hard drive.
# Replace 'sda' with the name of your hard drive (if you have multiple drives, repeat for each one).
# If it says 'noop', then that means you need to tune things up.

# Step 3: Run this command to change the IO scheduler to deadline:

# The following line uses the 'echo' command to print "deadline" and then pipes it to the 'tee' command.
# The 'tee' command takes the input and writes it to the specified file, in this case, the scheduler file for the hard drive.
# The 'sudo' command is used to run the entire command with root privileges.
# The 'tee' command also outputs the input to the terminal, which is then redirected to /dev/null to discard it.
echo "deadline" | sudo tee /sys/block/sda/queue/scheduler > /dev/null

Again, replace ‘sda’ with your hard drive name. This will immediately apply the changes and you should see an improvement in disk performance right away!

Step 4: To make this change permanent across reboots, add these lines to your ‘/etc/rc.local’ file (create it if it doesn’t exist):

# This script changes the I/O scheduler for a hard drive to improve disk performance.

# First, we use the 'echo' command to send the string "deadline" to the 'tee' command, which will write it to the specified file.
# The 'sudo' command gives us root privileges to make changes to the system.
# The 'tee' command will write the string to the specified file, in this case, the scheduler file for the hard drive.
# The '>' symbol redirects the output of the 'tee' command to the 'null' device, essentially discarding it.
# This ensures that the output of the 'tee' command does not interfere with the rest of the script.

echo "deadline" | sudo tee /sys/block/sda/queue/scheduler > /dev/null

# The 'exit' command exits the script with a status code of 0, indicating successful execution.

exit 0

# To make this change permanent across reboots, we need to add these lines to the '/etc/rc.local' file.
# The 'tee' command will append the specified lines to the end of the file.
# The '>>' symbol is used for appending, while the '>' symbol is used for overwriting.
# The '&&' symbol is used to execute the next command only if the previous command was successful.
# The 'echo' command is used to print the specified string to the terminal.
# The 'sudo' command gives us root privileges to make changes to the system.
# The 'tee' command will write the string to the specified file, in this case, the '/etc/rc.local' file.
# The 'exit' command exits the script with a status code of 0, indicating successful execution.

echo "echo 'deadline' > /sys/block/sda/queue/scheduler && exit 0" | sudo tee -a /etc/rc.local > /dev/null

Replace ‘sda’ with your hard drive name and save the changes. This will ensure that the deadline IO scheduler is set up every time you boot your system.

You should now be enjoying faster disk performance thanks to our trusty friend, the deadline IO scheduler.

SICORPS