12
edits
Changes
Disabled services added/fixed.
* Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr).
== Setup variables for 12.04 (Precise Pangolin) ==
Common part:
ARCH="i386"
export COUNTRY="de"
For 12.04 (Precise Pangolin):
export DIST="precise"
export NAME="ubuntu1204"
TMPL="12.04-x86"
export DIST="trusty"
export NAME="ubuntu1404"
TMPL="14.04-x86"
Note: replace "i386" and "x86" to "amd64", if you want to get 64-bit environment.
== Prepare directory ==
apt-get -y install debootstrap
cd /usr/share/debootstrap/scripts && ln -s gutsy trusty && cd -
debootstrap --arch $ARCH $DIST /var/lib/vz/template/$NAME -$ARCH http://$COUNTRY.archive.ubuntu.com/ubuntu chroot /var/lib/vz/template/$NAME-$ARCH
Note: Debootstrap can miss Trusty profile (as in Debian Wheezy), so you should create it manually as seen above.
locale-gen ru_RU.UTF-8
locale-gen en_US.UTF-8
echo 'LANG="en_US.UTF-8"' > /etc/default/locale
Configure packages:
echo $NAME > /etc/mailname
echo '
# dma-0.0.2010.xx syntax
SMARTHOST 192.0.2.2
DBOUNCEPROG dbounce-simple-safecat
:
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends dma bsd-mailx safecat
'''14.04 note:''' config syntax for dma-0.9 was changed:
echo '
# dma-0.9 syntax
SMARTHOST 192.0.2.2
MAILNAME /etc/mailname
' > /etc/dma/dma.conf
Disable hardware-related configs:
:
Cleanup and leave chroot:
apt-get clean
find /var/cache/apt /var/lib/apt/lists -type f -delete
exit
rm -f /var/lib/vz/template/cache/ubuntu-$TMPL.tar.gz &&
tar czf /var/lib/vz/template/cache/ubuntu-$TMPL.tar.gz --numeric-owner -C /var/lib/vz/template/$NAME -$ARCH .
== How to create CT from template ==
ID=123
vzctl create $ID --ostemplate ubuntu-12.04-x86 $TMPL --hostname … --name … --layout simfs
vzctl set $ID --save --onboot yes --nameserver 192.0.2.2 --ipadd 192.0.2.$ID
== First steps after creation ==
Start and enter:
vzctl start $ID
vzctl enter $ID
Install updates:
apt-get update
apt-get -y dist-upgrade