.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" ======================================================================== .\" .IX Title "guestfs-faq 1" .TH guestfs-faq 1 "2013-12-07" "libguestfs-1.18.1" "Virtualization Support" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" guestfs\-faq \- libguestfs Frequently Asked Questions (FAQ) .SH "ABOUT LIBGUESTFS" .IX Header "ABOUT LIBGUESTFS" .SS "What is libguestfs?" .IX Subsection "What is libguestfs?" libguestfs is a way to create, access and modify disk images. You can look inside disk images, modify the files they contain, create them from scratch, resize them, and much more. It's especially useful from scripts and programs and from the command line. .PP libguestfs is a C library (hence \*(L"lib\-\*(R"), and a set of tools built on this library, and a set of bindings in many different programming languages. .PP For more information about what libguestfs can do read the introduction on the home page (). .SS "What are the virt tools?" .IX Subsection "What are the virt tools?" Virt tools (website: http://virt\-tools.org ) are a whole set of virtualization management tools aimed at system administrators. Some of them come from libguestfs, some from libvirt and many others from other open source projects. So virt tools is a superset of libguestfs. However libguestfs comes with many important tools. See for a full list. .SS "Does libguestfs need { libvirt / \s-1KVM\s0 / Red Hat / Fedora }?" .IX Subsection "Does libguestfs need { libvirt / KVM / Red Hat / Fedora }?" No! .PP libvirt is not a requirement for libguestfs. .PP libguestfs works with any disk image, including ones created in VMware, \s-1KVM\s0, qemu, VirtualBox, Xen, and many other hypervisors, and ones which you have created from scratch. .PP Red Hat sponsors (ie. pays for) development of libguestfs and a huge number of other open source projects. But you can run libguestfs and the virt tools on many different Linux distros and Mac \s-1OS\s0 X. Some virt tools have been ported to Windows. .SS "How does libguestfs compare to other tools?" .IX Subsection "How does libguestfs compare to other tools?" .IP "\fIvs. kpartx\fR" 4 .IX Item "vs. kpartx" Libguestfs takes a different approach from kpartx. kpartx needs root, and mounts filesystems on the host kernel (which can be insecure \- see \&\*(L"\s-1SECURITY\s0\*(R" in \fIguestfs\fR\|(3)). Libguestfs isolates your host kernel from guests, is more flexible, scriptable, supports \s-1LVM\s0, doesn't require root, is isolated from other processes, and cleans up after itself. Libguestfs is more than just file access because you can use it to create images from scratch. .IP "\fIvs. vdfuse\fR" 4 .IX Item "vs. vdfuse" vdfuse is like kpartx but for VirtualBox images. See the kpartx comparison above. You can use libguestfs on the partition files exposed by vdfuse, although it's not necessary since libguestfs can access VirtualBox images directly. .IP "\fIvs. qemu-nbd\fR" 4 .IX Item "vs. qemu-nbd" nbd is like kpartx but for qcow2 images. See the kpartx comparison above. You can use libguestfs and qemu-nbd together for access to block devices over the network. .IP "\fIvs. mounting filesystems in the host\fR" 4 .IX Item "vs. mounting filesystems in the host" Mounting guest filesystems in the host is insecure and should be avoided completely for untrusted guests. Use libguestfs to provide a layer of protection against filesystem exploits. See also \&\fIguestmount\fR\|(1). .IP "\fIvs. parted\fR" 4 .IX Item "vs. parted" Libguestfs supports \s-1LVM\s0. Libguestfs uses parted and provides most parted features through the libguestfs \s-1API\s0. .SH "GETTING HELP AND REPORTING BUGS" .IX Header "GETTING HELP AND REPORTING BUGS" .SS "How do I know what version I'm using?" .IX Subsection "How do I know what version I'm using?" The simplest method is: .PP .Vb 1 \& guestfish \-\-version .Ve .PP Libguestfs development happens along an unstable branch and we periodically create a stable branch which we backport stable patches to. To find out more, read \*(L"\s-1LIBGUESTFS\s0 \s-1VERSION\s0 \s-1NUMBERS\s0\*(R" in \fIguestfs\fR\|(3). .SS "How can I get help? What mailing lists or chat rooms are available?" .IX Subsection "How can I get help? What mailing lists or chat rooms are available?" If you are a Red Hat customer using Red Hat Enterprise Linux, please contact Red Hat Support: .PP There is a mailing list, mainly for development, but users are also welcome to ask questions about libguestfs and the virt tools: .PP You can also talk to us on \s-1IRC\s0 channel \f(CW\*(C`#libguestfs\*(C'\fR on FreeNode. We're not always around, so please stay in the channel after asking your question and someone will get back to you. .PP For other virt tools (not ones supplied with libguestfs) there is a general virt tools mailing list: https://www.redhat.com/mailman/listinfo/virt\-tools\-list .SS "How do I report bugs?" .IX Subsection "How do I report bugs?" Please use the following link to enter a bug in Bugzilla: .PP .Vb 1 \& https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools .Ve .PP Include as much detail as you can and a way to reproduce the problem. .PP Include the full output of \fIlibguestfs\-test\-tool\fR\|(1). .SH "COMMON ERRORS" .IX Header "COMMON ERRORS" .ie n .SS """child process died unexpectedly""" .el .SS "``child process died unexpectedly''" .IX Subsection "child process died unexpectedly" This error indicates that qemu failed or the host kernel could not boot. To get further information about the failure, you have to run: .PP .Vb 1 \& libguestfs\-test\-tool .Ve .PP If, after using this, you still don't understand the failure, contact us (see previous section). .SH "COMMON PROBLEMS" .IX Header "COMMON PROBLEMS" See also \*(L"\s-1LIBGUESTFS\s0 \s-1GOTCHAS\s0\*(R" in \fIguestfs\fR\|(3) for some \*(L"gotchas\*(R" with using the libguestfs \s-1API\s0. .SS "Non-ASCII characters don't appear on \s-1VFAT\s0 filesystems." .IX Subsection "Non-ASCII characters don't appear on VFAT filesystems." Typical symptoms of this problem: .IP "\(bu" 4 You get an error when you create a file where the filename contains non-ASCII characters, particularly non 8\-bit characters from Asian languages (Chinese, Japanese, etc). The filesystem is \s-1VFAT\s0. .IP "\(bu" 4 When you list a directory from a \s-1VFAT\s0 filesystem, filenames appear as question marks. .PP This is a design flaw of the GNU/Linux system. .PP \&\s-1VFAT\s0 stores long filenames as \s-1UTF\-16\s0 characters. When opening or returning filenames, the Linux kernel has to translate these to some form of 8 bit string. \s-1UTF\-8\s0 would be the obvious choice, except for Linux users who persist in using non\-UTF\-8 locales (the user's locale is not known to the kernel because it's a function of libc). .PP Therefore you have to tell the kernel what translation you want done when you mount the filesystem. The two methods are the \f(CW\*(C`iocharset\*(C'\fR parameter (which is not relevant to libguestfs) and the \f(CW\*(C`utf8\*(C'\fR flag. .PP So to use a \s-1VFAT\s0 filesystem you must add the \f(CW\*(C`utf8\*(C'\fR flag when mounting. From guestfish, use: .PP .Vb 1 \& > mount\-options utf8 /dev/sda1 / .Ve .PP or on the guestfish command line: .PP .Vb 1 \& guestfish [...] \-m /dev/sda1:/:utf8 .Ve .PP or from the \s-1API:\s0 .PP .Vb 1 \& guestfs_mount_options (g, "utf8", "/dev/sda1", "/"); .Ve .PP The kernel will then translate filenames to and from \s-1UTF\-8\s0 strings. .PP We considered adding this mount option transparently, but unfortunately there are several problems with doing that: .IP "\(bu" 4 On some Linux systems, the \f(CW\*(C`utf8\*(C'\fR mount option doesn't work. We don't precisely understand what systems or why, but this was reliably reported by one user. .IP "\(bu" 4 It would prevent you from using the \f(CW\*(C`iocharset\*(C'\fR parameter because it is incompatible with \f(CW\*(C`utf8\*(C'\fR. It is probably not a good idea to use this parameter, but we don't want to prevent it. .SS "Non-ASCII characters appear as underscore (_) on \s-1ISO9660\s0 filesystems." .IX Subsection "Non-ASCII characters appear as underscore (_) on ISO9660 filesystems." The filesystem was not prepared correctly with mkisofs or genisoimage. Make sure the filesystem was created using Joliet and/or Rock Ridge extensions. libguestfs does not require any special mount options to handle the filesystem. .SH "DOWNLOADING, INSTALLING, COMPILING LIBGUESTFS" .IX Header "DOWNLOADING, INSTALLING, COMPILING LIBGUESTFS" .SS "Where can I get the latest binaries for ...?" .IX Subsection "Where can I get the latest binaries for ...?" .IP "Fedora ≥ 11, \s-1RHEL\s0 ≥ 5.3, \s-1EPEL\s0 5" 4 .IX Item "Fedora ≥ 11, RHEL ≥ 5.3, EPEL 5" Use: .Sp .Vb 1 \& yum install \*(Aq*guestf*\*(Aq .Ve .Sp For the latest builds, see: .IP "Red Hat Enterprise Linux 6" 4 .IX Item "Red Hat Enterprise Linux 6" It is part of the default install. On \s-1RHEL\s0 6 (only) you have to install \f(CW\*(C`libguestfs\-winsupport\*(C'\fR to get Windows guest support. .IP "\s-1RHEL\s0 6.3" 4 .IX Item "RHEL 6.3" Preview packages are available here: http://people.redhat.com/~rjones/libguestfs\-RHEL\-6.3\-preview/ .IP "Debian Squeeze (6)" 4 .IX Item "Debian Squeeze (6)" Use Hilko Bengen's backport repository: .IP "Debian Wheezy and later (7+)" 4 .IX Item "Debian Wheezy and later (7+)" Official Debian packages are available: (thanks Hilko Bengen). .IP "Ubuntu" 4 .IX Item "Ubuntu" We don't have an Ubuntu maintainer, and the packages supplied by Canonical (which are outside our control) are often broken. Try compiling from source (next section). .Sp Canonical decided to change the permissions on the kernel so that it's not readable except by root. This is completely stupid, but they won't change it (). So every user should do this: .Sp .Vb 1 \& sudo chmod 0644 /boot/vmlinuz* .Ve .IP "Ubuntu 10.04" 4 .IX Item "Ubuntu 10.04" See: http://libguestfs.org/download/binaries/ubuntu1004\-packages/ .IP "Ubuntu 12.04" 4 .IX Item "Ubuntu 12.04" libguestfs in this version of Ubuntu works, but you need to update febootstrap and seabios to the latest versions. .Sp You need febootstrap ≥ 3.14\-2 from: .Sp You need seabios ≥ 0.6.2\-0ubuntu2.1 or ≥ 0.6.2\-0ubuntu3 from: http://packages.ubuntu.com/precise\-updates/seabios or .Sp Also you need to do (see above): .Sp .Vb 1 \& sudo chmod 0644 /boot/vmlinuz* .Ve .IP "Other Linux distro" 4 .IX Item "Other Linux distro" Compile from source (next section). .IP "Other non-Linux distro" 4 .IX Item "Other non-Linux distro" You'll have to compile from source, and port it. .SS "How can I compile and install libguestfs from source?" .IX Subsection "How can I compile and install libguestfs from source?" If your Linux distro has a working port of febootstrap (that is, Fedora, Red Hat Enterprise Linux >= 6.3, Debian, Ubuntu and ArchLinux) then you should just be able to compile from source in the usual way. Download the latest tarball from , unpack it, and start by reading the \s-1README\s0 file. .PP If you \fIdon't\fR have febootstrap, you will need to use the \*(L"fixed appliance method\*(R". See: .PP Patches to port febootstrap to more Linux distros are welcome. .SS "Why do I get an error when I try to rebuild from the source RPMs supplied by Red Hat / Fedora?" .IX Subsection "Why do I get an error when I try to rebuild from the source RPMs supplied by Red Hat / Fedora?" Because of the complexity of building the libguestfs appliance, the source RPMs provided cannot be rebuilt directly using \f(CW\*(C`rpmbuild\*(C'\fR or \&\f(CW\*(C`mock\*(C'\fR. .PP If you use Koji (which is open source software and may be installed locally), then the SRPMs can be rebuilt in Koji. .PP If you don't have or want to use Koji, then you have to give libguestfs access to the network so it can download the RPMs for building the appliance. You also need to set an \s-1RPM\s0 macro to tell libguestfs to use the network. Put the following line into a file called \f(CW\*(C`$HOME/.rpmmacros\*(C'\fR: .PP .Vb 1 \& %libguestfs_buildnet 1 .Ve .PP If you are using mock, do: .PP .Vb 1 \& mock \-D \*(Aq%libguestfs_buildnet 1\*(Aq [etc] .Ve .SS "Libguestfs has a really long list of dependencies!" .IX Subsection "Libguestfs has a really long list of dependencies!" That's because it does a lot of things. .SS "How can I speed up libguestfs builds?" .IX Subsection "How can I speed up libguestfs builds?" By far the most important thing you can do is to install and properly configure Squid. Note that the default configuration that ships with Squid is rubbish, so configuring it is not optional. .PP A very good place to start with Squid configuration is here: .PP Make sure Squid is running, and that the environment variables \&\f(CW$http_proxy\fR and \f(CW$ftp_proxy\fR are pointing to it. .PP With Squid running and correctly configured, appliance builds should be reduced to a few minutes. .SH "SPEED, DISK SPACE USED BY LIBGUESTFS" .IX Header "SPEED, DISK SPACE USED BY LIBGUESTFS" Note: Most of the information in this section has moved: \&\fIguestfs\-performance\fR\|(1). .SS "Upload or write seem very slow." .IX Subsection "Upload or write seem very slow." In libguestfs < 1.13.16, the mount command (\*(L"guestfs_mount\*(R" in \fIguestfs\fR\|(3)) enabled option \f(CW\*(C`\-o sync\*(C'\fR implicitly. This causes very poor write performance, and was one of the main gotchas for new libguestfs users. .PP For libguestfs < 1.13.16, replace mount with \f(CW\*(C`mount\-options\*(C'\fR, leaving the first parameter as an empty string. .PP You can also do this with more recent versions of libguestfs, but if you know that you are using libguestfs ≥ 1.13.16 then it's safe to use plain mount. .PP If the underlying disk is not fully allocated (eg. sparse raw or qcow2) then writes can be slow because the host operating system has to do costly disk allocations while you are writing. The solution is to use a fully allocated format instead, ie. non-sparse raw, or qcow2 with the \f(CW\*(C`preallocation=metadata\*(C'\fR option. .SS "Libguestfs uses too much disk space!" .IX Subsection "Libguestfs uses too much disk space!" libguestfs caches a large-ish appliance in: .PP .Vb 1 \& /var/tmp/.guestfs\- .Ve .PP If the environment variable \f(CW\*(C`TMPDIR\*(C'\fR is defined, then \&\f(CW\*(C`$TMPDIR/.guestfs\-\*(C'\fR is used instead. .PP It is safe to delete this directory when you are not using libguestfs. .SH "USING LIBGUESTFS IN YOUR OWN PROGRAMS" .IX Header "USING LIBGUESTFS IN YOUR OWN PROGRAMS" .SS "The \s-1API\s0 has hundreds of methods, where do I start?" .IX Subsection "The API has hundreds of methods, where do I start?" We recommend you start by reading the \s-1API\s0 overview: \&\*(L"\s-1API\s0 \s-1OVERVIEW\s0\*(R" in \fIguestfs\fR\|(3). .PP Although the \s-1API\s0 overview covers the C \s-1API\s0, it is still worth reading even if you are going to use another programming language, because the \&\s-1API\s0 is the same, just with simple logical changes to the names of the calls: .PP .Vb 6 \& C guestfs_ln_sf (g, target, linkname); \& Python g.ln_sf (target, linkname); \& OCaml g#ln_sf target linkname; \& Perl $g\->ln_sf (target, linkname); \& Shell (guestfish) ln\-sf target linkname \& PHP guestfs_ln_sf ($g, $target, $linkname); .Ve .PP Once you're familiar with the \s-1API\s0 overview, you should look at this list of starting points for other language bindings: \&\*(L"\s-1USING\s0 \s-1LIBGUESTFS\s0 \s-1WITH\s0 \s-1OTHER\s0 \s-1PROGRAMMING\s0 \s-1LANGUAGES\s0\*(R" in \fIguestfs\fR\|(3). .SS "Can I use libguestfs in my proprietary / closed source / commercial program?" .IX Subsection "Can I use libguestfs in my proprietary / closed source / commercial program?" In general, yes. However this is not legal advice. You should read the license that comes with libguestfs, and if you have specific questions about your obligations when distributing libguestfs, contact a lawyer. In the source tree the license is in the file \&\f(CW\*(C`COPYING.LIB\*(C'\fR (LGPLv2+ for the library and bindings) and \f(CW\*(C`COPYING\*(C'\fR (GPLv2+ for the standalone programs). .SH "DEBUGGING LIBGUESTFS" .IX Header "DEBUGGING LIBGUESTFS" .SS "How do I debug when using any libguestfs program or tool (eg. virt\-v2v or virt-df)?" .IX Subsection "How do I debug when using any libguestfs program or tool (eg. virt-v2v or virt-df)?" There are two \f(CW\*(C`LIBGUESTFS_*\*(C'\fR environment variables you can set in order to get more information from libguestfs. .ie n .IP """LIBGUESTFS_TRACE""" 4 .el .IP "\f(CWLIBGUESTFS_TRACE\fR" 4 .IX Item "LIBGUESTFS_TRACE" Set this to 1 and libguestfs will print out each command / \s-1API\s0 call in a format which is similar to guestfish commands. .ie n .IP """LIBGUESTFS_DEBUG""" 4 .el .IP "\f(CWLIBGUESTFS_DEBUG\fR" 4 .IX Item "LIBGUESTFS_DEBUG" Set this to 1 in order to enable massive amounts of debug messages. If you think there is some problem inside the libguestfs appliance, then you should use this option. .PP To set these from the shell, do this before running the program: .PP .Vb 2 \& export LIBGUESTFS_TRACE=1 \& export LIBGUESTFS_DEBUG=1 .Ve .PP For csh/tcsh the equivalent commands would be: .PP .Vb 2 \& setenv LIBGUESTFS_TRACE 1 \& setenv LIBGUESTFS_DEBUG 1 .Ve .PP For further information, see: \*(L"\s-1ENVIRONMENT\s0 \s-1VARIABLES\s0\*(R" in \fIguestfs\fR\|(3). .SS "How do I debug when using guestfish?" .IX Subsection "How do I debug when using guestfish?" You can use the same environment variables above. Alternatively use the guestfish options \-x (to trace commands) or \-v (to get the full debug output), or both. .PP For further information, see: \fIguestfish\fR\|(1). .SS "How do I debug when using the \s-1API\s0?" .IX Subsection "How do I debug when using the API?" Call \*(L"guestfs_set_trace\*(R" in \fIguestfs\fR\|(3) to enable command traces, and/or \&\*(L"guestfs_set_verbose\*(R" in \fIguestfs\fR\|(3) to enable debug messages. .PP For best results, call these functions as early as possible, just after creating the guestfs handle if you can, and definitely before calling launch. .SS "How do I capture debug output and put it into my logging system?" .IX Subsection "How do I capture debug output and put it into my logging system?" Use the event \s-1API\s0. For examples, see: \&\*(L"\s-1SETTING\s0 \s-1CALLBACKS\s0 \s-1TO\s0 \s-1HANDLE\s0 \s-1EVENTS\s0\*(R" in \fIguestfs\fR\|(3). .SS "Digging deeper into the appliance boot process." .IX Subsection "Digging deeper into the appliance boot process." Enable debugging and then read this documentation on the appliance boot process: \*(L"\s-1INTERNALS\s0\*(R" in \fIguestfs\fR\|(3). .SS "libguestfs hangs or fails during run/launch." .IX Subsection "libguestfs hangs or fails during run/launch." Enable debugging and look at the full output. If you cannot work out what is going on, file a bug report, including the \fIcomplete\fR output of \fIlibguestfs\-test\-tool\fR\|(1). .SH "DESIGN/INTERNALS OF LIBGUESTFS" .IX Header "DESIGN/INTERNALS OF LIBGUESTFS" .SS "Why don't you do everything through the \s-1FUSE\s0 / filesystem interface?" .IX Subsection "Why don't you do everything through the FUSE / filesystem interface?" We offer a command called \fIguestmount\fR\|(1) which lets you mount guest filesystems on the host. This is implemented as a \s-1FUSE\s0 module. Why don't we just implement the whole of libguestfs using this mechanism, instead of having the large and rather complicated \s-1API\s0? .PP The reasons are twofold. Firstly, libguestfs offers \s-1API\s0 calls for doing things like creating and deleting partitions and logical volumes, which don't fit into a filesystem model very easily. Or rather, you could fit them in: for example, creating a partition could be mapped to \f(CW\*(C`mkdir /fs/hda1\*(C'\fR but then you'd have to specify some method to choose the size of the partition (maybe \f(CW\*(C`echo 100M > /fs/hda1/.size\*(C'\fR), and the partition type, start and end sectors etc., but once you've done that the filesystem-based \s-1API\s0 starts to look more complicated than the call-based \s-1API\s0 we currently have. .PP The second reason is for efficiency. \s-1FUSE\s0 itself is reasonably efficient, but it does make lots of small, independent calls into the \&\s-1FUSE\s0 module. In guestmount these have to be translated into messages to the libguestfs appliance which has a big overhead (in time and round trips). For example, reading a file in 64 \s-1KB\s0 chunks is inefficient because each chunk would turn into a single round trip. In the libguestfs \s-1API\s0 it is much more efficient to download an entire file or directory through one of the streaming calls like \&\f(CW\*(C`guestfs_download\*(C'\fR or \f(CW\*(C`guestfs_tar_out\*(C'\fR. .SS "Why don't you do everything through \s-1GVFS\s0?" .IX Subsection "Why don't you do everything through GVFS?" The problems are similar to the problems with \s-1FUSE\s0. .PP \&\s-1GVFS\s0 is a better abstraction than \s-1POSIX/FUSE\s0. There is an \s-1FTP\s0 backend for \s-1GVFS\s0, which is encouraging because \s-1FTP\s0 is conceptually similar to the libguestfs \s-1API\s0. However the \s-1GVFS\s0 \s-1FTP\s0 backend makes multiple simultaneous connections in order to keep interactivity, which we can't easily do with libguestfs. .ie n .SS "Can I use ""guestfish \-\-ro"" as a way to backup my virtual machines?" .el .SS "Can I use \f(CWguestfish \-\-ro\fP as a way to backup my virtual machines?" .IX Subsection "Can I use guestfish --ro as a way to backup my virtual machines?" Usually this is not a good idea. The question is answered in more detail in this mailing list posting: https://www.redhat.com/archives/libguestfs/2010\-August/msg00024.html .SS "What's the difference between guestfish and virt-rescue?" .IX Subsection "What's the difference between guestfish and virt-rescue?" A lot of people are confused by the two superficially similar tools we provide: .PP .Vb 3 \& $ guestfish \-\-ro \-a guest.img \& > run \& > fsck /dev/sda1 \& \& $ virt\-rescue \-\-ro guest.img \& > /sbin/fsck /dev/sda1 .Ve .PP And the related question which then arises is why you can't type in full shell commands with all the \-\-options in guestfish (but you can in \fIvirt\-rescue\fR\|(1)). .PP \&\fIguestfish\fR\|(1) is a program providing structured access to the \&\fIguestfs\fR\|(3) \s-1API\s0. It happens to be a nice interactive shell too, but its primary purpose is structured access from shell scripts. Think of it more like a language binding, like Python and other bindings, but for shell. The key differentiating factor of guestfish (and the libguestfs \s-1API\s0 in general) is the ability to automate changes. .PP \&\fIvirt\-rescue\fR\|(1) is a free-for-all freeform way to boot the libguestfs appliance and make arbitrary changes to your \s-1VM\s0. It's not structured, you can't automate it, but for making quick ad-hoc fixes to your guests, it can be quite useful. .PP But, libguestfs also has a \*(L"backdoor\*(R" into the appliance allowing you to send arbitrary shell commands. It's not as flexible as virt-rescue, because you can't interact with the shell commands, but here it is anyway: .PP .Vb 1 \& > debug sh "cmd arg1 arg2 ..." .Ve .PP Note that you should \fBnot\fR rely on this. It could be removed or changed in future. If your program needs some operation, please add it to the libguestfs \s-1API\s0 instead. .ie n .SS "What's the deal with ""guestfish \-i""? Why does virt-cat only work on a real \s-1VM\s0 image, but virt-df works on any disk image? What does ""no root device found in this operating system image"" mean?" .el .SS "What's the deal with \f(CWguestfish \-i\fP? Why does virt-cat only work on a real \s-1VM\s0 image, but virt-df works on any disk image? What does ``no root device found in this operating system image'' mean?" .IX Subsection "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. .PP At the \fIguestfs\fR\|(3) \s-1API\s0 level, a \*(L"disk image\*(R" is just a pile of partitions and filesystems. .PP In contrast, when the virtual machine boots, it mounts those filesystems into a consistent hierarchy such as: .PP .Vb 9 \& / (/dev/sda2) \& | \& +\-\- /boot (/dev/sda1) \& | \& +\-\- /home (/dev/vg_external/Homes) \& | \& +\-\- /usr (/dev/vg_os/lv_usr) \& | \& +\-\- /var (/dev/vg_os/lv_var) .Ve .PP (or drive letters on Windows). .PP The \s-1API\s0 first of all sees the disk image at the \*(L"pile of filesystems\*(R" level. But it also has a way to inspect the disk image to see if it contains an operating system, and how the disks are mounted when the operating system boots: \*(L"\s-1INSPECTION\s0\*(R" in \fIguestfs\fR\|(3). .PP Users expect some tools (like \fIvirt\-cat\fR\|(1)) to work with \s-1VM\s0 paths: .PP .Vb 1 \& virt\-cat fedora.img /var/log/messages .Ve .PP How does virt-cat know that \f(CW\*(C`/var\*(C'\fR is a separate partition? The trick is that virt-cat performs inspection on the disk image, and uses that to translate the path correctly. .PP Some tools (including \fIvirt\-cat\fR\|(1), \fIvirt\-edit\fR\|(1), \fIvirt\-ls\fR\|(1)) use inspection to map \s-1VM\s0 paths. Other tools, such as \fIvirt\-df\fR\|(1) and \fIvirt\-filesystems\fR\|(1) operate entirely at the raw \*(L"big pile of filesystems\*(R" level of the libguestfs \s-1API\s0, and don't use inspection. .PP \&\fIguestfish\fR\|(1) is in an interesting middle ground. If you use the \&\fI\-a\fR and \fI\-m\fR command line options, then you have to tell guestfish exactly how to add disk images and where to mount partitions. This is the raw \s-1API\s0 level. .PP If you use the \fI\-i\fR option, libguestfs performs inspection and mounts the filesystems for you. .PP The error \f(CW\*(C`no root device found in this operating system image\*(C'\fR is related to this. It means inspection 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 disk image. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIguestfish\fR\|(1), \&\fIguestfs\fR\|(3), . .SH "AUTHORS" .IX Header "AUTHORS" Richard W.M. Jones (\f(CW\*(C`rjones at redhat dot com\*(C'\fR) .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2012 Red Hat Inc. .PP This library is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This library is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \s-1GNU\s0 Lesser General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, \s-1MA\s0 02110\-1301 \s-1USA\s0