Difference between revisions of "Ubuntu Precise template creation"
Ilya Evseev (talk | contribs) (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...") |
Ilya Evseev (talk | contribs) m (Trusty details moved from bottom to head.) |
||
Line 3: | Line 3: | ||
* Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr). | * Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr). | ||
− | == Setup variables == | + | == Setup variables for 12.04 (Precise Pangolin) == |
ARCH="i386" | ARCH="i386" | ||
Line 10: | Line 10: | ||
export COUNTRY="de" | export COUNTRY="de" | ||
TMPL="12.04-x86" | TMPL="12.04-x86" | ||
+ | |||
+ | == Setup variables for 14.04 (Trusty Tahr) == | ||
+ | |||
+ | ARCH="i386" | ||
+ | export DIST="trusty" | ||
+ | export NAME="ubuntu1404" | ||
+ | export COUNTRY="de" | ||
+ | TMPL="14.04-x86" | ||
== Prepare directory == | == Prepare directory == | ||
apt-get -y install debootstrap | apt-get -y install debootstrap | ||
+ | cd /usr/share/debootstrap/scripts && ln -s gutsy trusty && cd - | ||
debootstrap --arch $ARCH $DIST /var/lib/vz/template/$NAME http://$COUNTRY.archive.ubuntu.com/ubuntu | debootstrap --arch $ARCH $DIST /var/lib/vz/template/$NAME http://$COUNTRY.archive.ubuntu.com/ubuntu | ||
chroot /var/lib/vz/template/$NAME | chroot /var/lib/vz/template/$NAME | ||
+ | |||
+ | Note: Debootstrap can miss Trusty profile (as in Debian Wheezy), so you should create it manually as seen above. | ||
== Steps in chroot == | == Steps in chroot == | ||
Line 73: | Line 84: | ||
vzctl create $ID --ostemplate ubuntu-12.04-x86 --hostname … --name … --layout simfs | 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 | vzctl set $ID --save --onboot yes --nameserver 192.0.2.2 --ipadd 192.0.2.$ID | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 15:09, 22 July 2014
- Based on Ubuntu_Trusty_template_creation.
- HN: Debian 7 (Wheezy).
- Templates: Ubuntu 12.04 (Precise Pangolin) and 14.04 (Trusty Tahr).
Contents
Setup variables for 12.04 (Precise Pangolin)
ARCH="i386" export DIST="precise" export NAME="ubuntu1204" export COUNTRY="de" TMPL="12.04-x86"
Setup variables for 14.04 (Trusty Tahr)
ARCH="i386" export DIST="trusty" export NAME="ubuntu1404" export COUNTRY="de" TMPL="14.04-x86"
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 http://$COUNTRY.archive.ubuntu.com/ubuntu chroot /var/lib/vz/template/$NAME
Note: Debootstrap can miss Trusty profile (as in Debian Wheezy), so you should create it manually as seen above.
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