mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-12-01 07:39:48 +00:00
a1ec819cf1
* Removes note about --os-variant as it is fixed.
118 lines
5.4 KiB
Text
118 lines
5.4 KiB
Text
[[creating-virtual-machines]]
|
|
= Creating virtual machines
|
|
|
|
The installation of Fedora guests using Anaconda is supported. The installation can be started on the command-line using the `virt-install` program or in the user interface program `virt-manager`.
|
|
|
|
[[creating-a-guest-with-virt-install]]
|
|
== Creating a guest with virt-install
|
|
|
|
`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 fedora28 \
|
|
--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: 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`.
|
|
|
|
If graphics were enabled, a VNC window will open and present the graphical installer. If graphics were not enabled, a text installer will appear. Proceed with the Fedora installation.
|
|
|
|
[[creating-a-guest-with-virt-manager]]
|
|
== Creating a guest with virt-manager
|
|
|
|
. Start Virtual Machine Manager by navigating to menu:Applications[System Tools], or by running the following command:
|
|
+
|
|
----
|
|
# virt-manager
|
|
----
|
|
+
|
|
. Open a connection to a hypervisor by navigating to menu:File[Add connection].
|
|
. Choose *qemu* for KVM, or *Xen* for Xen.
|
|
. Choose *local* or select a method to connect to a remote hypervisor.
|
|
. After a connection is opened, click the new icon next to the hypervisor, or right-click on the active hypervisor and select *New*.
|
|
. Configure the virtual machine following the steps in the *New VM* wizard.
|
|
. Click *Finish* at the end of the wizard to provision the guest operating system. After a few moments a VNC window will appear. Proceed with the Fedora installation.
|
|
|
|
|
|
|
|
|