I wrote this FAQ entry today …
- What’s the deal with guestfish -i?
- Why does virt-cat only work on a real VM image, but virt-df works on any disk image?
- What does “no root device found in this operating system image” mean?
These questions are all related at a fundamental level which may not be immediately obvious.
At the libguestfs API and guestfish level, a “disk image” is just a pile of partitions and filesystems.
In contrast, when the virtual machine boots, it mounts those filesystems into a consistent hierarchy such as:
/ (/dev/sda2) | +-- /boot (/dev/sda1) | +-- /home (/dev/vg_external/Homes) | +-- /usr (/dev/vg_os/lv_usr) | +-- /var (/dev/vg_os/lv_var)
(or drive letters on Windows).
The libguestfs API however knows nothing about how filesystems are mounted. In general, a disk image that we just made up might not contain an operating system or “mountpoints” at all.
Nevertheless, users expect some tools (like virt-cat) to work with VM paths:
virt-cat fedora.img /var/log/messages
How does virt-cat know that /var is a separate partition?
The trick is a large external program called virt-inspector. Virt-inspector contains all sorts of tests and heuristics, so it can take a disk image about which nothing is known beforehand and work out both what it is, and how filesystems would be mounted.
Some tools, such as virt-cat, virt-edit, virt-ls and virt-tar use the same virt-inspector code to map VM paths. Other tools, such as virt-df and virt-list-filesystems operate entirely at the raw “big pile of filesystems” level of the libguestfs API, and don’t use virt-inspector code.
guestfish is in an interesting middle ground. If you use the -a and -m command line options, then you have to tell guestfish exactly how to add disk images and where to mount partitions. This is the raw API level.
However there is also a guestfish -i (for “inspector”) mode. In this mode, guestfish runs virt-inspector, and then (if successful) virt-inspector runs guestfish a second time with the correct -a and -m options. This is much slower, but usually simpler for the user. They can just do this and it all works:
guestfish -i SomeLibvirtGuest
The error “no root device found in this operating system image” is related to this. It means virt-inspector was unable to locate an operating system within the disk image you gave it. You might see this from programs like virt-cat if you try to run them on something which is just a disk image, not a virtual machine.
Pingback: Implementing simple bash tab completion for guestfish « Richard WM Jones
Pingback: libguestfs news « Richard WM Jones