virt-install examples

Create VM using a local ISO – No kickstart file

virt-install \
--name=centos7test \ 
--ram=1024 \
--disk path=/var/lib/libvirt/images/centos7.qcow2,size=8 \
--vcpus=1 \
--os-type=linux \
--os-variant=rhl7 \
--network bridge=virbr0 \
--console pty,target_type=serial \
--nographics \
--location /root/isos/CentOS-7-x86_64-Everything-1708.iso \
--extra-args=console=ttyS0; 

Create VM using a kickstart file via HTTPD

 virt-install \
--name=centos7test \
--ram=1024 \ 
--disk path=/var/lib/libvirt/images/centos7.qcow2,size=8 \
--vcpus=1 \
--os-type=linux \
--os-variant=rhl7 \
--network bridge=virbr0 \ 
--console pty,target_type=serial  \
--nographics \
--location /root/isos/CentOS-7-x86_64-Everything-1708.iso \
--extra-args="console=ttyS0, ks=http://192.168.0.2/test.cfg"; 

Important note for the Kistarst file via HTTPD
Provided you speficy the http location of the kickstart file in the virt-install command, in the kickstart file as source installation you should use the following entry.

#Install source
cdrom
Share Button

virsh – Manage VMs

List all VMs

virst list --all

[root@desktop ~]# virsh list --all
Id Name State
----------------------------------------------------
- centos7.0 shut off
- centos7.0-2 shut off

Create a snapshot

virsh snapshot-create-as --domain centos7.0-2 \
> -- name "Testing"\
> -- description "Testing stuff"\
> -- live

List any snapshots of a VM

virsh snapshot-list --domain centos7.0-2
Name Creation Time State
------------------------------------------------------------
testing--description 2017-10-22 15:35:40 -0400 shutoff

Revert to a snapshot

virsh snapshot-revert centos7.0-2  testing--description

Power up/off a VM

virsh start/shutdown centos7.0-2 

Find IP of VM By using the MAC address

[root@desktop ~]# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.0.1              ether   28:56:5a:e9:3a:0b   C                     enp5s0
192.168.0.8              ether   74:2f:68:f7:32:0e   C                     enp5s0
192.168.124.148          ether   52:54:00:27:86:b6   C                     virbr0
192.168.0.5              ether   70:85:c2:29:cf:a3   C                     enp5s0
192.168.0.4              ether   d0:50:99:09:38:63   C                     enp5s0

[root@desktop ~]# virsh domiflist centos7.0-2
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00:27:86:b6

Enable/Disable Auto Start of guest upon boot

[root@desktop ~]# virsh autostart centos7.0-2 
Domain centos7.0-2 marked as autostarted

[root@desktop ~]# virsh autostart centos7.0-2  --disable
Domain centos7.0-2 unmarked as autostarted


Share Button

Fedora – How to Install KVM and how to install a Guest OS on KVM

KVM is an alternative solution to Citrix XEN and VMware. It comes with any major Linux distribution. Even though I use VMware most of the time there is no reason for me not to learn KVM as well 🙂 Below are instructions on how to install KVM and how to install a Virtual machine under KVM.

Continue reading

Share Button