As we all know, there are four I/O schedulers for Linux kernel to reorder requests with different algorithms:
- NOOP Scheduler
- Anticipatory I/O Scheduler (AS)
- Deadline Scheduler
- Complete Fair Queuing Scheduler (CFQ)
It is recommended to use the NOOP scheduler for Linux Virtual Machines on Hyper-V to obtain better I/O performance. In this article, we will introduce how to turn on the NOOP I/O scheduler for a Linux Virtual Machines on Hyper-V and you can follow the steps below:
1. Check the current-selected I/O scheduler
a. Switch to the root account
Switching to the root account is necessary for many tasks in Linux as the root user account is set aside for administrative access. You can access the command line on your Linux Virtual Machine and entersu or su root to switch to the root account. (Figure 1)
Figure 1.
b. Confirm the currently-selected I/O scheduler
The name of the file that controls the scheduler for a block device is:
/sys/block/Device-Name/queue/scheduler
Assuming that we have a disk named /dev/sda, we can use the command below to view the contents of that virtual file and it will show you the currently-selected scheduler surrounded by square brackets:
# cat /sys/block/sda/queue/scheduler
From figure 2, we can see the current I/O schedule is CFQ.
Figure 2.
2. Set the I/O scheduler as NOOP
In general, we can use the following command to set a specific scheduler:
#echo SCHEDNAME > /sys/block/Device-Name/queue/scheduler
Since we want to set the I/O scheduler to NOOP, we can use the command below:
#echo noop > sys/block/sda/queue/scheduler(Figure 3)
Figure 3.
3. Edit the boot loader's configuration and restart
To add the NOOP scheduler to the boot loader’s configuration, we can add “evevator=noop”to the kernel parameters in the /etc/grub.conf. (Figure 4)
Figure 4.
After all the steps above, we can see that the current-selected I/O scheduler is NOOP. (Figure 5)
Figure 5.
Note: After you finish the step 2, you can also find the current I/O scheduler will be changed to NOOP. We recommend following the steps 3 in case the setting changes after a reboot.
More information:
Best Practices for running Linux on Hyper-V
http://technet.microsoft.com/en-us/library/dn720239.aspx
How to get the best disk performance with Linux on Hyper-V
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.