>>>up
>>
>>я скриптом генерирую хост систему через локальный репозиторий yum, система Centos44.
>>
>>выходит порядка в ~300Мб.
>>
>>могу кинуть сюда... ~6кб
>кидай...проверю, но у меня хостовая стоит уже - мне надо гостевую прикрутить.
>Спасибо.
#!/bin/bash
#
# create new XEN domain
#
XEN_HOSTNAME="www2.test.domain.ru"
XEN_KERNEL_VERSION="2.6.9-42.0.3.EL.xs0.4.0.263"
XEN_ROOT="file:/xen/www2.test.domain.ru"
XEN_SWAP="file:/xen/www2.test.domain.swap"
XEN_RPM_KERNELU=/etc/xen/kernel-xenU-${XEN_KERNEL_VERSION}.i686.rpm
XEN_TMP_PREFIX=/mnt/XENROOT_TEMP
XEN_KERNEL_DIR=/etc/xen/kernel
XEN_CONF_DIR=/etc/xen
XEN_KERNEL="vmlinuz-${XEN_KERNEL_VERSION}xenU"
echo "create MAC"
T1=`head -c 5 /dev/urandom | md5sum | head -c 2`
T2=`head -c 5 /dev/urandom | md5sum | head -c 2`
T3=`head -c 5 /dev/urandom | md5sum | head -c 2`
XEN_HWADDR="AA:00:00:${T1}:${T2}:${T3}"
XEN_DHCP_HOSTNAME=`echo $XEN_HOSTNAME | awk -F'.' '{ print $1 }'`
if [ -d ${XEN_TMP_PREFIX} ]; then
echo "Please umount or remove ${XEN_TMP_PREFIX}"
exit
fi
if [ ! -f ${XEN_RPM_KERNELU} ]; then
echo "Please check kernel xenU rpm: ${XEN_RPM_KERNELU}"
exit
fi
XEN_DEV1=`echo ${XEN_ROOT} | awk -F':' '{ print $1 }'`
XEN_DEV2=`echo ${XEN_ROOT} | awk -F':' '{ print $2 }'`
mkdir -p ${XEN_TMP_PREFIX}
mkdir -p ${XEN_KERNEL_DIR}
if [ ${XEN_DEV1} == "file" ]; then
MOUNT_OPTIONS="-oloop"
fi
mount $MOUNT_OPTIONS ${XEN_DEV2} ${XEN_TMP_PREFIX} || ( echo "error mount"; exit )
echo "mount xen root disk"
mkdir -p "${XEN_TMP_PREFIX}/dev"
mkdir -p "${XEN_TMP_PREFIX}/etc/sysconfig/network-scripts"
mkdir -p "${XEN_TMP_PREFIX}/var/lock/rpm"
mkdir -p "${XEN_CONF_DIR}/domains"
cat > ${XEN_TMP_PREFIX}/etc/fstab <<EOF
/dev/sda1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/sdb1 swap swap defaults 0 0
EOF
echo "create fstab"
cat > ${XEN_TMP_PREFIX}/etc/hosts <<EOF
127.0.0.1 localhost.localdomain localhost
EOF
for i in console null zero tty tty0 tty1 tty2 tty3 tty4 tty5 tty6 tty7 tty8 tty9; do /sbin/MAKEDEV -d $XEN_TMP_PREFIX/dev -x $i; done
cat > ${XEN_TMP_PREFIX}/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=${XEN_DHCP_HOSTNAME}
EOF
cat > ${XEN_TMP_PREFIX}/etc/sysconfig/network <<EOF
NETWORKING=yes
HOSTNAME=${XEN_HOSTNAME}
NOZEROCONF=1
GATEWAY=
EOF
echo "create network config"
yum --installroot=${XEN_TMP_PREFIX}/ -y install acl attr audit audit-libs authconfig basesystem bash beecrypt bind-libs \
bind-utils bluez-libs bzip2 bzip2-libs centos-release checkpolicy chkconfig coreutils cpio cracklib cracklib-dicts \
crontabs cups-libs cyrus-sasl cyrus-sasl-md5 cyrus-sasl-plain db4 device-mapper dhclient diffutils dos2unix e2fsprogs \
elfutils elfutils-libelf ethtool expat file filesystem findutils gawk gdbm gettext glib2 glibc glibc-common gmp gnupg \
grep groff gzip hesiod hotplug hwdata info initscripts iproute iptables iptstate iputils kbd keyutils keyutils-libs \
krb5-libs less libacl libattr libcap libgcc libgcrypt libgpg-error libgssapi libjpeg libpcap libpng libselinux \
libsepol libstdc++ libtermcap libtiff libusb libuser libwvstreams libxml2 libxml2-python libxslt lockdev logrotate \
logwatch lsof lvm2 m4 mailcap mailx make MAKEDEV man man-pages mingetty mkinitrd mktemp module-init-tools mtools \
ncurses netconfig net-snmp-libs net-tools newt nfs-utils-lib nscd nss_db nss_ldap ntsysv numactl openssh \
openssh-clients openssh-server openssl pam pam_ccreds pam_krb5 pam_passwdqc passwd patch pciutils pcre perl \
perl-Filter policycoreutils popt procmail procps psmisc python python-elementtree python-sqlite python-urlgrabber \
quota readline redhat-logos rootfiles rpm rpmdb-CentOS rpm-libs rpm-python schedutils sed selinux-policy-targeted \
sendmail setarch setools setup setuptool shadow-utils slang specspo sqlite sudo symlinks sysklogd syslinux sysreport \
system-config-securitylevel-tui SysVinit tar tcp_wrappers termcap time tmpwatch tzdata udev unzip usbutils usermode \
utempter util-linux vconfig vim-minimal vixie-cron which xinetd xmlsec1 xmlsec1-openssl yum zip zlib ntp
rpm -ivh --root=${XEN_TMP_PREFIX}/ ${XEN_RPM_KERNELU}
rpm -ev --root=${XEN_TMP_PREFIX}/ kernel
mv ${XEN_TMP_PREFIX}/lib/tls ${XEN_TMP_PREFIX}/lib/tls.disabled
echo "move tls to tls.disabled"
cat > ${XEN_TMP_PREFIX}/etc/inittab <<EOF
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
1:2345:respawn:/sbin/mingetty tty1
EOF
echo "create inittab"
mkdir ${XEN_TMP_PREFIX}/etc/yum.repos.d/orig
mv ${XEN_TMP_PREFIX}/etc/yum.repos.d/*.repo ${XEN_TMP_PREFIX}/etc/yum.repos.d/orig
cat > ${XEN_TMP_PREFIX}/etc/sysconfig/clock <<EOF
ZONE="Asia/Irkutsk"
UTC=false
ARC=false
EOF
cat > ${XEN_TMP_PREFIX}/etc/yum.repos.d/CentOS-Base.repo <<EOF
[base]
name=CentOS-\$releasever - Base
baseurl=http://server-update/CentOS/\$releasever/os/\$basearch/
gpgcheck=0
enabled=1
[update]
name=CentOS-\$releasever - Updates
baseurl=http://server-update/CentOS/\$releasever/updates/\$basearch/
gpgcheck=0
enabled=1
[dag]
name=CentOS-\$releasever - DAG
baseurl=http://server-update/CentOS/\$releasever/dag/\$basearch/
gpgcheck=0
enabled=1
EOF
cat > "${XEN_CONF_DIR}/domains/${XEN_HOSTNAME}.conf" <<EOF
kernel ="${XEN_KERNEL_DIR}/${XEN_KERNEL}"
memory = 48
vcpus = 1
name = "${XEN_HOSTNAME}"
vif = ['mac=${XEN_HWADDR}']
dhcp = "dhcp"
disk = ['${XEN_ROOT},sda1,w','${XEN_SWAP},sdb1,w']
root = "/dev/sda1"
extra = "ro selinux=0 3"
EOF
echo "create ${XEN_CONF_DIR}/domains/${XEN_HOSTNAME}.conf"
if [ ! -f "${XEN_KERNEL_DIR}/${XEN_KERNEL}" ]; then
cp ${XEN_TMP_PREFIX}/boot/${XEN_KERNEL} ${XEN_KERNEL_DIR}
fi
rm -f ${XEN_TMP_PREFIX}/var/cache/yum/base/packages/*
rm -f ${XEN_TMP_PREFIX}/var/cache/yum/update/packages/*
umount ${XEN_TMP_PREFIX}/proc
umount ${XEN_TMP_PREFIX}
rm -rf ${XEN_TMP_PREFIX}
echo "building complete!"
echo "start example: xm create -c ${XEN_CONF_DIR}/domains/${XEN_HOSTNAME}.conf"