Guestfish: implement -x option, echo commands before executing them.
[libguestfs.git] / README
1 Libguestfs is a library for accessing and modifying guest disk images.
2 Amongst the things this is good for: making batch configuration
3 changes to guests, getting disk used/free statistics (see also:
4 virt-df), migrating between virtualization systems (see also:
5 virt-p2v), performing partial backups, performing partial guest
6 clones, cloning guests and changing registry/UUID/hostname info, and
7 much else besides.
8
9 Libguestfs uses Linux kernel and qemu code, and can access any type of
10 guest filesystem that Linux and qemu can, including but not limited
11 to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
12 schemes, qcow, qcow2, vmdk.
13
14 Libguestfs provides ways to enumerate guest storage (eg. partitions,
15 LVs, what filesystem is in each LV, etc.).  It can also run commands
16 in the context of the guest.  Also you can access filesystems over FTP.
17
18 Libguestfs is a library that can be linked with C and C++ management
19 programs (or management programs written in OCaml, Perl, Python, Ruby, Java
20 or Haskell).  You can also use it from shell scripts or the command line.
21
22 Libguestfs was written by Richard W.M. Jones (rjones@redhat.com) and
23 hacked on by lots of other people.  For discussion, development,
24 patches, etc. please use the mailing list:
25
26   http://www.redhat.com/mailman/listinfo/libguestfs
27
28
29 Home page
30 ----------------------------------------------------------------------
31
32   http://libguestfs.org/
33
34
35 Requirements
36 ----------------------------------------------------------------------
37
38 - recent QEMU >= 0.10 with vmchannel support
39   http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
40
41 - febootstrap >= 2.3
42
43 - fakeroot
44
45 - fakechroot >= 2.9
46
47 - XDR, rpcgen (on Linux these are provided by glibc)
48
49 - squashfs-tools (mksquashfs only)
50
51 - (Optional) Augeas (http://augeas.net/)
52
53 - perldoc (pod2man, pod2text) to generate the manual pages and
54   other documentation.
55
56 - (Optional) Readline to have nicer command-line editing in guestfish.
57
58 - (Optional) 'reged' program from chntpw to decode Windows registry
59   entries (http://home.eunet.no/~pnordahl/ntpasswd/)
60
61 - (Optional) OCaml if you want to rebuild the generated files, and
62   also to build the OCaml bindings
63
64 - (Optional) local Fedora mirror
65
66 - (Optional) Perl if you want to build the perl bindings
67
68 - (Optional) Python if you want to build the python bindings
69
70 - (Optional) Ruby, rake if you want to build the ruby bindings
71
72 - (Optional) Java, JNI, jpackage-utils if you want to build the java
73 bindings
74
75 - (Optional) GHC if you want to build the Haskell bindings
76
77 - (Optional) Perl XML::XPath, Sys::Virt modules (for libvirt support
78 in virt-inspector).
79
80 Running ./configure will check you have all the requirements installed
81 on your machine.
82
83
84 Building
85 ----------------------------------------------------------------------
86
87 Then make the daemon, library and root filesystem:
88
89   ./configure [--with-mirror=URI]
90   make
91
92 Use the optional --with-mirror parameter to specify the URI of a local
93 Fedora mirror.  See the discussion of the MIRROR parameter in the
94 febootstrap(8) manpage.
95
96 Finally run the tests:
97
98   make check
99
100 If everything works, you can install the library and tools by running
101 this command as root:
102
103   make install
104
105
106 Fedora
107 ----------------------------------------------------------------------
108
109 We provide packages for Fedora >= 11 in Fedora.  Use those, or build
110 from our source RPMs - it's far simpler that way.
111
112 You can compile libguestfs on Fedora 10 but you cannot use it with the
113 version of qemu in Fedora 10.  You need to compile your own qemu, see
114 section 'qemu' below.
115
116
117 RHEL / EPEL / CentOS etc
118 ----------------------------------------------------------------------
119
120 We provide packages in EPEL which cover RHEL/CentOS >= 5.  Use those
121 or build from our source RPMs.
122
123
124 Debian
125 ----------------------------------------------------------------------
126
127 libguestfs is now built as a package in Debian by Guido Gunther and
128 the other Debian libvirt maintainers.  See:
129
130 http://wiki.debian.org/Teams/DebianLibvirtTeam#Packages
131
132 You can build for Debian in two different ways, either building a
133 Fedora-based appliance using febootstrap, yum, rpm, fakeroot,
134 fakechroot (all packaged in Debian).  However the recommended way is
135 to build a Debian-based appliance using debootstrap and debirf.
136
137 Both ways are supported by the configure script.
138
139
140 qemu
141 ----------------------------------------------------------------------
142
143 By far the most common problem is with broken or incompatible
144 qemu releases.
145
146 First of all, you need qemu >= 0.10.4, which contains a vmchannel
147 implementation.  There are several, conflicting, incompatible things
148 called 'vmchannel' which at one time or another have been added or
149 proposed for qemu/KVM.  The _only_ one we support is this one:
150
151   http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
152
153 Secondly, different versions of qemu have problems booting the
154 appliance for different reasons.  This varies between versions of
155 qemu, and Linux distributions which add their own patches.
156
157 If you find a problem, you could try using your own qemu built from
158 source (qemu is very easy to build from source), with a 'qemu
159 wrapper'.  Qemu wrappers are described in the guestfs(3) manpage.
160
161
162 Note on using KVM
163 ----------------------------------------------------------------------
164
165 By default the configure script will look for qemu-kvm (KVM support).
166 You will need a reasonably recent processor for this to work.  KVM is
167 much faster than using plain Qemu.
168
169 You may also need to enable KVM support for non-root users, by following
170 these instructions:
171
172   http://www.linux-kvm.org/page/FAQ#How_can_I_use_kvm_with_a_non-privileged_user.3F
173
174 On some systems, this will work too:
175
176   chmod o+rw /dev/kvm
177
178 On some systems, the chmod will not survive a reboot, and you will
179 need to make edits to the udev configuration.
180
181
182 Supermin appliance
183 ----------------------------------------------------------------------
184
185 If you configure with --enable-supermin then we will build a supermin
186 appliance (supermin = super-minimized).  This is a very specialized
187 appliance which is built on-the-fly at runtime (specifically, when you
188 call guestfs_launch).
189
190 The normal appliance is a self-contained Linux operating system, based
191 on the Fedora/RHEL/CentOS Linux distro.  So it contains a complete
192 copy of all the libraries and programs needed, like kernel, libc,
193 bash, coreutils etc etc.
194
195 The supermin appliance removes the kernel and all the executable
196 libraries and programs from the appliance.  That just leaves a
197 skeleton of config files and some data files, which is obviously
198 massively smaller than the normal appliance.  At runtime we rebuild
199 the appliance on-the-fly from the libraries and programs on the host
200 (eg. pulling in the real /lib/libc.so, the real /bin/bash etc.)
201
202 Although this process of rebuilding the appliance each time sounds
203 slow, it turns out to be faster than using the prebuilt appliance.
204 (Most of the saving comes from not compressing the appliance - it
205 transpires that decompressing the appliance is the slowest part of the
206 whole boot sequence).  On my machine, a new appliance can be built in
207 under a fifth of a second, and the boot time is several seconds
208 shorter.
209
210 The big advantage of the supermin appliance for distributions like
211 Fedora is that it gets security fixes automatically from the host, so
212 there is no need to rebuild the whole of libguestfs for a security
213 update in some underlying library.
214
215 There are several DISADVANTAGES:
216
217 It won't work at all except in very narrow, controlled cases like the
218 Fedora packaging case.  We control the dependencies of the libguestfs
219 RPM tightly to ensure that the required binaries are actually present
220 on the host.
221
222 Furthermore there are certain unlikely changes in the packages on the
223 host which could break a supermin appliance, eg. an updated library
224 which depends on an additional data file.
225
226 Also supermin appliances are subjected to changes in the host kernel
227 which might break compatibility with qemu -- these are, of course,
228 real bugs in any case.
229
230 Lastly, supermin appliances really can't be moved between branches of
231 distributions (eg. built on Fedora 12 and moved to Fedora 10) because
232 they are not self-contained and they rely on certain libraries being
233 around.  You shouldn't do this anyway.
234
235 Use supermin appliances with caution.
236
237
238 Notes on cross-architecture support
239 ----------------------------------------------------------------------
240
241 At the moment we basically don't support cross-architecture or
242 32-on-64.  This limits what is possible for some guests.  Filesystem
243 operations and FTP export will work fine, but running commands in
244 guests may not be possible.
245
246 To enable this requires work for cross-architecture and 32-on-64
247 support in febootstrap, fakeroot and fakechroot.
248
249 The daemon/ directory contains its own configure script.  This is so
250 that in future we will be able to cross-compile the daemon.
251
252
253 Mirroring tip
254 ----------------------------------------------------------------------
255
256 On my machines I can usually rebuild the appliance in around 3
257 minutes.  If it takes much longer for you, use a local Fedora mirror
258 or squid.
259
260 To use squid to cache yum downloads, read this first:
261 https://lists.dulug.duke.edu/pipermail/yum/2006-August/009041.html
262 (In brief, because yum chooses random mirrors each time, squid doesn't
263 work very well with default yum configuration.  To get around this,
264 choose a Fedora mirror which is close to you, set this with
265 './configure --with-mirror=[...]', and then proxy the whole lot
266 through squid by setting http_proxy environment variable).
267
268 You will also need to substantially increase the squid configuration
269 limits:
270 http://fedoraproject.org/wiki/Using_Mock_to_test_package_builds#Using_Squid_to_Speed_Up_Mock_package_downloads
271
272
273 Porting to other Linux distros / non-Linux
274 ----------------------------------------------------------------------
275
276 libguestfs itself should be fairly portable to other Linux
277 distributions.  Non-Linux ports are trickier, but we will accept
278 patches if they aren't too invasive.
279
280 The main porting issues are with the dependencies needed to build the
281 appliance.  You will need to find or port the following packages
282 first:
283
284  - fakeroot
285  - fakechroot
286  - python
287  - rpm-python    http://www.rpm.org/
288  - yum           http://yum.baseurl.org/
289  - febootstrap   http://et.redhat.com/~rjones/febootstrap/
290
291
292 Copyright and license information
293 ----------------------------------------------------------------------
294
295 Copyright (C) 2009 Red Hat Inc.
296
297 The library is distributed under the LGPLv2+.  The programs are
298 distributed under the GPLv2+.  Please see the files COPYING and
299 COPYING.LIB for full license information.