12
edits
Changes
Created page with "* Based on Ubuntu_Trusty_template_creation. * HN: Debian 7 (Wheezy). * Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr). == Setup variables == ARCH="i..."
* Based on [[Ubuntu_Trusty_template_creation]].
* HN: Debian 7 (Wheezy).
* Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr).
== Setup variables ==
ARCH="i386"
export DIST="precise"
export NAME="ubuntu1204"
export COUNTRY="de"
TMPL="12.04-x86"
== Prepare directory ==
apt-get -y install debootstrap
debootstrap --arch $ARCH $DIST /var/lib/vz/template/$NAME http://$COUNTRY.archive.ubuntu.com/ubuntu
chroot /var/lib/vz/template/$NAME
== Steps in chroot ==
Configure locales:
locale-gen ru_RU.UTF-8
locale-gen en_US.UTF-8
Configure packages:
echo "
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST main restricted universe multiverse
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-updates main restricted universe multiverse
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-security main restricted universe multiverse
#eb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-backports main restricted universe multiverse
" > /etc/apt/sources.list
:
dpkg --remove ubuntu-minimal isc-dhcp-client isc-dhcp-common ntpdate resolvconf
dpkg --purge ubuntu-minimal isc-dhcp-client isc-dhcp-common ntpdate resolvconf
:
apt-get update
apt-get -y dist-upgrade
Configure mail system (consider 192.0.2.2 is IP of venet0 on HN, or put here your own SMTP relay if needed):
mkdir /etc/dma
echo $NAME > /etc/mailname
echo '
SMARTHOST 192.0.2.2
DBOUNCEPROG dbounce-simple-safecat
MAILNAMEFILE /etc/mailname
' > /etc/dma/dma.conf
:
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends dma bsd-mailx safecat
Disable hardware-related configs:
sed -i.orig -e 's,^#!.*,#!/bin/true,' /etc/init.d/ondemand
sed -i.orig -e 's,\(.* | \)\(sysctl .*\),\1 /bin/true \2,' /etc/init/procps.conf
sed -i.orig -e 's,^console output,, ; s,^env INIT_VERBOSE,,' /etc/init/rc.conf
sed -i.orig -e 's/^\$ModLoad imklog/## \$ModLoad imklog/g' /etc/rsyslog.conf
sed -i.orig -e 's,^\([^#].*/dev/xconsole\),## \1,' /etc/rsyslog.d/50-default.conf
:
mkdir /root/etc_init_console_tty
mv /etc/init/console* /etc/init/tty* /root/etc_init_console_tty
Cleanup and leave chroot:
find /var/cache/apt /var/lib/apt/lists -type f -delete
apt-get clean
exit
== Create template archive ==
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 .
== How to create CT from template ==
ID=123
vzctl create $ID --ostemplate ubuntu-12.04-x86 --hostname … --name … --layout simfs
vzctl set $ID --save --onboot yes --nameserver 192.0.2.2 --ipadd 192.0.2.$ID
== Trusty notes ==
Debootstrap can miss Trusty profile (as in Debian Wheezy), so create it manually (and adopt DIST,NAME,TMPL):
...
export DIST="trusty"
export NAME="ubuntu1404"
TMPL="14.04-x86"
...
apt-get install -y debootstrap
cd /usr/share/debootstrap/scripts && ln -s gutsy trusty
debootstrap ...
* HN: Debian 7 (Wheezy).
* Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr).
== Setup variables ==
ARCH="i386"
export DIST="precise"
export NAME="ubuntu1204"
export COUNTRY="de"
TMPL="12.04-x86"
== Prepare directory ==
apt-get -y install debootstrap
debootstrap --arch $ARCH $DIST /var/lib/vz/template/$NAME http://$COUNTRY.archive.ubuntu.com/ubuntu
chroot /var/lib/vz/template/$NAME
== Steps in chroot ==
Configure locales:
locale-gen ru_RU.UTF-8
locale-gen en_US.UTF-8
Configure packages:
echo "
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST main restricted universe multiverse
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-updates main restricted universe multiverse
deb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-security main restricted universe multiverse
#eb http://$COUNTRY.archive.ubuntu.com/ubuntu $DIST-backports main restricted universe multiverse
" > /etc/apt/sources.list
:
dpkg --remove ubuntu-minimal isc-dhcp-client isc-dhcp-common ntpdate resolvconf
dpkg --purge ubuntu-minimal isc-dhcp-client isc-dhcp-common ntpdate resolvconf
:
apt-get update
apt-get -y dist-upgrade
Configure mail system (consider 192.0.2.2 is IP of venet0 on HN, or put here your own SMTP relay if needed):
mkdir /etc/dma
echo $NAME > /etc/mailname
echo '
SMARTHOST 192.0.2.2
DBOUNCEPROG dbounce-simple-safecat
MAILNAMEFILE /etc/mailname
' > /etc/dma/dma.conf
:
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends dma bsd-mailx safecat
Disable hardware-related configs:
sed -i.orig -e 's,^#!.*,#!/bin/true,' /etc/init.d/ondemand
sed -i.orig -e 's,\(.* | \)\(sysctl .*\),\1 /bin/true \2,' /etc/init/procps.conf
sed -i.orig -e 's,^console output,, ; s,^env INIT_VERBOSE,,' /etc/init/rc.conf
sed -i.orig -e 's/^\$ModLoad imklog/## \$ModLoad imklog/g' /etc/rsyslog.conf
sed -i.orig -e 's,^\([^#].*/dev/xconsole\),## \1,' /etc/rsyslog.d/50-default.conf
:
mkdir /root/etc_init_console_tty
mv /etc/init/console* /etc/init/tty* /root/etc_init_console_tty
Cleanup and leave chroot:
find /var/cache/apt /var/lib/apt/lists -type f -delete
apt-get clean
exit
== Create template archive ==
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 .
== How to create CT from template ==
ID=123
vzctl create $ID --ostemplate ubuntu-12.04-x86 --hostname … --name … --layout simfs
vzctl set $ID --save --onboot yes --nameserver 192.0.2.2 --ipadd 192.0.2.$ID
== Trusty notes ==
Debootstrap can miss Trusty profile (as in Debian Wheezy), so create it manually (and adopt DIST,NAME,TMPL):
...
export DIST="trusty"
export NAME="ubuntu1404"
TMPL="14.04-x86"
...
apt-get install -y debootstrap
cd /usr/share/debootstrap/scripts && ln -s gutsy trusty
debootstrap ...