\begin{exe} {Using \textbf{virt-manager} with \textbf{KVM} to Install a
      \textbf{Virtual Machine} and Run it}

   In this exercise we will use pre-built \textbf{iso}
   images built by \textbf{TinyCoreLinux}
   (\url{http://www.tinycorelinux.net}) because they are
   cooked up very nicely and are quite small.

   If you would like, you can substitute any installation
   \textbf{iso} image for another \textbf{Linux}
   distribution, such as \textbf{Debian}, \textbf{CentOS},
   \textbf{Ubuntu}, \textbf{Fedora}, \textbf{openSUSE} etc.
   The basic steps will be identical and only differ when
   you get to the installation phase for building your new
   VM; which is no different than building any fresh
   installation on an actual physical machine.

   We will give step-by-step instructions with screen
   capture images; If you feel confident, please try to
   just launch \textbf{virt-manager} and see if you can
   work your way through the necessary steps, as the
   \textbf{GUI} is reasonably clearly constructed.


   \begin{enumerate}
      \item
      Make sure \textbf{libvirtd} is running and start
      \textbf{virt-manager} by typing:
      \begin{cmd}
$ sudo systemctl start libvirtd
$ sudo virt-manager
      \end{cmd}
      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man01}
         \caption{Starting virt-manager}
      \end{figure}

      \item
      Click on \verb?File->Create New Machine? :
      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man02}
         \caption{Creating a Virtual Machine with virt-manager}
      \end{figure}
      \item
      We have included three different \textbf{iso} install
      images from \textbf{TinyCoreLinux} in the
      \filelink{RESOURCES/s_\thesessionref} directory:

      \reslink{Core-current.iso}\newline
      \reslink{CorePlus-current.iso}\newline
      \reslink{TinyCore-current.iso}

      (You can check and see if there are newer versions
      upstream at \url{http://www.tinycorelinux.net} but
      these should be fine.)

      \textbf{CorePlus}-current is largest and robust and we
      will use this as it will install with full graphics.
      The others are considerably quicker to use, however.

      Navigate through your file system and pick the desired
      image:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man03}
         \caption{Selecting the TinyCoreLinux iso image in virt-manager}
      \end{figure}

      \item
      Next you have to request the amount of memory and
      number of \textbf{CPU}s or \textbf{cores} to use.
      These images are pretty minimal. A choice of
      \verb?256 MB? is more than enough; you may have fun seeing
      how low you can go!

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man04}
         \caption{Configuring Memory and CPUS in virt-manager}
      \end{figure}

      \item
      Next you have to configure the location and size of
      the VM that is being created.  You actually need very
      little for \textbf{TinyCoreLinux}, but the GUI will
      not let you choose less than \verb?0.1 GB?  (about
      \verb?100 MB?.)  (From the command line it is easy to
      configure less space.)

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man05}
         \caption{Configuring Disk Storage in virt-manager}
      \end{figure}

      If you do not click on
      \verb?Select or Create custom storage?  your image
      will be placed in \filelink{/var/lib/libvirt/images}.
      Since images can be quite large, you might want to
      configure to put it elsewhere.  Or you can replace the
      images directory in \filelink{/var/lib/libvirt} with a
      symbolic link to somewhere else, as in:
      \begin{cmd}
$ cd /var/lib/libvirt
$ sudo mv images images_ORIGINAL
$ sudo mkdir /tmp/images
$ sudo ln -s /tmp/images images
      \end{cmd}
      (You probably want a different location for the images
      files than \filelink{/tmp}, but you get the idea.)
      \item
      You are now ready to begin installation of your own VM
      from the \textbf{TinyCoreLinux} installation disk:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man06}
         \caption{Beginning the VM installation in virt-manager}
      \end{figure}
      \begin{info}
         We recommend clicking on
         \textbf{Customize} configuration before install.
         While you may want to make other changes, the mouse
         pointer is configured by default to be a \textbf{PS2}
         device; it is better to add a \textbf{USB tablet} input
         pointer.
      \end{info}
      Do this by clicking on \verb?Add Hardware? on the next
      screen and then:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man07}
         \caption{Adding an Input Device to the VM in virt-manager}
      \end{figure}
      \item
      Finally, we begin the installation:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man08}
         \caption{Booting into the Installation Media with virt-manager}
      \end{figure}
      You can make other choices for the graphical
      interface, here we just choose the first one, the
      default, and hit return.

      \item
      This will take a while and eventually you will see the
      following screen:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man09}
         \caption{First TinyCoreLinux Screen}
      \end{figure}

      It is not obvious what to do here, but you need to see
      the icons at the bottom so you should resize and make
      the screen taller:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man10}
         \caption{First TinyCoreLinux Screen Resized}
      \end{figure}
      \item
      Click on the terminal icon (or right click on the
      background and open up a terminal.  Note the font is
      microscopic unfortunately.  Then type
      \begin{cmd}
tc-install
      \end{cmd}
      in the window.
      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man11}
         \caption{Running tc-install}
      \end{figure}
      \item
      Select \verb?Whole disk? and \verb?sda? and click the
      forward arrow:
      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man12}
         \caption{Selecting Disk in VM}
      \end{figure}
      \item
      Things will crank for a while and each step will be
      reflected in the output window.

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man13}
         \caption{Finishing Installation in virt-manager}
      \end{figure}

      When installation is complete you can go to the
      \verb?File?  menu and shut down the virtual machine.

      \item
      Start up \textbf{virt-manager} again (if you have
      killed it) and you should now see something like:

      \begin{figure}[H]
         \includegraphics[width=4in]{IMAGES/virt-man14}
         \caption{Running the new VM in virt-manager}
      \end{figure}
      Right click on the VM and \verb?open? and \verb?run?.
      Your new virtual machine should be up and running!
      (If you get confused and think you are running the
      original install image, you can verify it is not that
      by noting there is no \textbf{tc-install} program in
      the new disk image.
   \end{enumerate}

\end{exe}

