• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to persistently set nr_requests using UDEV rules

by admin

The nr_requests is a parameter for block device, it controls maximum requests may be allocated in the block layer for read or write requests, the default value is 128. Occasionally, it may be suggested to adjust the value, generally speaking:

  • Increasing the value will improve the I/O throughput, but will also increase the memory usage.
  • Decreasing the value will benefit the real-time applications that are sensitive to latency, but it also decreases the I/O throughput.

This post elaborates on how to set the parameter permanently across system reboots.

1. Create a new udev rule.

For example, create the file /etc/udev/rules.d/71-nr-requests.rules, with the following content:

SUBSYSTEM!="block", GOTO="end_rule"
ENV{DEVTYPE}=="partition", GOTO="end_rule"
ACTION!="add|change", GOTO="end_rule"
KERNEL=="sd*", ATTR{queue/nr_requests}="256" 
LABEL="end_rule"

The rules above will set nr_requests to 256 for all sd* devices, if you need to blacklist some (e.g. sda, and sdb), use the rules like:

SUBSYSTEM!="block", GOTO="end_rule"
ENV{DEVTYPE}=="partition", GOTO="end_rule"
ACTION!="add|change", GOTO="end_rule"
KERNEL=="sda|sdb", GOTO="end_rule"
KERNEL=="sd*", ATTR{queue/nr_requests}="256"
LABEL="end_rule"

2. Apply the rule

Before applying the rule verify the value of “nr_requests” parameter:

$ grep "" /sys/block/sd*/queue/nr_requests
/sys/block/sda/queue/nr_requests:128
/sys/block/sdb/queue/nr_requests:128

Apply the rule on CentOS/RHEL 6 or above:

# udevadm trigger

Use this in CentOS/RHEL 5

# udevtrigger

After applying the rule verify the “nr_requests” parameter value:

$ grep "" /sys/block/sd*/queue/nr_requests
/sys/block/sda/queue/nr_requests:256
/sys/block/sdb/queue/nr_requests:256

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Linux OS Service ‘NetworkManager’
  2. Getting “parsing errors” When Running ‘yum repolist’
  3. How To Increase The Retention Of “sar” Data To ‘N’ Days in Linux
  4. dconf Command Examples in Linux
  5. abbr Command Examples in fish-shell
  6. mkfs.fat: command not found
  7. Why Does “/var/log/messages” Report Martian Packets
  8. Understanding DM-multipath deamon (multipathd)
  9. UbuntuDDE new upcoming Linux distribution
  10. dnstracer Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qsub Command Examples in Linux
  • qsub: command not found
  • qrcp Command Examples in Linux
  • qmrestore Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright