Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Brief introduction of Common commands in KVM

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The abbreviation of Kernel-based Virtual Machine is an open source system virtualization module that has been integrated in major releases of Linux since Linux 2.6.20. It is managed by Linux's own scheduler, so its core source code is relatively small compared to Xen. At present, KVM has become one of the mainstream VMM in academic circles.

View the status of all virtual machines:

[root@kvm7 vps] virsh list-- all

View the status of the specified virtual machine:

[root@kvm7 vps] virsh domstate vm01running

Start the virtual machine manually:

[root@kvm7 vps] virsh start vmname

Manually shut down the virtual machine:

[root@kvm7 vps] virsh shutdown vmname

Suspend the virtual machine (pause):

[root@kvm7 vps] virsh suspend vmname

Reply to a suspended virtual machine:

[root@kvm7 vps] virsh resume name

Power down the virtual machine:

[root@kvm7 vps] virsh destroy vmname

Set to start with the host (boot):

[root@kvm7 vps] virsh autostart vmname

Cancel boot and start:

[root@kvm7 vps] virsh autostart-- disable vmname

Delete virtual machine .xml configuration file

[root@kvm7 vps] virsh undefine vmname

Export (backup) virtual machine configuration fil

[root@kvm7 vps] virsh dumpxml centos6 > / home/vpsbak/centos6bak.xml

Edit the virtual machine configuration file (the configuration file location is / etc/libvirt/qemu, which can be edited with vim, but it is recommended to use the command provided by KVM)

[root@kvm7 vps] virsh edit vmname

View virtual machine disk information:

[root@kvm7 vps] qemu-img info vm01.img image: vm01.imgfile format: qcow2virtual size: 10G (10737418240 bytes) disk size: 3.3Gcluster_size: 65536Format specific information: compat: 0.10

View the disk used by the specified virtual machine:

[root@kvm7 vps] virsh domblklist vm01 destination source-vda / home/vps/vm01.imgvdb / home/vps/data.imghda

Virtual machine migration hosts physical servers

1. Back up the virtual machine configuration file

[root@kvm6 vps] virsh dumpxml centos6 > / home/vpsbak/centos6.xml

2. Power off and migrate configuration files and disk files. The configuration file path is / etc/libvirt/qemu.

[root@kvm6 vps] scp / home/vpsbak/centos6.xml root@192.168.0.3:/etc/libvirt/qemu/ [root@kvm6 vps] scp / home/vpsdata/vps/centos6.qcow2 root@192.168.0.3:/data/vpsdata/vps

3. Activate the virtual machine profile

[root@kvm7 vps] virsh define / etc/libvirt/qemu/centos6.xml

Original address: https://www.linuxprobe.com/kvm-common-commands.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report