Initial import of files for OpenVZ

* added kickstart file for the image
* script to convert an image to a tarred VZ image
This commit is contained in:
Arif Ali 2014-06-17 22:08:33 +01:00
parent 5acdb70216
commit db1dc24674
3 changed files with 168 additions and 0 deletions

7
openvz/README.md Normal file
View File

@ -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

25
openvz/img2vz.sh Normal file
View File

@ -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) <image>"
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"

136
openvz/openvz-7.ks Normal file
View File

@ -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