Mounting a .vhd disk image using blktap/tapdisk: Difference between revisions

From Xen
Jump to navigationJump to search
(Created page with "This page describes how to mount a .vhd disk image on a Linux system, using blktap/tapdisk. This page shows you how to modify and manipulate a .vhd disk image before booting a VM…")
 
No edit summary
Line 9: Line 9:


Other similar formats exist, most notably [[https://people.gnome.org/~markmc/qcow-image-format.html qcow2]] used natively by qemu.
Other similar formats exist, most notably [[https://people.gnome.org/~markmc/qcow-image-format.html qcow2]] used natively by qemu.

== How blktap/tapdisk works ==

"blktap" is a kernel module which is like "tuntap for blocks": it exposes a kernel block device and sends requests to user-space over a shared-memory ring. The only consumer of this ring is "tapdisk": a user-space process which understands the .vhd format (via a shared library called libvhd) and which performs read and write operations via AIO.

Note: when a tapdisk is connected to a blktap, it's important not to interfere with tapdisk (e.g. by killing it) because this will cause in-flight requests on the block device to block.

When tapdisk starts it will call mlockall() to prevent any of its pages being swapped out, which would otherwise lead to deadlocks.

== Prereqs ==

This example assumes Ubuntu 12.04, but similar packages should be available for other distributions. First install the user-space tools and the blktap kernel module (via DKMS):

sudo apt-get install blktap-utils

Revision as of 10:57, 25 November 2013

This page describes how to mount a .vhd disk image on a Linux system, using blktap/tapdisk. This page shows you how to modify and manipulate a .vhd disk image before booting a VM from it.

Overview

A .vhd disk image is a format originally created by Connectix for their Virtual PC and Virtual Server products, sold to Microsoft in 2003. The .vhd format is well-documented and supported by blktap/tapdisk. When using .vhd, blktap/tapdisk enable:

  • thin-provisioning of disks: blocks are only allocated on first write
  • snapshots, clones: gold master images can be used as read-only "parent" disks

Other similar formats exist, most notably [qcow2] used natively by qemu.

How blktap/tapdisk works

"blktap" is a kernel module which is like "tuntap for blocks": it exposes a kernel block device and sends requests to user-space over a shared-memory ring. The only consumer of this ring is "tapdisk": a user-space process which understands the .vhd format (via a shared library called libvhd) and which performs read and write operations via AIO.

Note: when a tapdisk is connected to a blktap, it's important not to interfere with tapdisk (e.g. by killing it) because this will cause in-flight requests on the block device to block.

When tapdisk starts it will call mlockall() to prevent any of its pages being swapped out, which would otherwise lead to deadlocks.

Prereqs

This example assumes Ubuntu 12.04, but similar packages should be available for other distributions. First install the user-space tools and the blktap kernel module (via DKMS):

sudo apt-get install blktap-utils