From db1dc24674145ca688685aeba8c644f293741eab Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 17 Jun 2014 22:08:33 +0100 Subject: [PATCH] Initial import of files for OpenVZ * added kickstart file for the image * script to convert an image to a tarred VZ image --- openvz/README.md | 7 +++ openvz/img2vz.sh | 25 +++++++++ openvz/openvz-7.ks | 136 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 openvz/README.md create mode 100644 openvz/img2vz.sh create mode 100644 openvz/openvz-7.ks diff --git a/openvz/README.md b/openvz/README.md new file mode 100644 index 0000000..1cfd0a0 --- /dev/null +++ b/openvz/README.md @@ -0,0 +1,7 @@ +# OpenVZ Image + +This folder has 2 files + +* openvz-7.cfg -- kickstart file to install a VM +* img2vz.sh -- will convert the an VM img to a VZ distributable tar file + diff --git a/openvz/img2vz.sh b/openvz/img2vz.sh new file mode 100644 index 0000000..adf1362 --- /dev/null +++ b/openvz/img2vz.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# This script imports a raw image into OpenVZ consumeable tarball. It takes one +# arguments: the name of the image file + +usage() { + echo "usage: $(basename $0) " + exit 1 +} + +image="$1" + +if [[ -z $1 ]]; then + usage +fi + +mount="$(mktemp -d --tmpdir)" +mount -o loop "$image" "$mount" + +cd "$mount" +tar -cpzf ${image}.tar.gz --acls --selinux --xattrs . + +cd - >& /dev/null +umount "$mount" +rmdir "$mount" diff --git a/openvz/openvz-7.ks b/openvz/openvz-7.ks new file mode 100644 index 0000000..2df1fef --- /dev/null +++ b/openvz/openvz-7.ks @@ -0,0 +1,136 @@ +install +#url --url=http://mirror.centos.org/centos/7/os/x86_64/ +url --url=http://buildlogs.centos.org/centos/7/os/x86_64-20140614/ +lang en_GB.UTF-8 +keyboard uk +network --device eth0 --bootproto dhcp +rootpw --iscrypted $1$UKLtvLuY$kka6S665oCFmU7ivSDZzU. +authconfig --enableshadow --passalgo=sha512 --enablefingerprint +selinux --enforcing +timezone --utc Europe/London +skipx +#repo --name="CentOS" --baseurl=http://mirror.centos.org/centos/7/os/x86_64/ --cost=100 +#repo --name="Updates" --baseurl=http://mirror.centos.org/centos-7/7/updates/x86_64/ --cost=100 +# CentOSPlus is here ONLY for a libselinux patch. +# Once 6.6 is released, this should be removed +# http://lists.centos.org/pipermail/centos-devel/2014-May/010345.html +#repo --name="CentOSPlus" --baseurl=http://mirror.centos.org/centos-7/7/centosplus/x86_64/ --cost=1000 + +clearpart --all --initlabel +part / --fstype ext4 --size=1024 --grow +reboot +%packages --excludedocs --nobase +@Core +-aic94xx-firmware +-alsa-firmware +-alsa-tools-firmware +-cronie +-dhclient +-efibootmgr +-ethtool +-iproute +-iptables +-iputils +-ivtv-firmware +-iwl100-firmware +-iwl105-firmware +-iwl135-firmware +-iwl1000-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6000g2b-firmware +-iwl6050-firmware +-iwl7260-firmware +-kbd +-libertas-sd8686-firmware +-libertas-sd8787-firmware +-libertas-usb8388-firmware +-libertas-usb8388-olpc-firmware +-linux-firmware +-postfix +-policycoreutils +-rsyslog +-selinux-policy +-selinux-policy-targeted +-sudo +-upstart +-vim-minimal +-xorg-x11-drv-ati-firmware +-zd1211-firmware +openssh-clients +openssh-server +yum +yum-utils +man +wget +sudo +tar +passwd +%end + +%post +# randomize root password and lock root account +dd if=/dev/urandom count=50 | md5sum | passwd --stdin root +passwd -l root + +# create necessary devices +/sbin/MAKEDEV /dev/console + +# cleanup unwanted stuff + +# ami-creator requires grub during the install, so we remove it (and +# its dependencies) in %post +rpm -e grub2 grub2-tools grubby centos-logos plymouth plymouth-scripts +rm -rf /boot + +# some packages get installed even though we ask for them not to be, +# and they don't have any external dependencies that should make +# anaconda install them +rpm -e MAKEDEV ethtool upstart initscripts iputils policycoreutils iptables \ + iproute + +# Remove kernel, as it's not required for openvz installations +rpm -e kernel + +# Remove files that are known to take up lots of space but leave +# directories intact since those may be required by new rpms. + +# locales +find /usr/{{lib,share}/{i18n,locale},{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive} \ + -type f | xargs /bin/rm + +# man pages and documentation +find /usr/share/{man,doc,info,gnome/help} \ + -type f | xargs /bin/rm + +# cracklib +find /usr/share/cracklib \ + -type f | xargs /bin/rm + +# sln +rm -f /sbin/sln + +# ldconfig +rm -rf /etc/ld.so.cache +rm -rf /var/cache/ldconfig/* + +# fstab +cat > /etc/fstab << __FSTAB__ +none /dev/pts devpts rw,gid=5,mode=620 0 0 +none /dev/shm tmpfs defaults 0 0 +__FSTAB__ + +# Timezone +cp -f /usr/share/zoneinfo/GMT /etc/localtime + +# Update the CONSOLEs for the image +sed -i -e 's/^\(ACTIVE_CONSOLES=\).*/\1//g' /etc/sysconfig/init + +%end