Improve disk performance with Virtio

Virtio disk drivers provide increased performance on virtualised systems by allowing the guest operating system to co-operate directly with the hypervisor – in effect, the drivers “know” they are running in a virtual environment, and can operate more efficiently as a result.

If you have a Linux server already running on ElasticHosts’ cloud, this short tutorial is designed to help you optimise performance by switching your drives to Virtio block devices. Drivers for Virtio are built into most modern versions of Linux as standard, so switching disk devices over can be as simple as editing two configuration files and rebooting the server with the drives attached as virtio block devices.

Editing boot settings can be daunting, so it’s important to know that any problems can be quickly and easily corrected using only a Linux LiveCD.

Step 1: Check your operating system has the virtio drivers in place

The drivers are built into all recent versions of Debian and Ubuntu, and RHEL/CentOS versions greater than 5. Most BSDs require the Virtio drivers to be explicitly installed. You can run the following command to check if your Linux kernel has the correct drivers:

modprobe virtio_blk  
grep virtblk /proc/devices  

Note that distributions based on the RHEL 5.x tree do not have these drivers available at boot. If you are using one of these, you must run the following command in order to create a new initramdisk:

mkinitrd --with virtio --with virtio_blk --with virtio_net --with virtio_pci -f /boot/initrd-$(uname -r).img $(uname -r)  

Step 2: Rename your disk devices within Linux

Next we need to tell Linux where to find the disks when it reboots. Whereas disks connected by IDE or SATA disks will be labelled by Linux as /dev/sda (or, in some cases, /dev/hda), Virtio disks are labeled as /dev/vda. We need to tell the operating system to look for this change when it reboots. In order to do this, we must edit two files: the bootloader configuration file, and the filesystem table. Where you find the first one of these will depend on your bootloader. If you’re using one of ElasticHosts’ preinstalled images, this file is found at:


If you’re not using one of our preinstalled images, you may need to know the location of your bootloader configuration file. The default GRUB2 configuration used on Ubuntu and many other current Linux distributions does not require you to make any changes. If you’re using another bootloader (such as an older version of GRUB), the procedure is essentially the same – simply change all instances of “/dev/sda” (or “/dev/hda”) to “/dev/vda”. For example, if you see an entry reading /dev/sda1, change it to /dev/vda1, and so on. Next, do exactly the same for the filesystem table. This is located in:


You may find on some versions of Linux that one or both of these files references the disk by UUID, or by logical volume instead of device name. If this is the case, you do not need to change anything in these files.

Step 3: Change your server’s disks in the Elastichosts Control Panel

Once you are happy with the above changes, shut down your server, and click ‘Edit’ to open the Server Configuration page. You will need to expand the ‘Drives’ tab to see all available options: Change your server's disk in the Elastichosts control panelChange the disks to Virtio block devices as shown below:

Virtio block

Optionally, click ‘Configure’ to save your changes before moving on to the final step.

Step 4: Start your server

Click ‘Start’ to run your server. It should boot as normal – you are now using Virtio disks.