網頁

2011年11月8日 星期二

Install Xen 4.0.1 on CentOS 6

Reference document: RHEL6Xen4Tutorial
According to  reference document, I wrote a shell script to install Xen4.0.1 on CentOS 6

#!/bin/bash
# Program:
#       Install-xen4.0.1.sh
# History:
# 2011/10/20    howie YU   First release

if [ $UID != "0" ]; then
  echo " You must be root to run the script or run it with sudo"
  exit 1;
fi

if [ $# -lt 1 ]; then
  echo " Usage: ./install-xen.sh   "
  echo " if src path in ~/xen/ then =xen "
  echo " The script assumes the guest being clone is a Red Hat based system"
  exit 1;
fi
installPath=$1

chkconfig --list network
yum -y update
yum -y install screen vim wget tcpdump ntp ntpdate man smartmontools links lynx ethtool xorg-x11-xauth
yum -y groupinstall "Development tools" "Additional Development" "Debugging Tools" "System administration tools" "Compatibility libraries" "Console internet tools" "Desktop Platform Development"
yum -y install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel
yum -y install glibc-devel.i686

echo "Remove old virtlib....."
yum -y groupremove "Virtualization"

echo "Prepare for qeum...."
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Everything/i386/os/Packages/openbios-common-1.0-2.fc12.noarch.rpm
wget ftp://ftp.pbone.net/mirror/download.fedora.redhat.com/pub/fedora/linux/releases/14/Everything/i386/os/Packages/openbios-ppc-1.0-2.fc12.noarch.rpm
wget ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/releases/test/16-Alpha/Fedora/x86_64/os/Packages/seabios-bin-0.6.2-2.fc16.noarch.rpm
wget ftp://bo.mirror.garr.it/pub/1/fedora/linux/development/16/x86_64/os/Packages/seabios-0.6.2-2.fc16.x86_64.rpm
wget ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/releases/15/Everything/i386/os/Packages/gpxe-roms-qemu-1.0.1-4.fc15.noarch.rpm


rpm -ivh openbios-common-1.0-2.fc12.noarch.rpm
rpm -ivh openbios-ppc-1.0-2.fc12.noarch.rpm
rpm -e seabios
rpm -ivh seabios-bin-0.6.2-2.fc16.noarch.rpm
rpm -ivh seabios-0.6.2-2.fc16.x86_64.rpm
rpm -e gpxe-roms-qemu
rpm -ivh gpxe-roms-qemu-1.0.1-4.fc15.noarch.rpm

wget http://dl.fedoraproject.org/pub/fedora/linux/updates/13/SRPMS/qemu-0.13.0-1.fc13.src.rpm
rpm -i qemu-0.13.0-1.fc13.src.rpm
rpmbuild -bb ~/rpmbuild/SPECS/qemu.spec

rpm -ivh  ~/rpmbuild/RPMS/x86_64/qemu-common-0.13.0-1.el6.x86_64.rpm
rpm -Uvh  ~/rpmbuild/RPMS/x86_64/qemu-img-0.13.0-1.el6.x86_64.rpm
rpm -Uvh  ~/rpmbuild/RPMS/x86_64/qemu-user-0.13.0-1.el6.x86_64.rpm
rpm -Uvh  ~/rpmbuild/RPMS/x86_64/qemu-system-*
rpm -ivh  ~/rpmbuild/RPMS/x86_64/qemu-kvm-*
rpm -ivh  ~/rpmbuild/RPMS/x86_64/qemu-debuginfo-0.13.0-1.el6.x86_64.rpm
rpm -ivh  ~/rpmbuild/RPMS/x86_64/qemu-0.13.0-1.el6.x86_64.rpm

echo "start to build xen"

wget ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/releases/14/Fedora/source/SRPMS/xen-4.0.1-6.fc14.src.rpm
rpm -i xen-4.0.1-6.fc14.src.rpm
rpmbuild -bb ~/rpmbuild/SPECS/xen.spec

rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-licenses-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-libs-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-hypervisor-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-runtime-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-doc-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-devel-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-debuginfo-4.0.1-6.el6.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/xen-4.0.1-6.el6.x86_64.rpm

echo "Prepare for libvirt install...."


yum -y install xhtml1-dtds libudev-devel libpciaccess-devel  yajl-devel libpcap-devel  libnl-devel avahi-devel  parted-devel device-mapper-devel numactl-devel  netcf-devel augeas radvd systemtap-sdt-devel gnutls-utils

wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/libvirt-0.8.7-18.el6_1.1.src.rpm
rpm -ivh libvirt-0.8.7-18.el6_1.1.src.rpm
wget http://pasik.reaktio.net/xen/patches/libvirt-spec-rhel6-enable-xen.patch
cp -a ~/rpmbuild/SPECS/libvirt.spec /root/rpmbuild/SPECS/libvirt.spec.orig
cd ~/rpmbuild/SPECS/
patch -p0 < ~/$installPath/libvirt-spec-rhel6-enable-xen.patch
cd ~/
rpmbuild -bb ~/rpmbuild/SPECS/libvirt.spec

echo "Remove old libvirt....."
yum -y erase libvirt-client

echo " reinstall libvirt......."

rpm -ivh  ~/rpmbuild/RPMS/x86_64/libvirt-client-0.8.7-18.el6.1.x86_64.rpm
rpm -ivh  ~/rpmbuild/RPMS/x86_64/libvirt-devel-0.8.7-18.el6.1.x86_64.rpm
rpm -ivh  ~/rpmbuild/RPMS/x86_64/libvirt-python-0.8.7-18.el6.1.x86_64.rpm
rpm -ivh  ~/rpmbuild/RPMS/x86_64/libvirt-debuginfo-0.8.7-18.el6.1.x86_64.rpm
rpm -ivh  ~/rpmbuild/RPMS/x86_64/libvirt-0.8.7-18.el6.1.x86_64.rpm

yum -y install virt-manager virt-top virt-viewer

#
# CentOS 6 and RHEL 6 has IGMP built into the bridge-utils. To prevent unnecessary error message, we will need to get Fedora version of bridge-utils source and rebuild it.
#
#
yum -y install  libsysfs-devel

wget ftp://ftp.icm.edu.pl/vol/rzm2/linux-fedora-secondary/development/15/source/SRPMS/bridge-utils-1.2-9.fc13.src.rpm
rpm -i bridge-utils-1.2-9.fc13.src.rpm
rpmbuild -bb ~/rpmbuild/SPECS/bridge-utils.spec

rpm -ivh --force ~/rpmbuild/RPMS/x86_64/bridge-utils-1.2-9.el6.x86_64.rpm


echo "prepare for kernel build "
yum -y install xmlto asciidoc newt-devel perl-ExtUtils-Embed


rpm -ivh kernel-2.6.32-131.12.1.el6.xendom0.src.rpm
rngd -r /dev/urandom
rpmbuild -bb --with baseonly --with firmware --without debuginfo --target=`uname -m`  ~/rpmbuild/SPECS/kernel.spec

rpm -Uvh ~/rpmbuild/RPMS/x86_64/kernel-firmware-2.6.32-131.12.1.el6.xendom0.x86_64.rpm
rpm -Uvh ~/rpmbuild/RPMS/x86_64/kernel-headers-2.6.32-131.12.1.el6.xendom0.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/kernel-devel-2.6.32-131.12.1.el6.xendom0.x86_64.rpm
rpm -ivh ~/rpmbuild/RPMS/x86_64/kernel-2.6.32-131.12.1.el6.xendom0.x86_64.rpm

chkconfig ksm off
chkconfig ksmtuned off

#
# title CentOS (2.6.18-128.1.10.el5)
# root (hd0,0)
# kernel /boot/vmlinuz-2.6.18-128.1.10.el5 ro root=LABEL=/ console=ttyS0
# initrd /boot/initrd-2.6.18-128.1.10.el5.img
#
#
#
echo "ttyS0" >> /etc/securetty

echo "Finish pleas check /etc/grub.conf"
echo " kernel /xen.gz dom0_mem=4096M console=ttyS0 loglvl=all guest_loglvl=all"
echo "module max_loop=256 earlyprintk=xen"

沒有留言:

張貼留言