Improving Linux Disk I/O in Hyper-V

One of the complaints typically heard about Hyper-V is that Linux performance is just not there. Here is a tip you can use that will improve your Linux VM performance by 20% to 30%.

Linux kernel 2.6 and newer offer four different I/O elevators (four different algorithms to accommodate different workloads and provide optimal performance).

These elevators are:

Anticipatory, CFQ and Deadline are great algorithms, but in a virtual machine these are bottlenecks since the hypervisor is responsible for mapping the virtual to physical storage. It is highly recommended that you set the elevator algorithm to NOOP which is the leanest and simplest elevator for virtualized environments. It allows the hypervisor to assign the ideal elevator and that results in better performance for Linux VMs. The only requirement is that your Linux distribution must have kernel version at lease 2.6.

In order to change the default elevator alrogithm, open /etc/default/grub file in your favorite text editor and add ‘elevator=noop’ at the end of the line (but inside the double quotes).

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"

After you make the change, run ‘sudo update-grub2’

vim /etc/initramfs-tools/modules
# append lines:
hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc
#save
update-initramfs -u
reboot