KVM image making and OVA mirroring conversion

Source: Internet
Author: User
Tags ide hard drive

First, the KVM installs the image through the ISO


1. Generate an empty IMG file

Qemu-img create-f qcow2/opt/data/rock-feibiao/slse11-sp4/sles-11-sp4-dvd-x86_64-gm-dvd1.img-opreallocation= Metadata 20G


2. Reference XML file: Change name ISO location IMG Location

The default CPU mode uses the IDE hard drive and the Virtio driver can be installed later

# More/opt/data/rock-feibiao/slse11-sp4/sles-11-sp4-dvd-test.xml


<domain type= ' KVM ' >

<name>rock_SLES-11-SP4-DVD-test-02</name>

<memory unit= ' KiB ' >1048576</memory>

<currentmemory unit= ' KiB ' >1048576</currentMemory>

<vcpu placement= ' static ' >2</vcpu>

<cputune>

<shares>100</shares>

</cputune>

<os>

<type arch= ' x86_64 ' machine= ' rhel6.3.0 ' >hvm</type>

<boot dev= ' HD '/>

<bootmenu enable= ' yes '/>

</os>

<features>

<acpi/>

<apic/>

<pae/>

</features>

<!--

<cpu mode= ' custom ' match= ' exact ' >

<model fallback= ' Allow ' >cpu64-rhel6</model>

<feature policy= ' require ' name= ' AES '/>

<feature policy= ' require ' name= ' AVX '/>

<feature policy= ' require ' name= ' popcnt '/>

<feature policy= ' require ' name= ' sse4.1 '/>

<feature policy= ' require ' name= ' sse4.2 '/>

<feature policy= ' require ' name= ' x2apic '/>

</cpu>

-

<clock offset= ' UTC ' >

<timer name= ' pit ' tickpolicy= ' delay '/>

</clock>

<on_poweroff>destroy</on_poweroff>

<on_reboot>restart</on_reboot>

<on_crash>restart</on_crash>

<devices>

<emulator>/usr/libexec/qemu-kvm</emulator>

<disk type= ' file ' device= ' cdrom ' >

<source file= '/opt/data/rock-feibiao/slse11-sp4/sles-11-sp4-dvd-x86_64-gm-dvd1.iso ' ></source>

<target dev= ' HDD ' bus= ' IDE ' ></target>

<readonly></readonly>

</disk>

<disk type= ' file ' device= ' disk ' >

<driver name= ' qemu ' type= ' qcow2 ' cache= ' writethrough ' io= ' native '/>

<source file= '/opt/data/rock-feibiao/slse11-sp4/sles-11-sp4-dvd-x86_64-gm-dvd1.img '/>

<target dev= ' Vda ' bus= ' Virtio '/>

<serial>UCLOUD-LOCAL-SDA</serial>

<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x06 ' function= ' 0x0 '/>

</disk>

<controller type= ' usb ' index= ' 0 ' >

<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x01 ' function= ' 0x2 '/>

</controller>

<controller type= ' PCI ' index= ' 0 ' model= ' pci-root '/>

<interface type= ' bridge ' >

<!--

<mac address= ' 52:54:00:2F:B6:BC '/>

-

<source bridge= ' br0 '/>

<virtualport type= ' Openvswitch ' >

<parameters interfaceid= ' f136d74f-9da4-41e6-8740-f9a517b1368a '/>

</virtualport>

<model type= ' Virtio '/>

<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x03 ' function= ' 0x0 '/>

</interface>

<input type= ' tablet ' bus= ' USB '/>

<input type= ' mouse ' bus= ' ps2 '/>

<graphics type= ' vnc ' port= '-1 ' autoport= ' yes '/>

<video>

<model type= ' Cirrus ' vram= ' 9216 ' heads= ' 1 '/>

<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x02 ' function= ' 0x0 '/>

</video>

<memballoon model= ' Virtio ' >

<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x05 ' function= ' 0x0 '/>

</memballoon>

</devices>

</domain>


3. Start and log in the virtual machine

Virsh Create/opt/data/rock-feibiao/slse11-sp4/sles-11-sp4-dvd-test.xml

Virsh Vncdisplay rock_sles-11-sp4-dvd-test-02

Install ISO with host IP and port VNC login virtual machine, img file after successful installation and available



Second, OVA image conversion

1. Unzip the File.ova file:

# TAR-XVF Rsa-am-virtual-appliance-8.1.0.0.0.ova

2. Convert the extracted vmdk file:

Example: Qemu-img convert-o qcow2 file.vmdk file.qcow2-o compat=0.10

3. Start img via XML If you cannot start the installation of Virtio driver after using IDE boot


Three, Virtio Drive installation

Unzip initrd.img to the specified directory

mkdir Temp
CD Temp
Gunzip-c/boot/initrd-xxx.img | Cpio-i

Copy the kernel module to the INITRD directory

Cp/lib/modules/xxx/kernel/driver/virtio/virtio.ko lib/
Cp/lib/modules/xxx/kernel/driver/virtio/virtio_ring.ko lib/
Cp/lib/modules/xxx/kernel/driver/virtio/virtio_pci.ko lib/
Cp/lib/modules/xxx/kernel/driver/block/virtio_blk.ko Lib

Modify the script file to automatically load the script file

VI Init
Add Module
Insmod Lib/virtio.ko
Insmod Lib/virtio_ring.ko
Insmod Lib/virtio_pci.ko
Insmode Lib/virtio_blk.ko

RePack INITRD Directory

Find. | Cpio-c-O-... /initrd-xxx.img
Cd..
Gzip initrd-xxx.img
CP initird-xxx.img.gz/boot/initrd-xxx.img




























KVM image making and OVA mirroring conversion

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.