menu
  + 
    #### 
    Reliable web hosting for your business or personal sites. cPanel + Litespeed included on fast NVMe storage.
    Loaded features and overselling enabled plans to help grow your business. cPanel/WHM + LiteSpeed + NVMe.
    Fine-tuned and optimized for all WordPress sizes. No i/io limits, AccelerateWP + cPanel + LiteSpeed + NVMe.
    KVM VPS servers with NVMe standard. Fast setup. **Free VPS control panel included.**
    Enterprise grade bare-metal servers with **1G / 10G unmetered** options. Fast provisioning.
 / Knowledge Base
# Linux Virtualisation Cheat Sheet
## Knowledge Base
2600
July 30, 2023
## Table of Contents
1. 
   1. 
   2. 
2. 
3. 
      1. 
      2. 
   3. 
4. 
5. 
6. 
7. 
8. 
## KVM Commands
### virsh dialogue terminal
```
$ virsh --connect qemu:///system
virsh # list --all
### virsh commands
| Command | Description |
| --- | --- |
| **virsh list** ← active guest only**virsh list –all****virsh list –autostart**virsh list –all –autostartvirsh list –all –no-autostartvirsh list –inactive ← inactive guest only | check virtual server status |
| virsh dominfo GUEST | checking guest information(CPU, Memory, Auto start) |
| **virsh console GUEST** | For logout with ‘CTRL+]’ |
| virsh vncdisplay GUEST | :0 is TCP 5900:1 is TCP 5901 |
| virsh start GUEST |  |
| virsh autostart GUESTvirsh autostart –disable GUEST | guest start with os boot**Check**`ls -lh /etc/libvirt/qemu/autostart/` |
| virsh shutdown GUEST |  |
| virsh destroy GUEST | Force terminate OS |
| virsh edit GUEST | edit xml file for cpu numbers, memory size.The place of xml file is `/etc/libvirt/qemu/GUEST.xml.` |
| virsh dumpxml GUEST | lessvirsh dumpxml GUEST | grep macvirsh dumpxml GUEST | grep graphics | grep port |  |
| virsh define /etc/libvirt/qemu/SERVER.xmlvirsh define xxxxx.xml | registration new virtual machine |
| virsh create /etc/libvirt/qemu/SERVER.xmlvirsh create xxxxx.xml | registration new virtual machine and start |
| virsh undefine SERVER | `virsh undefine` will delete XML configuration file.If you need the XML Configuration file, please backup XML file.And Image file isn’t delete.**Check the place of disk file before undefine. And delete image file.**`virsh dumpxml Guest |grep file` |
| virt-clone –original ORG –name NEW –file /etc/libvirt/qemu/ORG/ORG.img |  |
## Installing KVM in Host OS
yum install kvm
yum install virt-manager libvirt libvirt-python python-virtinst
or
yum groupinstall Virtualization "Virtualization Client" "Virtualization Platform" "Virtualization Tools"
chkconfig libvirtd on
## KVM Networking
### Checking KVM Network
# brctl show
### Creating Bridge Interface
#### Creating Bridge Interface with brX
| **brX Basic** | /etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-br0 |
| **brX bonding** | /etc/modprobe.d/bonding.conf/etc/sysconfig/network-scripts/ifcfg-bond0/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth1/etc/sysconfig/network-scripts/ifcfg-br0 |
| **brX VLAN** | /etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-bond0/etc/sysconfig/network-scripts/ifcfg-bond0.10/etc/sysconfig/network-scripts/ifcfg-bond0.20/etc/sysconfig/network-scripts/ifcfg-br10/etc/sysconfig/network-scripts/ifcfg-br20 |
#### Creating Bridge Interface with virbrX
This bridge is use iptables’s NAT function.
### How to delete virbr0 of NAT.
# ifconfig virbr0
# virsh net-destroy default
# virsh net-list --all
# virsh net-autostart default --disable
## KVM Guest OS
### File Composition
| configuration file | /etc/libvirt/qemu/HOST.xml |
| disk file | /var/lib/libvirt/images/HOST.img |
## Log
| /var/log/libvirt/libvirtd.log |  |
| /var/log/libvirt/qemu/test-server.log |  |
## Snapshot
* If you want to use snapshot, you must use a qcow2 file format.
| create snapshot | virsh snapshot-create-as [Guest\_Name] [Snapshot\_Name] [Description] |
| recovery snapshot | virsh snapshot-revert [Guest\_Name] [Snapshot\_Name] |
| list snapshot | virsh snapshot-list [Guset\_Name]virsh snapshot-list [Guset\_Name] –tree |
| delete snapshot | virsh snapshot-delete [Guset\_Name] [Snapshot\_Name] |
## LiveMigration
virsh migrate --live centos7 qemu+ssh://xx.xx.xx.xx/system
## Tips
### KVM Image Mount
# kpartx -av disk.img
# mount /dev/mapper/loop0p1 /mnt  <-   loop0p1 or loop0p2 or loop0p3 etc
# cd /mnt/
# ls -al
# umount /mnt
# kpartx -dv disk.img
source: 
Tags: 
0
Share Feedback
email
 Submit
previous article
#### 
next article
### Leave a Reply 
You must be  to post a comment.
* cPanel
* Control Panels
* Linux Tips
* Monitoring
* Operating Systems
* Random Stuff
!
The **LOGICWEB** logo is a registered trademark of LogicWeb Inc. All rights reserved. © 2024
**Company**
**Policies**
**Support**