Got it

How to Install VMs on CentOS 7.6

Latest reply: Mar 15, 2022 14:14:18 609 23 9 0 0

Hi, everyone!


Today, I will share with you the case: How to install VMs on CentOS 7.6.


The process for installing the VM

1. Install the host machine system

Install CentOS 7.6 and configure the proxy to ensure that you can access the yum source.


2. Install virtualization components

yum install qemu* libvirt* AAVMF virt-install

Creating a QEMU-KVM Soft Link

ln -sv /usr/libexec/qemu-kvm /usr/bin/

Upgrading the QEMU

yum -y install glib2-devel zlib-devel pixman-devel


3. Define a VM

a. Create the os and vm directories in the /home directory of the host machine.

Upload the OS image to the /home/os directory.

VM XML files and VM hard disk files are uploaded and created in /home/vm.

b. Modify the XML file and create the VM hard disk file.

Modify the VM XML file to ensure that the OS and hard disk paths are correct. In addition, ensure that the VM MAC address does not conflict.

Creating a VM Hard Disk File

qemu-img create -f qcow2 -o size=200G win10.qcow2 Creating a 200 GB VM Hard Disk File
qemu-img create –f qcow2 win10.img 100G

c. Host machine bridge operation

brctl addbr br0
ifconfig enp2s0f0 0.0.0.0/0 up
brctl addif br0 enp2s0f0
ifconfig br0 xx.xx.xx.xx/xx up
route add default gw xx.xx.xx.xx


d. Define virtual machines

virsh define win10.xml
virsh list --all # Run the following command to check whether the VM is successfully defined:
virsh edit win10 #Modify the information about the XML file of the Windows 10 VM.
virsh start win10 #Start the Windows 10 VM.
virsh destroy win10 #Stop the Windows 10 VM.
netstat -tunlp #Check the VNC port number of the VM.

Before using VNC to connect to VMs, disable the firewall of the system.

sysemctl stop firewalld.service #Disable the firewall.
firewall-cmd --state #Check the status of the firewall.
systemctl disable firewalld.service # Disable the firewall from being started.

e. Clone a VM

virt-clone -o win10 -n win20 -f /home/vm/win20.qcow2


Attach the XML definition file.

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>     
     <name>win10</name>
     <memory>16777216</memory>
     <currentMemory>16777216</currentMemory>
     <vcpu>4</vcpu>
     <os>
         <type arch='x86_64'>hvm</type>
         <boot dev='hd'/>
         <boot dev='cdrom'/>
     </os>
     <features>
         <acpi/>
         <apic/>  
         <pae/>
    </features>
    <clock offset='utc'>        
        <timer name='rtc' tickpolicy='catchup' track='guest'/>
        <timer name='hpet' present='no'/>
        <timer name='pit' tickpolicy='delay'/>
    </clock>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
    <devices>
        <emulator>/usr/bin/qemu-kvm</emulator>
        <disk type='file' device='disk'> 
            <driver name='qemu' type='qcow2' cache='none' io='native'/>
            <source file='/home/vm/win10.qcow2'/> 
            <target dev='hda' bus='ide'/>
        </disk>
        <disk type='file' device='cdrom'>
            <driver name='qemu' type='raw' cache='none' io='native'/>
            <source file='/home/os/cn_windows_10_technical_preview_x86_dvd_5552506.iso'/>
            <target dev='hdc' bus='ide'/>
            <readonly/>
        </disk>
        <interface type='bridge'>
            <mac address='00:21:10:11:20:1a'/>
            <source bridge='br0'/>
        </interface>
        <input type='tablet' bus='usb'/> 
        <input type='mouse' bus='ps2'/>
        
        <console type='pty'>
            <target port='0'/>
        </console>    
        
        <graphics type='vnc' autoport='no' listen='xx.xx.xx.xx' port='59210'>
            <listen type='address' address='xx.xx.xx.xx'/>
        </graphics>
       <video>
            <model type='cirrus' vram='9216' heads='1'/>
        </video>
        <memballoon model='none'/>
    </devices>
</domain>


Thank you for reading!



Install VMs on CentOS 7
View more
  • x
  • convention:

user_4400653
user_4400653 Created Mar 11, 2022 10:19:28 (0) (0)
 
Thanks for sharing
View more
  • x
  • convention:

stephen.xu
stephen.xu Created Feb 11, 2022 00:34:31 (0) (0)
Thank you!  
user_4400653
user_4400653 Created Mar 11, 2022 10:19:38 (0) (0)
 
good
View more
  • x
  • convention:

stephen.xu
stephen.xu Created Feb 15, 2022 00:38:19 (0) (0)
Thank you!  
smileymind
smileymind Created Mar 11, 2022 10:20:42 (0) (0)
note  
Thanks for sharing
View more
  • x
  • convention:

sabahshahzad
sabahshahzad Created Mar 5, 2022 16:52:06 (0) (0)
 
smileymind
smileymind Created Mar 11, 2022 10:20:48 (0) (0)
oh  
Good share
View more
  • x
  • convention:

stephen.xu
stephen.xu Created Feb 15, 2022 00:38:08 (0) (0)
Thank you!  
Very Interesting knowledge
View more
  • x
  • convention:

Nabihazahid
Nabihazahid Created Mar 5, 2022 16:52:46 (0) (0)
 
Sothea_nh
Sothea_nh Created Mar 11, 2022 10:21:40 (0) (0)
oh  
Good share
View more
  • x
  • convention:

Sothea_nh
Sothea_nh Created Mar 11, 2022 10:21:48 (0) (0)
note  
Thanks for sharing
View more
  • x
  • convention:

stephen.xu
stephen.xu Created Mar 7, 2022 06:00:07 (0) (0)
Thank you!  
good
View more
  • x
  • convention:

12
Back to list

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.