To convert a VirtualBox virtual machine to a KVM Virtual Machine

Source: Internet
Author: User


It turns out that we have been using virtualbox Virtual Machine Management Program (VMM) on the desktop to build virtual machines to install different operating systems. Now we are studying whether the KVM in linux can be used to create a virtualBox virtual client (guest) how about converting to a KVM Virtual Machine? After searching for information, you can.
The steps are as follows:
1. Convert the Virtual Disk File (VDI) of the virtualbox virtual machine to a file in raw format. In this step, use the virtualbox command line tool vboxmanage. This tool is helpful for generating virtual machines by compiling scripts, it provides more powerful functions than virtualbox graphic configuration.

The specific command is as follows: VBoxManage clonehd-format raw centos. vdi centos. img www.2cto.com: The name is centos. vdi Virtual Disk Files are converted to raw Virtual Disk Files. raw files can be converted between Virtual Disk Files of different formats. Other formats can be converted to this format first, then convert to another target format. After the conversion, the raw format file size is specified when the virtual machine is configured. The actual vdi file only occupies the actual application size, however, after installing the operating system and related software, it may only take 8 GB, so the actual Virtual Disk File (vdi format) only occupies 8 GB, but after using the above command to convert, the size of the converted file is the size of the disk space specified when the virtual machine is created, which is 20 GB here. Therefore, check whether the disk space is sufficient before conversion. Command Parameter: clonehd-clone Virtual Disk-format raw-specified conversion format clone this is used in many Virtualization Technologies, such as backup, migration, and so on.
2. Convert the converted raw format file to the qcow2 format file used by kvm. This step is implemented using the qemu-img tool. If there is no qcow2 file on the machine, you can install it through rpm or yum, the package name is qemu-img. Qemu-img is a qemu command line tool dedicated to virtual disk image files. The command is as follows: qemu-img convert-f raw centos. img-O qcow2 centos. qcow2 parameter description: convert Converts a disk file to a file in the specified format-f specifies the file format www.2cto.com-O specifies the target format to be converted after conversion, A new target image file is generated, and the original file is still saved.
3. Use the qemu-kvm command to start the Virtual Machine Based on the converted virtual disk image. After the file format supported by kvm is generated, you can use qemu-kvm to start the Virtual Machine Based on the converted disk file, syntax: qemu-kvm-m 1024-M pc-smp 2-hda/opt/images/centos. after qcow2-boot c-name centos \-k en-us vnc: 0-usb device tablet is started, a separate qemu-kvm process will be produced, you can use the vnc tool to connect to this virtual machine. In this example, the vnc port is 5900. After the connection, you can perform various operations on the client. Parameter description:-m 1024 specifies the memory size-M pc real machine type, here, RHEL 5.4.0 PC-smp uses two virtual CPUs to simulate a symmetric multi-processor system-hda to specify the Virtual Disk File Name-boot and the boot device c as the hard disk, d. Specify the Virtual Machine name for the optical drive-name-k and the keyboard layoutvnc: 0, specify the vnc connection port, and the final port is the number + 5900-usb to make the usb device valid for www.2cto.com-usbdevice tablet and add the device, tablet is a pointer device that uses absolute coordinates, such as the mouse
4. Other Instructions: the virtual machine generated in step 3 is temporary. After the process is disabled, the virtual machine does not exist. You can manually create a configuration file to protect the Virtual Machine Parameters stored in the/etc/libvirt/qemu directory, so that they can be managed by virsh for convenient startup and shutdown. The configuration file can use the configuration file of an existing virtual machine as the template. In a virtual machine generated using virtualbox, if the VBoxGuestAdditions of virtualbox is installed (mainly used to control Mouse capture and other functions), you must first uninstall it from the virtual machine. Therefore, kvm does not support it. Prepared by-syc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.