You can set a given disk scheduler for specific block devices by using the udev rules. The setting persists across system reboots.
About this task
When configuring udev rules to set a disk scheduler, replace:
- device with the name of the block device, for example
sdf and
- selected-scheduler with the disk scheduler that you want to set for the device, for example
bfq.
Procedure
-
Find the system unique identifier of the block device:
$ udevadm info --name=/dev/device | grep -E '(WWN|SERIAL)'
E: ID_WWN=0x5002538d00000000
E: ID_SERIAL=Generic-_SD_MMC_20120501030900000-0:0
E: ID_SERIAL_SHORT=20120501030900000
Note This command returns all values identified as a World Wide Name (WWN) or serial number associated with the specified block device. Although using a WWN is preferred, it is not always available for every device. In such cases, you can use any value returned by the example command as the device system’s unique ID.
-
To configure the
udev rule, create the /etc/udev/rules.d/99-scheduler.rules file with the following content:
ACTION=="add|change", SUBSYSTEM=="block", ENV{IDNAME}=="device system unique id", ATTR{queue/scheduler}="selected-scheduler"
Here:
- Replace IDNAME with the name of the identifier being used (for example,
ID_WWN).
- Replace device system unique id with the value of the chosen identifier (for example,
0x5002538d00000000).
-
Reload
udev rules:
# udevadm control --reload-rules
-
Apply the scheduler configuration:
# udevadm trigger --type=devices --action=change
Results
- Verify the active scheduler:
# cat /sys/block/device/queue/scheduler