Configuring Deadline Scheduler for Disks

But first, why we need it in the first place.

You see, when a process requests data from a disk, the kernel has to decide which request gets served next. By default, Linux uses a round-robin scheduler that gives each process an equal chance of getting its data. But sometimes, you want certain processes (like your favorite video game) to have priority over others (like those ***** system updates).

That’s where deadline scheduling comes in! It prioritizes requests based on their deadlines if a request has a closer deadline than another one, it gets served first. This can lead to better performance for time-critical applications and less frustration for you when your game lags because of those ***** system updates.

So how do we enable this magical feature? Well, let’s start by opening up our trusty terminal (or command prompt if you’re on Windows) and running the following command:

# This script sets the I/O scheduler to "deadline" for a specified disk, improving performance for time-critical applications.

# First, we use the "echo" command to print the word "deadline" to the terminal.
echo "deadline"

# Then, we use the ">" symbol to redirect the output of the "echo" command to a specific file.
# In this case, we are redirecting it to the "scheduler" file located in the "queue" folder of the specified disk.
# This file controls the I/O scheduler for the disk.
# Note: <your_disk> should be replaced with the name of the disk you want to modify.
# Example: /dev/sda
# Note: The "queue" folder may be located in a different directory depending on your system.
# Example: /sys/block/sda/queue/scheduler
echo "deadline" > /sys/block/<your_disk>/queue/scheduler

Replace `` with the name of your disk, like `sda`. If you’re not sure which one it is, run this command:

# This script uses the `lsblk` command to list all block devices and then filters the output using `grep` to only show devices starting with "sd".
# The `^` symbol in the `grep` command indicates that the pattern should be found at the beginning of the line.
# This will help identify the disk name, which is usually in the format of "sda", "sdb", etc.

# Replace `<your_disk>` with the name of your disk, like `sda`.
# If you're not sure which one it is, run this command:
# lsblk | grep '^sd'



# First, we use the `lsblk` command to list all block devices.
# Then, we use the `grep` command to filter the output and only show devices starting with "sd".
# We use the `-E` flag to enable extended regular expressions, which allows us to use the `|` symbol to specify multiple patterns.
# The `^` symbol indicates that the pattern should be found at the beginning of the line.
# The `?` symbol after `sd` indicates that the `d` is optional, so the command will also match devices starting with just "s".
# Finally, we use the `-o` flag to specify the output format, which in this case is just the device name.
lsblk | grep -E '^s?d' -o

This will show you a list of all your disks and their names. Once you’ve found the right disk, go back to our first command and replace `` with its name.

That’s it! Your deadline scheduler is now enabled for that particular disk. You can also set a priority level for each request using the following command:

# This script enables the deadline scheduler for a specific disk and sets a priority level for each request.

# First, we need to find the name of the disk we want to enable the scheduler for. 
# Use the command `lsblk` to list all disks and their names.

# Once you've found the right disk, replace `<your_disk>` in the following command with its name.

# This command sets the number of requests to 1 for the specified disk, enabling the deadline scheduler.
echo "1" > /sys/block/<your_disk>/queue/nr_requests

This sets the priority level to 1 (highest) for all requests on that disk. You can adjust this value based on your needs lower values mean lower priorities, and higher values mean higher priorities.

Deadline scheduling is now enabled on your chosen disk with a high priority level. Your video games will thank you (or at least run smoother), and those ***** system updates won’t slow them down anymore.

But remember, this feature can also cause issues if not used properly for example, it may lead to starvation of other processes that have lower priority levels. So use it wisely!

SICORPS