Skip to content

Latest commit

 

History

History
163 lines (97 loc) · 2.69 KB

0809.md

File metadata and controls

163 lines (97 loc) · 2.69 KB
$ systemctl status chronyd

$ timedatectl set-timezone 'Asia/Taipei'


$ sudo su -

$ virsh list

$ virsh list --all

$ virsh shutdown centos8

$ virsh start centos8

$ virsh reboot centos8


# Backup
$ mkdir vm-bak

$ cd vm-bak

# 1. shutdown vm
$ virsh shutdown centos8

# 2. dump xml
$ virsh dumpxml centos8 > centos8.xml

$ ls -lh /var/lib/libvirt/images/centos8.qcow2

# 3. copy image
$ cp /var/lib/libvirt/images/centos8.qcow2 ./

# 4. start vm
$ virsh start centos8


# Delete
# 1. shutdown vm
$ virsh shutdown centos8

$ virsh destroy centos8

# 2. undefine vm
$ virsh undefine centos8

$ ls -lh /var/lib/libvirt/images/centos8.qcow2

# 3. remove image
$ rm -rf /var/lib/libvirt/images/centos8.qcow2

$ ls -lh /var/lib/libvirt/images/centos8.qcow2


$ qemu-img info centos8.qcow2

# -p progress -c zip
$ qemu-img convert -p -c -O qcow2 centos8.qcow2 centos8-compress.qcow2

$ qemu-img info centos8-compress.qcow2


# Restore
# 1. restore image
$ cp centos8-compress.qcow2 /var/lib/libvirt/images/centos8.qcow2

$ ls -lh /var/lib/libvirt/images/centos8.qcow2

# 2. define xml
$ virsh define centos8.xml

# 3. start vm
$ virsh start centos8


$ qemu-img create -f qcow2 mylinux.qcow2 100G

$ qemu-img info mylinux.qcow2

$ qemu-img resize mylinux.qcow2 +100G

$ qemu-img info mylinux.qcow2


# https://linux.die.net/man/8/virt_selinux
$ setsebool -P virt_use_nfs 1
# https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/


# copy image

# backup files
$ qemu-img create -f qcow2 -b centos8.qcow2 centos8-1.qcow2

$ ls -lh centos8*

$ qemu-img info centos8-1.qcow2

$ qemu-img create -f qcow2 -b centos8.qcow2 centos8-2.qcow2

# template
- windows
    - sysprep
- linux
    - /etc/ssh/ssh_host_* -> file
    - /var/log/* -> file
    - /etc/hostname -> localhost.localdmain
    - nmtui -> clean profiles
    - history -c & rm -rf ~/.bash_history
    

$ dnf install -y ibus-libzhuyin.x86_64
  • compute

    • cpu
    • memory
  • storage

    • disk space
  • network

  • totla 4

    • Storage NFS x1
    • Host x2
    • Manager x1
# install oVirt
# 4.3 in CentOS 7, 4.4 in CentOS 8
$ sudo yum install -y https://resources.ovirt.org/pub/yum-repo/ovirt-release43.rpm

$ sudo yum install -y ovirt-engine



$ ntmui

$ ssh root@10.6.64.25

$ for ip in 21 22 25 26; do ssh root@10.6.64.${ip} "hostname"; done

$ ovirt-64.linux.class

$ echo 127.0.0.1 ovirt-64.linux.class >> /etc/hosts

$ vi /etc/hosts

$ cat /etc/hosts

$ engine-setup

$ cd /etc/yum.repos.d/

$ mkdir old

$ mv *.* old

$ echo 10.6.64.25 ovirt-64.linux.class >> /etc/hosts