What are the common operations of kvm
Editor to share with you what are the common operations of kvm, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
KVM (full name is Kernel-based Virtual Machine) is a fully functional virtualization solution on x86 hardware platform under Linux, including a loadable kernel module kvm.ko provides and virtualizes core architecture and processor specification module.
1. Create a virtual machine [root@localhost] # virt-install--name=centos1\ # generate a virtual machine-- ram 1024-- vcpus=1\-- disk path=/root/centos1.img,size=10\-- accelerate-- cdrom / root/CentOS-6.5-x86_64-bin-DVD1.iso\-- graphics vnc,port=5921-- network bridge=br02 Other actions of virsh [root@localhost /] # virsh start centos1 # start the virtual machine [root@localhost /] # virt-viewer centos1 # if there is a graphical interface You can enter the interface of the virtual machine [root@localhost] # virsh shutdown centos1 # shut down the virtual machine [root@localhost /] # virsh reboot centos1 # restart the virtual machine [root@localhost /] # virsh suspend centos1 # pause the virtual machine [root@localhost /] # virsh resume centos1 # restore the virtual machine [root@localhost /] # virsh autostart centos1 # automatically load the virtual machine
The virsh parameters are as follows:
Autostart # automatically loads a specified virtual machine connect # reconnects to hypervisorconsole # connects to a customer session create # creates a virtual machine from a SML file start # starts an inactive virtual machine destroy # deletes a virtual machine define # defines a virtual machine domid from a XML file # convert a virtual machine name or UUID to IDdomuuid # convert a depressed or ID to UUIDdominfo # View virtual machine information domstate # view virtual machine status domblkstat # get virtual machine device fast status domifstat # get virtual machine network interface status dumpxml # XML virtual machine information edit # Edit the XML file of a virtual machine list # list the virtual machine migrate # migrate the virtual machine to another host quit # exit the non-interactive terminal reboot # restart a virtual machine resume # restore a virtual machine save # save the state of a virtual machine to a text Dump # dump the kernel of a virtual machine into a file for easy analysis of shutdown # shut down a virtual machine setmem # change the allocation of memory setmaxmem # change the maximum memory limit suspend # suspend a virtual machine vcpuinfo # cpu information of the virtual machine version # display virsh version 3 Virt-clone, if we are going to build several identical virtual machines, this command is very useful # virt-clone-- connect=qemu:///system-o centos1-n centos3-f / root/centos3.img # cloning centos1 is cloning centos1.img | 10.0 GB 00:07Clone 'centos3' created successfully.
Libguestfs-tools is a virtual machine management package, a very useful tool
[root@localhost ~] # yum-y install libguestfs-tools # installation kit 4. If you are not logged in, check the image directory [root@localhost ~] # virt-ls centos.img / home # check the / home directory tank5 in the centos.img image file, and if you are not logged in Copy the files in the image file [root@localhost ~] # virsh list-- all # View all virtual machine names Id name status-1 centos1 Running2 centos6.5 running- arch shutdown-arch2 shutdown-arch3 shutdown-arch4 shutdown-arch6 shutdown-centos3 Close-ubuntu close-ubuntu1 close [root@localhost ~] # virt-copy-out-d centos1 / etc/passwd / tmp # copy the files in centos1 to tmp under 6 Check the partition of the virtual machine [root@localhost ~] # virt-filesystems-d centos1/dev/sda1/dev/VolGroup/lv_ root [root @ localhost ~] # virt-list-partitions / root/centos.img/dev/sda1/dev/sda2 [root@localhost ~] # virt-df centos.imgFilesystem 1K-blocks Used Available Use%centos.img:/dev/sda1 495844 34510 435734 7%centos.img:/dev/VolGroup/lv_root 8780808 2842056 5492700 33% 7 Mount virtual machine [root@localhost ~] # guestmount-a / root/centos.img-m / dev/VolGroup/lv_root-- rw / mnt/usb [root@localhost ~] # cd / mnt/usb/ [root@localhost usb] # lsbin dev home lib64 media mnt opt root selinux sys usrboot etc lib lost+found misc net proc sbin srv tmp var is all the content of this article "what are the common operations of kvm?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!