summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--other/README10
-rw-r--r--other/TODOS2
-rw-r--r--other/kickstarts/centos5-x86_64-master.cfg99
-rw-r--r--other/kickstarts/centos6-i386-master.cfg100
-rw-r--r--other/kickstarts/centos6-x86_64-master.cfg100
-rw-r--r--other/kickstarts/centos7-x86_64-master.cfg108
-rw-r--r--other/kickstarts/handmade/Centos5-32.cfg24
-rw-r--r--other/kickstarts/handmade/Centos5-64.cfg24
-rw-r--r--other/kickstarts/handmade/Centos6-32.cfg30
-rw-r--r--other/kickstarts/handmade/Centos6-64.cfg30
-rw-r--r--other/kickstarts/handmade/Centos7-64.cfg32
-rwxr-xr-xother/scripts/centoskvm.sh158
-rwxr-xr-xother/scripts/resizevm.sh120
13 files changed, 837 insertions, 0 deletions
diff --git a/other/README b/other/README
new file mode 100644
index 0000000..b7b11a8
--- /dev/null
+++ b/other/README
@@ -0,0 +1,10 @@
+Based on:
+
+https://github.com/fubralimited/CentOS-KVM-Image-Tools
+
+Adapted to fit our machines and infrastructure.
+
+Example of usage:
+
+scripts/centoskvm.sh Centos6-64-Master x86_64 6
+
diff --git a/other/TODOS b/other/TODOS
new file mode 100644
index 0000000..f3d64d1
--- /dev/null
+++ b/other/TODOS
@@ -0,0 +1,2 @@
+- have a yum update in all VMs
+ - auto-accept key
diff --git a/other/kickstarts/centos5-x86_64-master.cfg b/other/kickstarts/centos5-x86_64-master.cfg
new file mode 100644
index 0000000..8a94138
--- /dev/null
+++ b/other/kickstarts/centos5-x86_64-master.cfg
@@ -0,0 +1,99 @@
+# text mode (no graphical mode)
+text
+
+# do not configure X
+skipx
+
+# non-interactive command line mode
+cmdline
+
+# install
+install
+
+# installation path
+url --url=http://mirror.switch.ch/ftp/mirror/centos/5/os/x86_64
+
+# repository
+repo --name="Switch CentOS Repo" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/5/os/x86_64
+# by specifying the update Repo the install process will automatically update to the latest version. If you wish to stay at the initial release version, comment the following line.
+repo --name="Switch CentOS Repo Update" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/5/updates/x86_64
+
+# Language support
+lang en_US.UTF-8
+
+# keyboard
+keyboard us
+
+# network
+network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=centos5-64-master
+
+# root password (123qwe, change after cloning)
+rootpw --iscrypted $6$LhelAf3MiEiKEXoZ$4Ymdrfp0TJRtQf0DtkfRqjFzQddX72yYvRlHYapeDxMhdG.HGWm04XX1YOCTleKqsUio04hwbb6/1O.ea4RhM/
+
+# firewall
+firewall --enabled
+firewall --port=22:tcp
+
+# auth config
+authconfig --enableshadow --passalgo=sha512
+
+# SElinux
+selinux --enforcing
+
+# timezone
+timezone --utc Europe/Zurich
+
+# bootloader
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+
+# clear the MBR (Master Boot Record)
+zerombr
+
+# the Setup Agent is not started the first time the system boots
+firstboot --disable
+
+# power off after installation
+poweroff
+
+################################################################################
+# LVM partitions
+
+# do not remove any partition (preserve the gpt label)
+clearpart --none
+
+# creates a partition on the system
+part /boot --fstype=ext3 --size=500
+part pv.00 --grow --asprimary --size=1
+
+# Increased pesize from 4096 KB to 262144 KB (0.25GB) to allow bigger logvols
+# Keep 20% of volgroup reserved for future use
+volgroup vg_main --pesize=262144 pv.00
+
+# Use default swap size
+logvol swap --name=lv_swap --vgname=vg_main --recommended
+
+# Allocate the rest to /
+logvol / --fstype=ext4 --name=lv_root --vgname=vg_main --size=1 --grow
+
+################################################################################
+
+%pre
+parted -s /dev/vda mklabel msdos
+
+%packages –nobase
+@core
+vim-minimal
+
+################################################################################
+
+%post
+# cleanup the installation
+yum clean all
+# create default ssh keys
+ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa
+# create default authorized_keys file
+cp -p -f --context=system_u:object_r:ssh_home_t:s0 /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
+chmod 600 /root/.ssh/authorized_keys
+%end
+
+################################################################################
diff --git a/other/kickstarts/centos6-i386-master.cfg b/other/kickstarts/centos6-i386-master.cfg
new file mode 100644
index 0000000..3013505
--- /dev/null
+++ b/other/kickstarts/centos6-i386-master.cfg
@@ -0,0 +1,100 @@
+# text mode (no graphical mode)
+text
+
+# do not configure X
+skipx
+
+# non-interactive command line mode
+cmdline
+
+# install
+install
+
+# installation path
+url --url=http://mirror.switch.ch/ftp/mirror/centos/6/os/i386
+
+# repository
+repo --name="Switch CentOS Repo" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/6/os/i386
+# by specifying the update Repo the install process will automatically update to the latest version. If you wish to stay at the initial release version, comment the following line.
+repo --name="Switch CentOS Repo Update" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/6/updates/i386
+
+# Language support
+lang en_US.UTF-8
+
+# keyboard
+keyboard us
+
+# network
+network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=centos6-32-master
+
+# root password (123qwe, change after cloning)
+rootpw --iscrypted $6$LhelAf3MiEiKEXoZ$4Ymdrfp0TJRtQf0DtkfRqjFzQddX72yYvRlHYapeDxMhdG.HGWm04XX1YOCTleKqsUio04hwbb6/1O.ea4RhM/
+
+# firewall
+firewall --enabled
+firewall --service=ssh
+
+# auth config
+authconfig --enableshadow --passalgo=sha512
+
+# SElinux
+selinux --enforcing
+
+# timezone
+timezone --utc Europe/Zurich
+
+# bootloader
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+
+# clear the MBR (Master Boot Record)
+zerombr
+
+# the Setup Agent is not started the first time the system boots
+firstboot --disable
+
+# power off after installation
+poweroff
+
+################################################################################
+# LVM partitions
+
+# do not remove any partition (preserve the gpt label)
+clearpart --none
+
+# creates a partition on the system
+part /boot --fstype=ext4 --size=500
+part pv.00 --grow --asprimary --size=1
+
+# Increased pesize from 4096 KB to 262144 KB (0.25GB) to allow bigger logvols
+# Keep 20% of volgroup reserved for future use
+volgroup vg_main --pesize=262144 pv.00 --reserved-percent=20
+
+# Use default swap size
+logvol swap --name=lv_swap --vgname=vg_main --recommended
+
+# Allocate the rest to /
+logvol / --fstype=ext4 --name=lv_root --vgname=vg_main --size=1 --grow
+
+################################################################################
+
+%pre
+parted -s /dev/vda mklabel gpt
+
+%packages –nobase
+@core
+@server-policy
+vim-minimal
+
+################################################################################
+
+%post
+# cleanup the installation
+yum clean all
+# create default ssh keys
+ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa
+# create default authorized_keys file
+cp -p -f --context=system_u:object_r:ssh_home_t:s0 /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
+chmod 600 /root/.ssh/authorized_keys
+%end
+
+################################################################################
diff --git a/other/kickstarts/centos6-x86_64-master.cfg b/other/kickstarts/centos6-x86_64-master.cfg
new file mode 100644
index 0000000..4528499
--- /dev/null
+++ b/other/kickstarts/centos6-x86_64-master.cfg
@@ -0,0 +1,100 @@
+# text mode (no graphical mode)
+text
+
+# do not configure X
+skipx
+
+# non-interactive command line mode
+cmdline
+
+# install
+install
+
+# installation path
+url --url=http://mirror.switch.ch/ftp/mirror/centos/6/os/x86_64
+
+# repository
+repo --name="Switch CentOS Repo" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/6/os/x86_64
+# by specifying the update Repo the install process will automatically update to the latest version. If you wish to stay at the initial release version, comment the following line.
+repo --name="Switch CentOS Repo Update" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/6/updates/x86_64
+
+# Language support
+lang en_US.UTF-8
+
+# keyboard
+keyboard us
+
+# network
+network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=centos6-64-master
+
+# root password (123qwe, change after cloning)
+rootpw --iscrypted $6$LhelAf3MiEiKEXoZ$4Ymdrfp0TJRtQf0DtkfRqjFzQddX72yYvRlHYapeDxMhdG.HGWm04XX1YOCTleKqsUio04hwbb6/1O.ea4RhM/
+
+# firewall
+firewall --enabled
+firewall --service=ssh
+
+# auth config
+authconfig --enableshadow --passalgo=sha512
+
+# SElinux
+selinux --enforcing
+
+# timezone
+timezone --utc Europe/Zurich
+
+# bootloader
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+
+# clear the MBR (Master Boot Record)
+zerombr
+
+# the Setup Agent is not started the first time the system boots
+firstboot --disable
+
+# power off after installation
+poweroff
+
+################################################################################
+# LVM partitions
+
+# do not remove any partition (preserve the gpt label)
+clearpart --none
+
+# creates a partition on the system
+part /boot --fstype=ext4 --size=500
+part pv.00 --grow --asprimary --size=1
+
+# Increased pesize from 4096 KB to 262144 KB (0.25GB) to allow bigger logvols
+# Keep 20% of volgroup reserved for future use
+volgroup vg_main --pesize=262144 pv.00 --reserved-percent=20
+
+# Use default swap size
+logvol swap --name=lv_swap --vgname=vg_main --recommended
+
+# Allocate the rest to /
+logvol / --fstype=ext4 --name=lv_root --vgname=vg_main --size=1 --grow
+
+################################################################################
+
+%pre
+parted -s /dev/vda mklabel gpt
+
+%packages –nobase
+@core
+@server-policy
+vim-minimal
+
+################################################################################
+
+%post
+# cleanup the installation
+yum clean all
+# create default ssh keys
+ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa
+# create default authorized_keys file
+cp -p -f --context=system_u:object_r:ssh_home_t:s0 /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
+chmod 600 /root/.ssh/authorized_keys
+%end
+
+################################################################################
diff --git a/other/kickstarts/centos7-x86_64-master.cfg b/other/kickstarts/centos7-x86_64-master.cfg
new file mode 100644
index 0000000..ffbd579
--- /dev/null
+++ b/other/kickstarts/centos7-x86_64-master.cfg
@@ -0,0 +1,108 @@
+# text mode (no graphical mode)
+text
+
+# do not configure X
+skipx
+
+# non-interactive command line mode
+cmdline
+
+# install
+install
+
+# reboot after installation is complete
+reboot
+
+# accept eula
+eula --agreed
+
+# installation path
+url --url=http://mirror.switch.ch/ftp/mirror/centos/7/os/x86_64
+
+# repository
+repo --name="Switch CentOS Repo" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/7/os/x86_64
+# by specifying the update Repo the install process will automatically update to the latest version. If you wish to stay at the initial release version, comment the following line.
+repo --name="Switch CentOS Repo Update" --baseurl=http://mirror.switch.ch/ftp/mirror/centos/7/updates/x86_64
+
+# Language support
+lang en_US.UTF-8
+
+# keyboard
+keyboard us
+
+# network
+network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=centos7-64-master
+
+# root password (123qwe, change after cloning)
+rootpw --iscrypted $6$LhelAf3MiEiKEXoZ$4Ymdrfp0TJRtQf0DtkfRqjFzQddX72yYvRlHYapeDxMhdG.HGWm04XX1YOCTleKqsUio04hwbb6/1O.ea4RhM/
+
+# enable SSH and network manager
+services --enabled=NetworkManager,sshd
+
+# firewall
+firewall --enabled
+firewall --service=ssh
+
+# auth config
+authconfig --enableshadow --passalgo=sha512
+
+# SElinux
+selinux --enforcing
+
+# timezone
+timezone --utc Europe/Zurich
+
+# bootloader
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+
+# clear the MBR (Master Boot Record)
+zerombr
+
+# the Setup Agent is not started the first time the system boots
+firstboot --disable
+
+# power off after installation
+poweroff
+
+################################################################################
+# LVM partitions
+
+bootloader --location=mbr --boot-drive=vda
+clearpart --all --drives=vda
+ignoredisk --only-use=vda
+
+part /boot --fstype="xfs" --ondisk=vda --size=512
+part pv.01 --fstype="lvmpv" --ondisk=vda --grow --size=1
+
+volgroup vg_main pv.01
+logvol / --fstype="xfs" --name=lv_root --vgname=vg_main --grow --size=2048
+logvol swap --fstype="swap" --name=lv_swap --vgname=vg_main --grow --size=2048 --maxsize=2048
+
+
+################################################################################
+
+#%pre
+#parted -s /dev/vda mklabel gpt
+#%end
+
+%packages –nobase
+@core
+#@server-policy
+vim-minimal
+%end
+
+################################################################################
+
+%post
+# cleanup the installation
+yum clean all
+# create default ssh keys
+ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa
+# create default authorized_keys file
+cp -p -f --context=system_u:object_r:ssh_home_t:s0 /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
+chmod 600 /root/.ssh/authorized_keys
+%end
+
+################################################################################
+
+
diff --git a/other/kickstarts/handmade/Centos5-32.cfg b/other/kickstarts/handmade/Centos5-32.cfg
new file mode 100644
index 0000000..0aa25ef
--- /dev/null
+++ b/other/kickstarts/handmade/Centos5-32.cfg
@@ -0,0 +1,24 @@
+# Kickstart file automatically generated by anaconda.
+
+install
+url --url http://swissmirror.silyus.net/centos/5.8/os/i386
+lang en_US.UTF-8
+keyboard us
+network --device eth0 --bootproto dhcp --hostname CentOS-5-32-Master
+rootpw --iscrypted $1$U9eue073$hpWqFVoP4I6.dvT0qz2uB/
+firewall --enabled --port=22:tcp
+authconfig --enableshadow --enablemd5
+selinux --enforcing
+timezone --utc Europe/Zurich
+bootloader --location=mbr --driveorder=vda
+# The following is the partition information you requested
+# Note that any partitions you deleted are not expressed
+# here so unless you clear all partitions first, this is
+# not guaranteed to work
+#clearpart --linux
+#part / --fstype ext3 --size=1 --grow --asprimary
+#part swap --size=1024 --asprimary
+
+%packages
+@core
+sgpio
diff --git a/other/kickstarts/handmade/Centos5-64.cfg b/other/kickstarts/handmade/Centos5-64.cfg
new file mode 100644
index 0000000..a6e22a7
--- /dev/null
+++ b/other/kickstarts/handmade/Centos5-64.cfg
@@ -0,0 +1,24 @@
+# Kickstart file automatically generated by anaconda.
+
+install
+url --url http://swissmirror.silyus.net/centos/5.8/os/x86_64
+lang en_US.UTF-8
+keyboard us
+network --device eth0 --bootproto dhcp --hostname CentOS-5-64-Master
+rootpw --iscrypted $1$LlZErziA$y7scQObxRfmO4HZc0wfhO0
+firewall --enabled --port=22:tcp
+authconfig --enableshadow --enablemd5
+selinux --enforcing
+timezone --utc Europe/Zurich
+bootloader --location=mbr --driveorder=vda
+# The following is the partition information you requested
+# Note that any partitions you deleted are not expressed
+# here so unless you clear all partitions first, this is
+# not guaranteed to work
+#clearpart --linux
+#part / --fstype ext3 --size=1 --grow --asprimary
+#part swap --size=1024 --asprimary
+
+%packages
+@core
+sgpio
diff --git a/other/kickstarts/handmade/Centos6-32.cfg b/other/kickstarts/handmade/Centos6-32.cfg
new file mode 100644
index 0000000..13f9a29
--- /dev/null
+++ b/other/kickstarts/handmade/Centos6-32.cfg
@@ -0,0 +1,30 @@
+# Kickstart file automatically generated by anaconda.
+
+#version=DEVEL
+install
+url --url=http://swissmirror.silyus.net/centos/6.3/os/i386
+lang en_US.UTF-8
+keyboard us
+network --onboot yes --device eth0 --bootproto dhcp --noipv6
+rootpw --iscrypted $6$cybIqb74.gcQQCoV$oqwTnlZbhgVKc5yZJuRZDEhKjFNv2ha3WTbra9BhbvPxdfu/23Pr8XXA5YW6G.trb65Q60Ji3Vapmd5Eek4Od0
+firewall --service=ssh
+authconfig --enableshadow --passalgo=sha512
+selinux --enforcing
+timezone --utc Europe/Zurich
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+# The following is the partition information you requested
+# Note that any partitions you deleted are not expressed
+# here so unless you clear all partitions first, this is
+# not guaranteed to work
+#clearpart --none
+
+
+#part swap --asprimary --size=1024
+#part / --fstype=ext4 --grow --asprimary --size=200
+
+repo --name="CentOS" --baseurl=http://swissmirror.silyus.net/centos/6.3/os/i386 --cost=100
+
+%packages
+@core
+@server-policy
+%end \ No newline at end of file
diff --git a/other/kickstarts/handmade/Centos6-64.cfg b/other/kickstarts/handmade/Centos6-64.cfg
new file mode 100644
index 0000000..fa0954b
--- /dev/null
+++ b/other/kickstarts/handmade/Centos6-64.cfg
@@ -0,0 +1,30 @@
+# Kickstart file automatically generated by anaconda.
+
+#version=DEVEL
+install
+url --url=http://swissmirror.silyus.net/centos/6.3/os/x86_64/
+lang en_US.UTF-8
+keyboard us
+network --onboot yes --device eth0 --bootproto dhcp --noipv6
+rootpw --iscrypted $6$LhelAf3MiEiKEXoZ$4Ymdrfp0TJRtQf0DtkfRqjFzQddX72yYvRlHYapeDxMhdG.HGWm04XX1YOCTleKqsUio04hwbb6/1O.ea4RhM/
+firewall --service=ssh
+authconfig --enableshadow --passalgo=sha512
+selinux --enforcing
+timezone --utc Europe/Zurich
+bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
+# The following is the partition information you requested
+# Note that any partitions you deleted are not expressed
+# here so unless you clear all partitions first, this is
+# not guaranteed to work
+#clearpart --none
+
+
+#part swap --onpart=vda1
+#part / --fstype=ext4 --onpart=vda2
+
+repo --name="CentOS" --baseurl=http://swissmirror.silyus.net/centos/6.3/os/x86_64/ --cost=100
+
+%packages
+@core
+@server-policy
+%end \ No newline at end of file
diff --git a/other/kickstarts/handmade/Centos7-64.cfg b/other/kickstarts/handmade/Centos7-64.cfg
new file mode 100644
index 0000000..b985f80
--- /dev/null
+++ b/other/kickstarts/handmade/Centos7-64.cfg
@@ -0,0 +1,32 @@
+#version=RHEL7
+# System authorization information
+auth --enableshadow --passalgo=sha512
+
+# Use CDROM installation media
+cdrom
+# Run the Setup Agent on first boot
+firstboot --enable
+ignoredisk --only-use=vda
+# Keyboard layouts
+keyboard --vckeymap=us --xlayouts='us'
+# System language
+lang en_US.UTF-8
+
+# Network information
+network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto
+network --hostname=centos7test
+# Root password
+rootpw --iscrypted $6$3M1tV8rDh8wtW390$g0hBugm3NBQZrYm7cBL4XfARtvuqjzEI1kHBt965W/Hhrus4VteDumTQoLCiISjbTrv1Jnzqs.GWHtlh3Ewkh.
+# System timezone
+timezone America/New_York --isUtc
+# System bootloader configuration
+bootloader --location=mbr --boot-drive=vda
+autopart --type=lvm
+# Partition clearing information
+clearpart --none --initlabel
+
+%packages
+@core
+
+%end
+
diff --git a/other/scripts/centoskvm.sh b/other/scripts/centoskvm.sh
new file mode 100755
index 0000000..965550d
--- /dev/null
+++ b/other/scripts/centoskvm.sh
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+#==============================================================================+
+# File name : centoskvm.sh
+# Begin : 2013-04-18
+# Last Update : 2013-04-25
+# Version : 1.0.0
+#
+# Description : Shell script used to generate a CentOS Virtual Machine image.
+#
+# Website : https://github.com/fubralimited/CentOS-KVM-Image-Tools
+#
+# Author: Nicola Asuni
+#
+# (c) Copyright:
+# Fubra Limited
+# Manor Coach House
+# Church Hill
+# Aldershot
+# Hampshire
+# GU12 4RQ
+# UK
+# http://www.fubra.com
+# support@fubra.com
+#
+# License:
+# Copyright (C) 2012-2013 Fubra Limited
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# See LICENSE.TXT file for more information.
+#==============================================================================+
+
+# CONFIGURATION
+
+LIBVIRT_IMAGE_BASE=/data/libvirt
+
+# USAGE EXAMPLE:
+# sh centoskvm.sh centos-gold-master
+
+# ensure script is being run as root
+if [ `whoami` != root ]; then
+ echo "ERROR: This script must be run as root" 1>&2
+ exit 1
+fi
+
+# check for image name and kickstart file
+if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
+ echo "ERROR: No argument supplied. Please provide the following parameters:"
+ echo " <image name> [ x86_64 | i386 ] [ 5 | 6 | 7 ] [<kickstart>] [<options>]"
+ echo " being architecture and 5 6 7 being the major Centos version"
+ echo " <kickstart> provide your own optional kickstart file"
+ echo " <options> currently the only option is 'noshrink':"
+ echo " noshrink: don't skrink the image to minimal size after building"
+ exit 1
+fi
+
+# name of the image
+IMGNAME=$1
+
+# architecture
+ARCH=$2
+
+# version of Centos
+VER=$3
+
+if test "X$4" != "X"; then
+ KICKSTART=$4
+else
+ # compose the name of the kickstart file
+ KICKSTART=centos$3-$ARCH-master.cfg
+fi
+
+# some sanity checks per architecture and major release
+# and set some limits
+case ${ARCH}_${VER} in
+ i386_5|x86_64_5|i386_6|x86_64_6)
+ VM_MEMORY=512
+ ;;
+
+ x86_64_7)
+ VM_MEMORY=1024
+ ;;
+
+ i386_7|*)
+ echo "Unsupported architecture '$ARCH' and major release '$VER'" 1>&2
+ exit 1
+esac
+
+# VM image file extension
+EXT="qcow2"
+
+echo "Generating VM ..."
+
+# create image file
+virt-install \
+--name $IMGNAME \
+--ram $VM_MEMORY \
+--cpu host \
+--vcpus 1 \
+--nographics \
+--os-type=linux \
+--os-variant=rhel$VER \
+--location=http://mirror.switch.ch/ftp/mirror/centos/$VER/os/$ARCH \
+--initrd-inject=kickstarts/$KICKSTART \
+--extra-args="ks=file:/$KICKSTART text console=tty0 utf8 console=ttyS0,115200" \
+--disk path=$LIBVIRT_IMAGE_BASE/$IMGNAME.$EXT,size=10,bus=virtio,format=qcow2 \
+--force \
+--noreboot
+
+# change directory
+cd $LIBVIRT_IMAGE_BASE
+
+if test "X$5" != "Xnoshrink"; then
+
+ # reset, unconfigure a virtual machine so clones can be made
+ virt-sysprep --no-selinux-relabel -a $IMGNAME.$EXT
+
+ # SELinux: relabelling all filesystem
+ #guestfish --selinux -i $IMGNAME.$EXT <<EOF
+ #sh load_policy
+ #sh 'restorecon -R -v /'
+ #EOF
+ # fails with:
+ #*stdin*:1: libguestfs: error: sh: SELinux: Could not downgrade policy file /etc/selinux/targeted/policy/policy.24, searching for an older version.
+ #SELinux: Could not open policy file <= /etc/selinux/targeted/policy/policy.24: No such file or directory
+ # really needed?
+
+ # make a virtual machine disk sparse
+ TMPDIR=/data/tmp virt-sparsify --compress --convert qcow2 --format qcow2 $IMGNAME.$EXT $IMGNAME-sparsified.$EXT
+
+ # remove original image
+ rm -rf $IMGNAME.$EXT
+
+ # rename sparsified
+ mv $IMGNAME-sparsified.$EXT $IMGNAME.$EXT
+
+fi
+
+# set correct ownership for the VM image file
+#chown qemu:qemu $IMGNAME.$EXT
+
+echo "Process Completed. Use the 'virt start $IMGNAME' command to start the newly created VM."
+
+#==============================================================================+
+# END OF FILE
+#==============================================================================+
diff --git a/other/scripts/resizevm.sh b/other/scripts/resizevm.sh
new file mode 100755
index 0000000..aaaa3ae
--- /dev/null
+++ b/other/scripts/resizevm.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+#==============================================================================+
+# File name : resizevm.sh
+# Begin : 2013-04-18
+# Last Update : 2013-04-23
+# Version : 1.0.0
+#
+# Description : Shell script used to resize Virtual Machine image.
+#
+# Website : https://github.com/fubralimited/CentOS-KVM-Image-Tools
+#
+# Author: Nicola Asuni
+#
+# (c) Copyright:
+# Fubra Limited
+# Manor Coach House
+# Church Hill
+# Aldershot
+# Hampshire
+# GU12 4RQ
+# UK
+# http://www.fubra.com
+# support@fubra.com
+#
+# License:
+# Copyright (C) 2012-2013 Fubra Limited
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# See LICENSE.TXT file for more information.
+#==============================================================================+
+
+# USAGE EXAMPLE:
+# sh resizevm.sh VM_NAME VM_SIZE
+# sh resizevm.sh centosvm 20G
+
+# NOTE: This script assume that the VM images are created using the centoskvm.sh
+# script and located at /data/images
+
+# ensure script is being run as root
+if [ `whoami` != root ]; then
+ echo "ERROR: This script must be run as root" 1>&2
+ exit 1
+fi
+
+# check for vm name
+if [ -z "$1" ]; then
+ echo "ERROR: No argument supplied. Please provide the Virtual machine name."
+ exit 1
+fi
+
+# name of the image
+VMNAME=$1
+
+# check for new size
+if [ -z "$2" ]; then
+ echo "ERROR: Missing size argument. Please provide the Virtual machine name new size."
+ exit 1
+fi
+
+echo "Resizing VM ..."
+
+# new size of the image
+VMSIZE=$2
+
+# extract VM file name
+VMFILE=$(virsh dumpxml $VMNAME | grep "<source file='" | sed "s/[\t ]*<source file='\/data\/images\///" | sed "s/'\/>//")
+
+export TMPDIR=/data/tmp/
+
+# shut the virtual machine down
+virsh shutdown $VMNAME
+
+# change directory
+cd /data/images
+
+# clone VM image
+cp -f $VMFILE $VMFILE.tmp
+
+# resize the cloned image (i.e. 20 GB)
+qemu-img resize $VMFILE.tmp $VMSIZE
+
+# resize the partitions
+virt-resize --expand /dev/vda2 --LV-expand /dev/vg_main/lv_root $VMFILE $VMFILE.tmp
+
+# make a backup of the VM for any evenience:
+mv -f $VMFILE $VMFILE.backup
+
+# sparsify image
+virt-sparsify --format qcow2 --compress $VMFILE.tmp $VMFILE
+
+# remove the resized image
+rm -f $VMFILE.tmp
+
+# set file ownership
+chown qemu:qemu $VMFILE
+
+# restart the virtual machine
+virsh start $VMNAME
+
+# if the new image works fine, then we can delete the backup image:
+#rm -rf $VMFILE.backup
+
+echo "Process Completed. Please try the new image and delete the backup file if everything is OK."
+
+#==============================================================================+
+# END OF FILE
+#==============================================================================+