Mounting KVM image

Richard W.M. Jones rjones at
Sat Jun 12 12:44:58 UTC 2010

On Fri, Jun 11, 2010 at 03:45:39PM -0400, Alex wrote:
> Hi,
> >> Another option is guestfish:
> I have to migrate the image to a remote system because I don't have
> all the tools there to run this. Do you know if guestfish requires a
> kvm kernel and processor, or can it be done with an older processor?
> When I try and mount the image, I see this:
> # guestfish -a systmp-img.img -m /dev/hda1 /bin/ls

You don't need to be root to use libguestfs tools, provided your
normal user has permissions to at least read the image file.

> open /dev/kvm: No such file or directory
> Could not initialize KVM, will disable KVM support
> libguestfs: error: mount_options: mount_options_stub: /dev/hda1: No
> such file or directory

Take it a step at a time:

  guestfish -a systmp-img.img --ro
  ><fs> list-devices
  ><fs> list-partitions
  ><fs> lvs

You can then mount the partition(s) that contain data you want to
read, for example:

  ><fs> mount /dev/vda1 /


  ><fs> mount /dev/some_vg/some_lv /

[There is also a separate command, virt-list-filesystems, which takes
an arbitrary image and lists out the names of the filesystems in that
image that you could mount.]

To make this easier, you can have virt-inspector do all the hard work
of examining your image and finding out how partitions are arranged,
and then get it to mount them up for you.  Just do:

  guestfish -i systmp-img.img --ro

To extract the data, I suggest you use the guestfish tgz-out command
(see the guestfish(1) man page).

If you want to actually mount the partition(s) as filesystems on the
host, you need to use another command, guestmount.  This uses FUSE and
will let you mount the filesystem(s) on a local directory, root
permissions also not needed.  Eventually we'll modify virt-manager so
you can double click on an image and it'll appear mounted, but in the
meantime you'll need to read the manual page guestmount(1).

> I suspect it's because the processor isn't kvm-capable, but it allowed
> me to install and upgrade all the necessary packages...

You don't need KVM, although libguestfs is a lot faster if KVM is


Richard Jones, Virtualization Group, Red Hat
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.

More information about the users mailing list