Manual page with centralised documentation.
[virt-p2v.git] / virt-p2v.pod
1 =head1 NAME
2
3 virt-p2v - P2V (physical to virtual machine) migration tool
4
5 =head1 SUMMARY
6
7 virt-p2v
8
9 =head1 DESCRIPTION
10
11 virt-p2v is a live CD for migrating physical machines to virtual
12 machine guests.
13
14 In the simplest mode of operation, you take a pre-built live CD ISO
15 from the main website (L<http://et.redhat.com/~rjones/virt-p2v/>) and
16 burn it to a CD-R.  Then insert the CD-R into the physical machine
17 which must be migrated, reboot, and follow the on-screen instructions.
18 See B<STANDARD USAGE> section below.
19
20 You may also build a customized live CD.  Typically this will contain
21 things like server details specific to your organization, so that the
22 live CD can run mostly or completely automatically.  See B<BUILDING A
23 CUSTOM LIVE CD> section below.
24
25 In both cases, files and disk images are transferred from the physical
26 machine over the network to the virtualization host machine over ssh.
27 Therefore C<sshd> must be running on the virtualization host, and must
28 be accessible to that host.  See B<SERVER REQUIREMENTS> section below.
29
30 The C<virt-p2v> script must only be run from the live CD.  It isn't
31 designed to run outside this environment and could do Bad Things to
32 your machine if you try it.  The script contains some checks to try to
33 stop you from doing this.
34
35 Virt-p2v does not modify the physical machine, its disks,
36 configuration etc.
37
38 =head1 STANDARD USAGE
39
40 After booting the live CD-R, you are presented with a series of
41 questions.  This section explains each question.
42
43 =over 4
44
45 =item Remote host
46
47 Enter the name or IP address of the virtualization host.  This is the
48 host running Xen (or any other virtualization system supported by
49 libvirt, eg. QEMU).  This host should be accessible on the network and
50 running an SSH daemon (C<sshd>).
51
52 =item Remote port
53
54 This is the port name or number of the SSH server on the remote host.
55 The default is C<22> which is the standard SSH port.
56
57 =item Remote directory
58
59 Enter the directory on the remote host where disk image(s) and
60 configuration file(s) must reside.
61
62 Note that if the remote host is running SELinux then you may not be
63 able to start a Xen guest unless its disk image(s) are located in the
64 default directory, C</var/lib/xen/images>.
65
66 =item Remote username
67
68 Enter the remote SSH username to use to log in to the remote host.
69
70 If you use the default username of C<root> then you should ensure that
71 remote root logins are enabled on the remote host
72 (ie. C<PermitRootLogin yes> in C</etc/ssh/sshd_config>).
73
74 =item Network configuration
75
76 Choose the way that the live CD configures network access.  The
77 current options are:
78
79 =over 4
80
81 =item Automatic configuration
82
83 In this mode, the live CD attempts to reuse the network configuration
84 from the physical machine's root filesystem.  You should probably try
85 this method even though occasionally it does not work.
86
87 =item Configure from the shell
88
89 In this mode you will be dropped into a command shell and you will
90 need to issue the correct sequence of C</sbin/ifconfig> commands in
91 order to configure the network interface.
92
93 A typical sequence of commands which should bring up the network
94 interface would be:
95
96  /sbin/ifconfig eth0 AA.BB.CC.DD
97  /sbin/route add default gw GG.HH.II.JJ eth0
98
99 where C<AA.BB.CC.DD> is the IP address and C<GG.HH.II.JJ> is the
100 gateway.
101
102 =back
103
104 =item Devices
105
106 This question lists out all local block devices (hard disk drives and
107 similar) and asks you to choose which will be sent to the remote host.
108 You must send at least one block device.
109
110 =item Root device
111
112 This question lists out possible root filesystems and asks you to
113 choose the right one.  Choose the filesystem which would normally be
114 mounted as C</> on the system.
115
116 Virt-p2v performs some autodetection and is in most cases able to work
117 out which filesystems are possible root filesystems.  It displays what
118 it thinks is on each filesystem, but leaves it up to the user to make
119 a final decision.
120
121 The root filesystem is critical because it contains C</etc/fstab>.
122 This is used during P2V both to determine how other filesystems are
123 normally mounted on the machine, and because this file and others
124 under C</etc> may need to be modified during P2V conversion.
125
126 If the machine has more than one root filesystem (typically because
127 the machine is dual-booted with another operating system), then you
128 must choose only one of them to perform the P2V conversion on.
129
130 =item Hypervisor
131
132 This question asks you to choose the hypervisor / virtualization
133 system in use on the remote host.
134
135 If you select I<Xen>, I<QEMU> or I<KVM> then virt-p2v will produce a
136 configuration file which is customized for the selected system.  If
137 you select I<Other> then virt-p2v will produce a generic configuration
138 file which will probably require hand-modification to work.
139
140 See also L<http://libvirt.org/format.html>.
141
142 =item Machine architecture
143
144 This question asks you to choose the machine architecture.  Virt-p2v
145 can normally detect this, so you should leave it as I<Auto-detect>.
146
147 =item Memory
148
149 This question asks you to choose the amount of memory (RAM) in
150 megabytes assigned to the virtual machine.
151
152 If the entry is left blank, then virt-p2v will try to autodetect how
153 much RAM is present in the physical machine and use that, and this is
154 probably a good choice for most simple migrations.
155
156 =item Virtual CPUs
157
158 This question asks you to choose the number of virtual CPUs assigned
159 to the virtual machine.  Choosing C<1> causes the virtual machine to
160 be uniprocessor, and choosing some number greater than 1 causes the
161 virtual machine to be SMP.
162
163 If the entry is left blank, then virt-p2v will try to autodetect how
164 many CPU cores are present in the physical machine and use that, and
165 this is probably a good choice for most simple migrations.
166
167 =item MAC address
168
169 Here you should enter a MAC address for the virtual machine's emulated
170 network card.  MAC addresses are written as C<aa:bb:cc:dd:ee:ff> where
171 C<aa>, C<bb> etc are hexadecimal octets.
172
173 Leaving it blank will cause virt-p2v to choose a random MAC address
174 within the C<00:16:3e:..> space reserved for Xen guests.  These MAC
175 addresses are not tested for uniqueness so there is a very small
176 chance that they could coincide, which would leave a guest unable to
177 access the virtual network.
178
179 =item Verify and proceed
180
181 In this step you are asked to verify the settings above.  If any are
182 incorrect, use the I<Back> button to navigate back to the setting.  If
183 all settings are correct, use the I<OK> button to begin the P2V
184 conversion.
185
186 =item Network autoconfiguration
187
188 If you selected network autoconfiguration above then virt-p2v tries to
189 autoconfigure the network and ping the remote host.  It then asks
190 I<Did automatic network configuration work?>
191
192 You should answer C<y> here if it worked.
193
194 Answering C<n> will drop you into a command shell.
195
196 You can also switch to another virtual console if you need to perform
197 additional tests.  See section B<GETTING A SHELL> below.
198
199 =item SSH connection
200
201 Unless you have set up an SSH key, or the SSH server on the remote
202 host allows passwordless logins, then for each file that has to be
203 transferred to the remote host you will need to confirm the identity
204 of the remote host and/or enter a password.
205
206 To understand more about this, please see the L<ssh(1)> manual page.
207
208 =back
209
210 =head2 BOOTING P2V GUEST ON VIRTUALIZATION HOST
211
212 Once the P2V conversion has been completed, and assuming it was
213 successful, you will find a configuration file and one or more disk
214 images on the remote host.
215
216 The files will be located in the directory selected, usually
217 C</var/lib/xen/images>.  The names of the files are made up of:
218
219 C<p2v-I<hostname>-I<YYYYMMDDHHMM>.conf> or
220 C<p2v-I<hostname>-I<YYYYMMDDHHMM>-hdI<X>.img>
221
222 To simply start up the guest, use the following commands as root:
223
224  virsh define p2v-foo-2008MMDDHHMM.conf
225  virsh start foo
226
227 For QEMU/KVM do:
228
229  virsh -c qemu:///system define p2v-foo-2008MMDDHHMM.conf
230  virsh -c qemu:///system start foo
231
232 For other hypervisors you will need to edit the configuration file and
233 read L<http://libvirt.org/uri.html>.
234
235 =head1 GETTING A SHELL
236
237 During all stages of P2V questions and conversion you can get a root
238 shell on the physical machine.  Use I<ALT> I<F2> keys to switch to the
239 second virtual console, then log in as I<root> with no password.
240
241 =head2 LOG FILE
242
243 Virt-p2v writes a detailed log file to C</tmp/virt-p2v.log>.  (Note
244 that this C</tmp> directory is a ramdisk on the live CD, not the same
245 as the C</tmp> directory of the physical machine, and more importantly
246 it disappears when the machine is rebooted).
247
248 If you are reporting a bug, please always supply this file.
249
250 =head1 SERVER REQUIREMENTS
251
252 The virtualization host (remote host) must be running an SSH daemon
253 (C<sshd>), accessible from the physical machine which is being
254 migrated.
255
256 Previous versions of virt-p2v could use a special virt-p2v server.
257 However this capability has been removed since there was practically
258 no benefit.
259
260 =head1 BUILDING A CUSTOM LIVE CD
261
262 To build a custom live CD you must download the source for virt-p2v
263 from L<http://et.redhat.com/~rjones/virt-p2v/> or from the Mercurial
264 source repository (see website for details).
265
266 Please read the C<README> file to find the dependencies which are all
267 in Fedora &gt; 8 or EPEL &gt; 5.
268
269 The steps to creating a custom live CD are:
270
271 =over 4
272
273 =item 1. Edit C<virt-p2v> and adjust defaults
274
275 Find the section "TO MAKE A CUSTOM virt-p2v SCRIPT ..." which is near
276 to the top of this file.  Edit the defaults in this section as
277 detailed below.
278
279 =item 2. C<virt-p2v --test> to verify your changes
280
281 This command should not print anything at all.  If it prints any
282 message, then you will need to fix the error by going back to the
283 first step.
284
285 =item 3. C<make build> or C<make update> to build a custom live CD
286
287 C<make build> will create a complete ISO from scratch.  C<make update>
288 can be used to build a "quick" developer ISO by updating an existing
289 ISO image.  See section B<ISO ATTACHMENTS> below for more details.
290
291 =item 4. Burn the ISO to a CD-R and test
292
293 =back
294
295 =head2 EDITING DEFAULTS IN THE C<virt-p2v> SCRIPT
296
297 For each default, setting it to C<None> will ask the user.  All of the
298 defaults are set to C<None> in the standard, uncustomized virt-p2v
299 script, and so the standard script asks all the questions.
300
301 You may edit C<virt-p2v> and change the defaults, in which case the
302 user will not be questioned.  In this way you can make the script
303 partially or fully automated.
304
305 I<Note about OCaml code:>  C<None> and C<Some foo> are similar to the
306 concept of a NULL pointer versus non-NULL pointer in other languages.
307 This a variant type defined as:
308
309 type E<945> option = None | Some of E<945>
310
311 =over 4
312
313 =item C<greeting>
314
315 If this is C<true> then we wait for a keypress after boot and at a
316 couple of other stages.  If set to C<false> then we try not to wait
317 for any keypresses (so more automated live CDs are possible).
318
319 =item C<remote_host>
320
321 Set this to C<Some "hostname"> or C<Some "IP-address"> to
322 provide the name of the remote host.
323
324 =item C<remote_port>
325
326 Set this to C<Some port> (eg. C<Some 22>) to provide the port number
327 of the remote host's SSH daemon.
328
329 =item C<remote_directory>
330
331 Set this to C<Some "path"> (eg. C<Some "/var/lib/xen/images">) to
332 provide the directory where we update P2V converted images and
333 configuration files.
334
335 =item C<remote_username>
336
337 Set this to C<Some "username"> (eg. C<Some "root">) to provide the SSH
338 username to use on the remote system.
339
340 =item C<devices_to_send>
341
342 Set this to a list of block devices to send to the remote system.
343 For example, C<Some ["sda"; "sdb"]>.
344
345 =item C<root_filesystem>
346
347 Set this to the name of the root filesystem.
348
349 For a disk partition (eg. C</dev/sda1>), use:
350
351  Some (Part ("sda", "1"))
352
353 For a logical volume (eg. C</dev/VolGroup00/LogVol00>), use:
354
355  Some (LV ("VolGroup00", "LogVol00"))
356
357 =item C<network>
358
359 Set this to the choice for network setup.  Use either C<Some Auto> or
360 C<Some Shell> for auto-configuration or shell (manual) configuration
361 respectively.
362
363 =item C<hypervisor>
364
365 Set this to the choice of hypervisor or virtualization system.  The
366 choices are: C<Some Xen>, C<Some QEMU> or C<Some KVM>.
367
368 =item C<architecture>
369
370 Set this to the architecture.  The choices are:
371 C<Some I386> (i386 and up, 32 bit),
372 C<Some X86_64> (AMD and Intel x86-64, 64 bit),
373 C<Some IA64> (Intel IA64),
374 C<Some PPC> (PowerPC, 32 bit),
375 C<Some PPC64> (PowerPC, 64 bit),
376 C<Some SPARC> (Sun SPARC, 32 bit),
377 C<Some SPARC64> (Sun SPARC, 64 bit),
378 C<OtherArch "foo"> (a hypothetical architecture called I<foo>), or
379 C<UnknownArch> to auto-detect the architecture.
380
381 =item C<memory>
382
383 Set this to the size of memory in megabytes, eg. C<Some 256>.  If you
384 set this to C<Some 0> then virt-p2v will try to autodetect the amount
385 of RAM installed on the physical machine.
386
387 =item C<vcpus>
388
389 Set this to the number of virtual CPUs, eg. C<Some 1>.  If you set
390 this to C<Some 0> then virt-p2v will try to autodetect the number of
391 CPU cores on the physical machine.
392
393 =item C<mac_address>
394
395 Set this to the MAC address for the virtual network card, eg. C<Some
396 "aa:bb:cc:dd:ee:ff">.  If you set this to C<Some ""> then virt-p2v
397 will choose a random MAC address within the C<00:16:3e:..> space
398 reserved for Xen guests.  These MAC addresses are not tested for
399 uniqueness so there is a very small chance that they could coincide,
400 which would leave a guest unable to access the virtual network.
401
402 =back
403
404 =head2 ISO ATTACHMENTS
405
406 Rebuilding a custom ISO is time-consuming.  You can make a "quick"
407 developer ISO by updating an existing ISO image with a new custom
408 C<virt-p2v> script.  This is useful for testing purposes.
409
410 From the source directory, assuming that you have downloaded or
411 built an existing C<virt-p2v-*.iso>, you can just do:
412
413  make update
414
415 or the equivalent manual command:
416
417  ./iso-attach virt-p2v-VERSION.iso virt-p2v
418
419 =head1 BOOTING FROM A USB KEY INSTEAD OF A CD
420
421 If you wish to boot from a USB keydrive, use the livecd-iso-to-disk
422 tool:
423
424  livecd-iso-to-disk virt-p2v-$VERSION.iso /dev/sdX1
425
426 (Replace /dev/sdX1 with the actual USB device).
427
428 In my experience I also had to set up a suitable MBR:
429
430  cat /usr/lib/syslinux/mbr.bin > /dev/sdX
431
432 =head1 TESTING AN ISO UNDER QEMU OR KVM
433
434 If you have a virtual guest running under QEMU or KVM then
435 you can test the P2V conversion process on the guest.
436
437 (Technically this is a V2V -- virtual to virtual -- conversion).
438
439 From the source directory do:
440
441  make boot HDA=qemuimage.img
442
443 where C<qemuimage.img> is the name of the QEMU/KVM image.
444
445 You can also supply an C<HDB> parameter to specify a second disk.
446
447 =head1 SEE ALSO
448
449 L<virsh(1)>,
450 L<http://www.libvirt.org/ocaml/>,
451 L<http://www.libvirt.org/>,
452 L<http://et.redhat.com/~rjones/>,
453 L<http://caml.inria.fr/>
454
455 =head1 AUTHORS
456
457 Richard W.M. Jones <rjones @ redhat . com>
458
459 =head1 COPYRIGHT
460
461 (C) Copyright 2007-2008 Red Hat Inc., Richard W.M. Jones
462 http://libvirt.org/
463
464 This program is free software; you can redistribute it and/or modify
465 it under the terms of the GNU General Public License as published by
466 the Free Software Foundation; either version 2 of the License, or
467 (at your option) any later version.
468
469 This program is distributed in the hope that it will be useful,
470 but WITHOUT ANY WARRANTY; without even the implied warranty of
471 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
472 GNU General Public License for more details.
473
474 You should have received a copy of the GNU General Public License
475 along with this program; if not, write to the Free Software
476 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
477
478 =head1 REPORTING BUGS
479
480 Bugs can be viewed on the Red Hat Bugzilla page:
481 L<https://bugzilla.redhat.com/>.
482
483 If you find a bug in virt-p2v, please follow these steps to report it:
484
485 =over 4
486
487 =item 1. Check for existing bug reports
488
489 Go to L<https://bugzilla.redhat.com/> and search for similar bugs.
490 Someone may already have reported the same bug, and they may even
491 have fixed it.
492
493 =item 2. Capture debug and error messages
494
495 At the point where you get the error or unexpected behaviour,
496 go to the second virtual console (I<ALT> I<F2>) and look at
497 the logfile C</tmp/virt-p2v.log>.  Please make sure that
498 this file is attached to your bug report.
499
500 =item 3. Get version of virt-p2v
501
502 The version is in the name of the ISO.  If you have built a custom
503 virt-p2v ISO, please describe any changes that you have made.
504
505 =item 4. Submit a bug report.
506
507 Go to L<https://bugzilla.redhat.com/> and enter a new bug.
508 Please describe the problem in as much detail as possible.
509
510 Remember to include the version number (step 3) and to
511 attach the log file (step 2).
512
513 =item 5. Assign the bug to rjones @ redhat.com
514
515 Assign or reassign the bug to B<rjones @ redhat.com> (without the
516 spaces).  You can also send me an email with the bug number if you
517 want a faster response.
518
519 =back