Open main menu

OpenVZ Virtuozzo Containers Wiki β

Talk:Archlinux Template creation

Revision as of 05:50, 15 May 2009 by Dschauer (talk | contribs) (Pointed out replacement tool for missing script. Showed script I've used to create templates.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

One can use mkarchroot (provided by devtools) in place of archbootstrap if building the template with Archlinux.

Here is a script I have used to create Archlinux templates:

#!/bin/bash -x

DISTRO=arch
VERSION=das1

PACKS="sed gawk coreutils filesystem texinfo grep pacman logrotate \
module-init-tools wget curl net-tools procps tar cpio zip unzip \
gzip bzip2 lzma-utils psmisc initscripts iputils dnsutils iproute2 \
less dash which openssh joe sudo htop dcron syslog-ng screen \
util-linux-ng"


MIRROR1=http://mirror.umoss.org/archlinux
MIRROR2=http://mirror.rit.edu/archlinux

if [[ ${1} == 64 ]]; then
  ARCH=x86_64
else
  if [[ ${1} == 32 ]]; then
    ARCH=i686
  else
    echo "Usage: ${0} 32|64"
    exit 1
  fi
fi

ROOT=${DISTRO}-${VERSION}-${ARCH}

TEMPLATE=$(pwd)/${ROOT}.tar.gz

if [[ "$(whoami)" == "root" ]]; then
	echo "Building template: ${ROOT}"
else
	echo "This script must be run as root (or with sudo)"
	exit 1
fi

cat <<EOF > pacman.conf
[options]
HoldPkg     = pacman glibc
SyncFirst   = pacman

[core]
Server = ${MIRROR1}/\$repo/os/${ARCH}
Server = ${MIRROR2}/\$repo/os/${ARCH}
Include = /etc/pacman.d/mirrorlist
[extra]
Server = ${MIRROR1}/\$repo/os/${ARCH}
Server = ${MIRROR2}/\$repo/os/${ARCH}
Include = /etc/pacman.d/mirrorlist
[community]
Server = ${MIRROR1}/\$repo/os/${ARCH}
Server = ${MIRROR2}/\$repo/os/${ARCH}
Include = /etc/pacman.d/mirrorlist
EOF

mkarchroot -C pacman.conf ${ROOT} ${PACKS}

chmod 666 ${ROOT}/dev/null
chmod 666 ${ROOT}/dev/zero
mknod -m 666 ${ROOT}/dev/random c 1 8
mknod -m 666 ${ROOT}/dev/urandom c 1 9
mkdir -m 755 ${ROOT}/dev/pts
mkdir -m 1777 ${ROOT}/dev/shm
mknod -m 666 ${ROOT}/dev/tty c 5 0
mknod -m 666 ${ROOT}/dev/full c 1 7
mknod -m 600 ${ROOT}/dev/initctl p
mknod -m 666 ${ROOT}/dev/ptmx c 5 2


# we don't need any getty entries in a container
sed 's/^.*getty.*$//' -i ${ROOT}/etc/inittab

cd ${ROOT}
tar czvf ${TEMPLATE} .

echo "Created template: ${ROOT}"

Sometime I may get around to editing this page.

Return to "Archlinux Template creation" page.