KVM script scripts automate creating VMS for virtual machines

Source: Internet
Author: User

Use this script to pre-set the parameters needed to install Ubuntu for automate installation.
https://github.com/christhai/Virtualization/blob/master/kvmScripts/makeUbuntuVM.sh

makevm.sh

#! /bin/bash # using newest versions from apt# making desktop  if [ !  "$"  ]thenecho  "Usage: $0 vmnumber" Exitfi # apt-get  update vmnr=$1host=192.168.122. $vmNRuser =mrootpw=lightbluedir=/home/s199425/kvmscriptslogdir= $dir/ loggb=$ ((20 +  $vmNR))  # 20gb image ++vm=control$vmnr # vm namevnc =$ ((5900 +  $vmNR)) vncnested=$ ((6900 +  $vmNR))  virsh destroy  $vmvirsh   undefine  $VM  # will be built from scratch cd  /imagesfile=ubuntu14.04.amd64.${gb}g.img/bin/rm  $file # qemu-img create -o compat=0.10  -f qcow2  $file  ${GB}Gqemu-img create -f qcow2  $file  ${GB}G  # enters ip and name in /root/preseed/preseed.cfgcat&nbsp, .... /preseed/preseed.cfg.orig | sed s/192.168.122.4/192.168.122. $vmNR/ >  /PRESEED/PRESEED.TMP.CFGCAT&NBSP, .... /preseed/preseed.tmp.cfg | sed s/control2/$VM/ >  /preseed/preseed.cfg date >  $logDir/startvm$vmnr virt-install --name  $VM  --ram 1024 --vcpus=1 --os-type=linux --initrd-inject=. /preseed/preseed.cfg --disk path=. /images/$file, device=disk,bus=ide,format=qcow2 --bridge=virbr0 --location=http:// no.archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64 --vnc --vncport= $vnc  --vnclisten =0.0.0.0 --extra-args  "File=file: /preseed/preseed.cfg "

The preseed.cfg script parameters are set as follows:

[email protected]:~/virtualization/preseed# grep -v  ' ^# '  /root/preseed/preseed.cfg  | grep -v -e  ' ^$ '  d-i debian-installer/locale string en_usd-i  console-setup/ask_detect boolean falsed-i keyboard-configuration/layout string  norwegiand-i     keyboard-configuration/variant  string   Norwegiand-i netcfg/choose_interface select autod-i netcfg/disable_autoconfig boolean  trued-i netcfg/get_nameservers string 128.39.89.8d-i netcfg/get_ipaddress  String 192.168.122.24d-i netcfg/get_netmask string 255.255.255.0d-i netcfg/get_ Gateway string 192.168.122.1d-i netcfg/confirm_static boolean trued-i netcfg/get _hostname string control24d-i netcfg/get_domain string vlab.cs.hioa.nod-i netcfg /wireless_wep stringd-i mIrror/country string manuald-i mirror/http/hostname string archive.ubuntu.comd-i  mirror/http/directory string /ubuntud-i mirror/http/proxy stringd-i clock-setup /utc boolean trued-i time/zone string europe/oslod-i clock-setup/ntp  Boolean trued-i clock-setup/ntp-server string ntp.ubuntu.comd-i partman-auto/method  string regulard-i partman-auto/choose_recipe select atomicd-i  partman-partitioning/confirm_write_new_label boolean trued-i partman/choose_partition  select finishd-i partman/confirm boolean trued-i partman/confirm_nooverwrite  Boolean trued-i partman-md/confirm boolean trued-i partman-partitioning/confirm_write _new_label boolean trued-i partman/choose_partition select finishd-i partman/ Confirm boolean trued-i partman/confirm_nooverwrite boolean trued-i passwd/user-fullname string mr rootd-i  passwd/username string mrootd-i passwd/user-password password lightblued-i  passwd/user-password-again password lightblued-i user-setup/encrypt-home boolean  Falsed-i tasksel/first multiselect openssh serverd-i pkgsel/update-policy select  unattended-upgradesd-i grub-installer/only_debian boolean trued-i grub-installer/ with_other_os boolean trued-i finish-install/reboot_in_progress notexserver-xorg  xserver-xorg/autodetect_monitor boolean truexserver-xorg xserver-xorg/config/monitor/ selection-method        select mediumxserver-xorg  xserver-xorg/config/monitor/mode-list        select 1024x768  @ 60 hzd-i preseed/late_command&nBsp;string in-target chsh -s /bin/bash ; in-target echo grub_ Recordfail_timeout=2 >> /etc/default/grub ; in-target /usr/sbin/update-grub

How to use makevm.sh

1965./makevm.sh 1966 Virsh List 1967 SSH [email protected]
[Email protected]:~/virtualization/preseed# virsh list Id Name State----------------------------------------------------Control24 running CONTROL16 running

Once installed, the host can ssh directly to the VM for more operations.



This article from "Systemadmin Growth" blog, reproduced please contact the author!

KVM script scripts automate creating VMS for virtual machines

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.