Difference between revisions of "KVM"

From Dogtag
Jump to: navigation, search
m (Installing a Guest)
m (Installing a Guest)
Line 44: Line 44:
 
<pre>
 
<pre>
 
$ virt-install \
 
$ virt-install \
--name f28 \
+
    --name fedora \
--description 'Fedora 28 Workstation' \
+
    --memory 1024 \
--ram 2048 \
+
    --disk path=/var/lib/libvirt/images/guest.qcow2,size=10 \
--vcpus 2 \
+
    --network bridge=virbr0 \
--disk path=/var/lib/libvirt/images/guest.qcow2,size=10 \
+
    --graphics vnc,listen=127.0.0.1,port=5901 \
--network bridge=virbr0 \
+
    --cdrom /var/lib/libvirt/images/Fedora-Workstation-Live-x86_64-28-1.1.iso \
--graphics vnc,listen=127.0.0.1,port=5901 \
+
    --noautoconsole
--cdrom /var/lib/libvirt/images/Fedora-Workstation-Live-x86_64-28-1.1.iso \
 
--noautoconsole
 
 
</pre>
 
</pre>
  
Line 58: Line 56:
  
 
<pre>
 
<pre>
$ virt-install --name debian --memory 1024 --disk size=10 --cdrom /var/lib/libvirt/images/debian-9.5.0-amd64-netinst.iso
+
$ virt-install \
 +
    --name debian \
 +
    --memory 1024 \
 +
    --disk size=10 \
 +
    --cdrom /var/lib/libvirt/images/debian-9.5.0-amd64-netinst.iso
 
</pre>
 
</pre>
  

Revision as of 19:59, 27 July 2018

Installation

$ dnf install @virtualization

Starting the Service

$ systemctl start libvirtd

Creating a Storage

See Storage Management.

Sparse Raw File

$ rm -f /var/lib/libvirt/images/guest.img
$ truncate --size=10240M /var/lib/libvirt/images/guest.img

QCOW2

$ qemu-img create -f qcow2 /var/lib/libvirt/images/guest.qcow2 10240

Installing a Guest

Installing QCOW2 Image

To create a VM from a QCOW2 image:

$ virt-install --name <name> --memory 1024 --import --disk path=<image> --noautoconsole

Installing Fedora ISO

To create a Fedora 28 VM:

$ virt-install \
    --name fedora \
    --memory 1024 \
    --disk path=/var/lib/libvirt/images/guest.qcow2,size=10 \
    --network bridge=virbr0 \
    --graphics vnc,listen=127.0.0.1,port=5901 \
    --cdrom /var/lib/libvirt/images/Fedora-Workstation-Live-x86_64-28-1.1.iso \
    --noautoconsole

Installing Debian ISO

$ virt-install \
    --name debian \
    --memory 1024 \
    --disk size=10 \
    --cdrom /var/lib/libvirt/images/debian-9.5.0-amd64-netinst.iso

Connecting to VM

Connect with VNC to 127.0.0.1:1.

$ dnf install spice-vdagent
$ systemctl start spice-vdagentd

Running KVM

Start the VM with the following command:

$ virt-manager

References