openstack-manuals/doc/image-guide/ch_creating_images_manually.xml
Andreas Jaeger 34a567089b Fix markup
This fixes mainly screens, computeroutput/userinput and also
marks some filenames. A lot of prompts have been added.

Change-Id: I864dc5b051bb297b61c9b2ed5464f9a35306bd68
Partial-Bug: #1217503
2013-09-17 16:08:17 +02:00

128 lines
9.3 KiB
XML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="ch_creating_images_manually">
<title>Creating images manually</title>
<para>Creating a new image is a step done outside of your OpenStack installation.
You create the new image manually on your own system and then upload the image to your
cloud.
</para>
<para>To create a new image, you will need the installation CD or DVD ISO file for the guest
operating system. You'll also need access to a virtualization tool. You can use KVM for
this. Or, if you have a GUI desktop virtualization tool (such as, VMWare Fusion and VirtualBox),
you can use that instead and just convert the file to raw once you're done.</para>
<para>When you create a new virtual machine image, you will need to connect to the graphical
console of the hypervisor, which acts as the virtual machine's display and allows you to
interact with the guest operating system's installer using your keyboard and mouse. KVM can
expose the graphical console using the <link
xlink:href="https://en.wikipedia.org/wiki/Virtual_Network_Computing">VNC</link> (Virtual
Network Computing) protocol or the newer <link xlink:href="http://spice-space.org"
>SPICE</link> protocol. We'll use the VNC protocol here, since you're more likely to be
able to find a VNC client that works on your local desktop.</para>
<section xml:id="net-running">
<title>Ensuring the libvirt default network is running</title>
<para>Before starting a virtual machine with libvirt, verify that the libvirt "default"
network has been started. This network must be active for your virtual machine to be
able to connect out to the network. Starting this network will create a Linux bridge
(usually called <literal>virbr0</literal>), iptables rules, and a dnsmasq process that
will serve as a DHCP server.</para>
<para>To verify that the libvirt "default" network is enabled, use the <command>virsh
net-list</command> command and verify that the "default" network is
active:<screen><prompt>#</prompt> <userinput>virsh net-list</userinput>
<computeroutput>Name State Autostart
-----------------------------------------
default active yes</computeroutput></screen>
</para>
<para>If the network is not active, start it by
doing:<screen><prompt>#</prompt> <userinput>virsh net-start default</userinput></screen>
</para>
</section>
<section xml:id="virt-manager">
<title>Using the virt-manager X11 GUI</title>
<para>If you plan to create a virtual machine image on a machine that can run X11 applications,
the simplest way to do so is to use the <command>virt-manager</command> GUI, which is
installable as the <literal>virt-manager</literal> package on both Fedora-based and
Debian-based systems. This GUI has an embedded VNC client in it that will let you view and
interact with the guest's graphical console.</para>
<para>If you are building the image on a headless server, and you have an X server on your
local machine, you can launch <command>virt-manager</command>  using ssh X11 forwarding to
access the GUI. Since virt-manager interacts directly with libvirt, you typically need to be
root to access it. If you can ssh directly in as root (or with a user that has permissions
to interact with libvirt),
do:<screen><prompt>$</prompt> <userinput>ssh -X root@server virt-manager</userinput></screen></para>
<para>If the account you use to ssh into your server does not have permissions to run libvirt,
but has sudo privileges, do:<screen><prompt>$</prompt> <userinput>ssh -X root@server</userinput>
<prompt>$</prompt> <userinput>sudo virt-manager</userinput> </screen><note>
<para>The <literal>-X</literal> flag passed to ssh will enable X11 forwarding over ssh.
If this does not work, try replacing it with the <literal>-Y</literal> flag.</para>
</note></para>
<para>Click the "New" button at the top-left and step through the instructions. <mediaobject>
<imageobject>
<imagedata fileref="figures/virt-manager-new.png" format="PNG" contentwidth="6in"/>
</imageobject>
</mediaobject>You will be shown a series of dialog boxes that will allow you to specify
information about the virtual machine.</para>
</section>
<section xml:id="virt-install">
<title>Using virt-install and connecting using a local VNC client</title>
<para>If you do not with to use virt-manager (e.g., you don't want to install the
dependencies on your server, you don't have an X server running locally, the X11
forwarding over SSH isn't working), you can use the <command>virt-install</command> tool
to boot the virtual machine through libvirt and connect to the graphical console from a
VNC client installed on your local machine.</para>
<para>Since VNC is a standard protocol, there are multiple clients available that implement
the VNC spec, including <link
xlink:href="http://sourceforge.net/apps/mediawiki/tigervnc/index.php?title=Welcome_to_TigerVNC"
>TigerVNC</link> (multiple platforms), <link xlink:href="http://tightvnc.com/"
>TightVNC</link> (multiple platforms), <link xlink:href="http://realvnc.com/"
>RealVNC</link> (multiple platforms), <link
xlink:href="http://sourceforge.net/projects/chicken/">Chicken</link> (Mac OS X),
<link xlink:href="http://userbase.kde.org/Krdc">Krde</link> (KDE), and <link
xlink:href="http://projects.gnome.org/vinagre/">Vinagre</link> (GNOME).</para>
<para>The following example shows how to use the <command>qemu-img</command> command to create an empty
image file <command>virt-install</command> command to start up a virtual machine using
that image file. As root:</para>
<screen><prompt>#</prompt> <command>qemu-img create -f qcow2 /data/centos-6.4.qcow2 10G</command>
<prompt>#</prompt> <userinput>virt-install --virt-type kvm --name centos-6.4 --ram 1024 \
--cdrom=/data/CentOS-6.4-x86_64-netinstall.iso \
--disk path=/data/centos-6.4.qcow2,size=10,format=qcow2 \
--network network=default\
--graphics vnc,listen=0.0.0.0 --noautoconsole \
--os-type=linux --os-variant=rhel6</userinput>
<computeroutput>
Starting install...
Creating domain... | 0 B 00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.</computeroutput></screen>
<para>This uses the KVM hypervisor to start up a virtual machine with the libvirt name of
<literal>centos-6.4</literal> with 1024MB of RAM, with a virtual CD-ROM drive
associated with the <filename>/data/CentOS-6.4-x86_64-netinstall.iso</filename> file,
and a local hard disk which is stored in the host at
<filename>/data/centos-6.4.qcow2</filename> that is 10GB in size in qcow2 format. It
configures networking to use libvirt's default network. There is a VNC server that is
listening on all interfaces, and libvirt will not attempt to launch a VNC client
automatically nor try to display the text console (<literal>--no-autoconsole</literal>).
Finally, libvirt will attempt to optimize the configuration for a Linux guest running a
RHEL 6.x distribution.<note>
<para>When using the libvirt <literal>default</literal> network, libvirt will
connect the virtual machine's interface to a bridge called
<literal>virbr0</literal>. There is a dnsmasq process managed by libvirt
that will hand out an IP address on the 192.168.122.0/24 subnet, and libvirt has
iptables rules for doing NAT for IP addresses on this subnet.</para>
</note></para>
<para>Run the <command>virt-install --os-variant list</command> command to see a range of allowed
<literal>--os-variant</literal> options.</para>
<para>Use the <command>virsh vncdisplay <replaceable>vm-name</replaceable></command> command
to get the VNC port
number.</para><screen><prompt>#</prompt> <userinput>virsh vncdisplay centos-6.4</userinput>
<computeroutput>:1</computeroutput></screen>
<para>In the example above, the guest <literal>centos-6.4</literal> uses VNC display
<literal>:1</literal>, which corresponds to tcp port <literal>5901</literal>. You
should be able to connect to a VNC client running on your local machine to display :1 on
the remote machine and step through the installation process.</para>
</section>
<xi:include href="section_centos-example.xml"/>
<xi:include href="section_ubuntu-example.xml"/>
<xi:include href="section_windows-example.xml"/>
</chapter>