Update en-US/modules/proc_creating-virtual-machines.adoc

Updated virt-install documentation to fix issue #50.
This commit is contained in:
Nathan Hicks 2018-05-19 02:47:21 +00:00
parent 940df5b189
commit ccdd53d994

View file

@ -6,7 +6,92 @@ The installation of Fedora guests using Anaconda is supported. The installation
[[creating-a-guest-with-virt-install]] [[creating-a-guest-with-virt-install]]
== Creating a guest with virt-install == Creating a guest with virt-install
`virt-install` is a command-line based tool for creating virtualized guests. Refer to http://virt-tools.org/learning/install-with-command-line/ for understanding how to use this tool. Execute `virt-install --help` for command line help. `virt-install` is a command-line based tool for creating virtualized guests. Execute `virt-install --help` for command line help, or you can find the manual page at `man 1 virt-install`.
To use the virt-install command, you should first download an ISO of the Fedora version you wish to install. You can find the latest Fedora images at https://getfedora.org. This ISO is only needed during Fedora installation, and can be deleted to free up storage space afterwards if desired. More information about Fedora installation can be found at https://docs.fedoraproject.org/f28/install-guide/. In this example we'll use Fedora Workstation.
=== Planning VM Resources
Adjust the ram, vcpus, and disk size parameters according to the resources you have available.
* Storage: An easy way to check your disk size from a bash shell is using the `df(1)`` utility from the shell:
----
# df -h
----
* Memory: You can check your available memory from the shell using free(1):
----
# free -m
----
* VCPU: You can check your processor information using `lscpu(1)`:
----
# lscpu
----
When allocating resources to your VM, keep in mind the minimum system requirements for the version of Fedora you are installing as well as your use case requirements. For Fedora 28, you can find this in the release notes here: https://docs.fedoraproject.org/f28/release-notes/welcome/Hardware_Overview.html#hardware_overview-specs.
==== Create Storage for the VM
The libvirt default storage pool is located at /var/lib/libvirt/images - which is the parent file path we use in this example. For individuals who are lacking enough storage in that path, you can simply mount a new disk or partition to that directory path (from the BASH shell, type `man 1 mount`) or select a new path. In the example `virt-install` command below, the disk did not exist prior to running virt-install. When the specified disk is not pre-existing, you must specify the size so virt-install can create a disk for you. If your disk already exists, you can safely remove the `,size=20` parameter from the disk argument.
You have several disk storage options for your VM. While it's outside the scope of this article to discuss these in detail, the following are a few common options. These examples use 20G as the upper limit for disk size, but you can adjust this size to fit your needs.
[Note]
====
Again, you do not need to manually allocate storage using the example options shown below if you specify the size parameter in the virt-install example shown below.
====
===== Raw File (Non-Sparse)
To create a fully allocated (non-sparse) raw file:
----
dd if=/dev/zero of=/var/lib/libvirt/images/guest.img bs=1M count=20480
----
you can also use fallocate(1):
----
fallocate -l 20480M /var/lib/libvirt/images/guest.img
----
===== Raw File (Sparse)
To create a dynamically allocated (sparse) raw file:
----
rm -f /var/lib/libvirt/images/guest.img
truncate --size=20480M /var/lib/libvirt/images/guest.img
----
===== QCOW2
To create a new qcow2-formatted disk separately, you can use qemu-img (the example below specifies a disk size of 20G):
----
# qemu-img create -f qcow2 /var/lib/libvirt/images/guest.qcow2 20480
----
More information about libvirt storage options can be found at https://libvirt.org/storage.html.
Finally, run the virt-install command using the following format (adjusting parameters as needed):
----
# virt-install --name Fedora28 \
--description 'Fedora 28 Workstation' \
--ram 4096 \
--vcpus 2 \
--disk path=/var/lib/libvirt/images/Fedora-Workstation-28/Fedora-Workstation-28-20180518.0.x86_64.qcow2,size=20 \
--os-type linux \
--os-variant fedora27 \
--network bridge=virbr0 \
--graphics vnc,listen=127.0.0.1,port=5901 \
--cdrom /var/lib/libvirt/images/Fedora-Workstation-28/Fedora-Workstation-Live-x86-64-28-1.1.iso \
--noautoconsole
----
[Note]
====
Note: os-variant fedora27 was used in this example because fedora28 was not yet added at the time of this writing. For the graphics parameter, we're setting the vnc listener to localhost because it's more secure to tunnel your VNC connection through SSH so that you don't expose VNC to everyone with access to the network.
====
`virt-install` can use kickstart files, for example, `virt-install -x ks=kickstart-file-name.ks`. `virt-install` can use kickstart files, for example, `virt-install -x ks=kickstart-file-name.ks`.