Ubuntu 16.04磁盘I/O调度器修改及无选项时设置noop咨询
Hey there, let's break down how to fix this when your disk doesn't show I/O scheduler options on Ubuntu 16.04 and you want to set the noop (or its modern equivalent) scheduler.
First, let's understand why you might not see scheduler options:
- Modern SSDs or virtual block devices (like cloud disks, VMware volumes) often use the blk-mq (multi-queue) subsystem instead of the traditional single-queue schedulers. The old
noop,cfq, anddeadlineschedulers don't apply here—instead, you'll need their multi-queue counterparts. - Some disk types (especially high-performance virtual storage) bypass traditional schedulers entirely because they handle IO optimization at the hardware/hypervisor level.
Step 1: Diagnose your disk and kernel setup
First, confirm what's going on with your disk. Replace <your-disk> with your actual disk name (e.g., sda, nvme0n1):
# Check current scheduler (if any) cat /sys/block/<your-disk>/queue/scheduler # Check if blk-mq is enabled lsmod | grep blk_mq
If the scheduler output is empty or shows none, you're dealing with a blk-mq device.
Step 2: Temporarily set the equivalent of noop for blk-mq
For blk-mq devices, the "noop" equivalent is mq-none. Set it temporarily with:
echo mq-none | sudo tee /sys/block/<your-disk>/queue/scheduler
Verify it worked by re-running the scheduler check command—you should see [mq-none] marked as active.
Step 3: Make the setting permanent
Temporary changes vanish on reboot, so use one of these methods to make it stick:
Method 1: Udev Rules (per-disk control)
Create a udev rule file to apply the scheduler automatically when the disk is detected:
sudo nano /etc/udev/rules.d/60-scheduler.rules
Add this line (replace <your-disk> with your disk name, or use SUBSYSTEM=="block" to target all disks):
ACTION=="add|change", KERNEL=="<your-disk>", ATTR{queue/scheduler}="mq-none"
Save the file, then reload udev rules to apply immediately:
sudo udevadm control --reload-rules sudo udevadm trigger
Method 2: Grub Kernel Parameters (system-wide)
If you want all disks to use mq-none, edit your grub config:
sudo nano /etc/default/grub
Find the GRUB_CMDLINE_LINUX_DEFAULT line and add elevator=none (this maps to mq-none for blk-mq devices):
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=none"
Update grub and reboot:
sudo update-grub sudo reboot
Step 4: Special Cases (Virtual/Cloud Disks)
If you're on a cloud server (AWS, Azure, etc.) or using virtualized storage:
- Some cloud providers optimize their storage IO already, so double-check if changing the scheduler actually improves performance.
- If the
blk_mqmodule isn't loaded, manually load it first:
Then try setting the scheduler again.sudo modprobe blk_mq
A Quick Note on Performance
For most SSDs or virtual disks, the default mq-deadline scheduler is already well-optimized. Only switch to mq-none if you're dealing with workloads that benefit from minimal IO queuing (like high-throughput databases with their own queue management).
内容的提问来源于stack exchange,提问作者Vikas Saini

