(12) Automatic installation of virtual machines

   1. Install system-config-kickstart

    yum install system-config-kickstart -y


 2 Generate ks.cfg file (eg: save in /mnt)

    system-config-kickstart

Select time zone, set password

Fill in the http mount location

choose the first

Select all the first and partition, /boot partition is 200 /swap partition is 500 /partition is the rest


Firewall choose not to start

The network option is eth0


Finally, select sever to save to /mnt. After the save is successful, ls can check whether the save is successful.

    Save the file (/mnt)
    to check whether the ks.cfg file has errors
    ksvalidator /mnt/ks.cfg

    Note: Edit ks.cfg file with system-config-kickstart ks.cfg check


   4. Set up shared yum source

    scp ks.cfg [email protected]:/var/www/html/ Note: It can be shared on the real machine and can be called by all virtual machine installations


   3. Edit vm_create.sh, set to install
     vim automatically vm_create.sh
     #!/bin/bash
     virt-install \
     --location http://172.25.254.8/rhel7.2 \
     --memory 1024 \
     --vcpus 2 \
     - -disk /var/lib/libvirt/images/$1.qcow2,bus=virtio,size=9 \
     --name $1 \
     --network model=virtio,source=br0 \

     --extra-args "ks=http://172.25.254.148/ks.cfg" &


   6. Run the script to automatically install the virtual machine

     sh vm_create.sh VM-NAME



   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325447950&siteId=291194637