Changes

Jump to: navigation, search

Archlinux Template creation

2,291 bytes added, 04:44, 21 February 2013
Added updated script and notice re: outdated instructions
Instructions manually create a minimal Archlinux (0.8) "Voodoo" OS TemplateScript & archived instructions for creating an Arch container.
== Script == Script for creating a minimal Arch Linux template adapted from the script in [[Talk:Archlinux_Template_creation|Disussion]].<pre>#!/bin/bash -x DISTRO=archVERSION=2013 # set up base system plus:# syslinux (necessary? i don't think it is...)# vim (because nano is lame)# openssh# ...any other package from standard Arch repos...PACKS="base base-devel syslinux openssh vim" MIRROR1=http://mirror.umoss.org/archlinuxMIRROR2=http://mirror.rit.edu/archlinux if [[ ${1} == 64 ]]; then ARCH=x86_64else if [[ ${1} == 32 ]]; then ARCH=i686 else echo "Usage: ${0} 32|64" exit 1 fifi 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 1fi cat <<EOF > pacman.conf[options]HoldPkg = pacman glibcSyncFirst = pacmanArchitecture = ${ARCH} [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/mirrorlistEOF mkarchroot -C pacman.conf ${ROOT} ${PACKS} if [[ $? -ne 0 ]]; then echo "Build failed". exit 1fi chmod 666 ${ROOT}/dev/nullchmod 666 ${ROOT}/dev/zeromknod -m 666 ${ROOT}/dev/random c 1 8mknod -m 666 ${ROOT}/dev/urandom c 1 9mkdir -m 755 ${ROOT}/dev/ptsmkdir -m 1777 ${ROOT}/dev/shmmknod -m 666 ${ROOT}/dev/tty c 5 0mknod -m 666 ${ROOT}/dev/full c 1 7mknod -m 600 ${ROOT}/dev/initctl pmknod -m 666 ${ROOT}/dev/ptmx c 5 2  # we don't need any getty entries in a containersed 's/^.*getty.*$//' -i ${ROOT}/etc/inittab cd ${ROOT}tar czvf ${TEMPLATE} . echo "Created template: ${ROOT}"</pre> == Manual Instructions == The instructions below are informative but out of date and likely '''will not''' work with an Arch system built after 2011. === Prerequisites ===
I used a modified archbootstrap script which can be found at http://forzza.systs.org/openvz-misc/
{{Note | This link is currently broken}}
{{Note | One can use mkarchroot (provided by devtools) in place of archbootstrap if building the template on Archlinux. See [[Talk:Archlinux_Template_creation|Disussion]] for a bash script to do this. The script makes it easy to build an image on an arch machine, then copy the zipped template over to your VZ host.}} 
Edit settings of script "archbootstrap" :
|}
=== bootstrapping Archlinux ===
Syntax:
{{Note|Please use mirrors! A full list of Archlinux mirrors: http://wiki.archlinux.org/index.php/Mirror}}
=== enter the Build with chroot ===
All the commands below are executed from the root shell. I this howto "chroot" is used to enter as NEWROOT, a BUILD-VE must not be created!
CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/
==== setting DNS server ====
For the chroot BUILD we also need to specify a DNS for it:
BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf
==== update and install packages ====
Update (sync) pacman cache and update installed packages
BUILD_# pacman -S openssh quota-tools iproute
==== fix /etc/mtab ====
Add symlink /proc/mount /etc/mtab
BUILD_# ln -s /proc/mounts /etc/mtab
==== fix /etc/inittab ====
Remove getty lines from inittab:
BUILD_# sed -i -e '/getty/d' /etc/inittab
==== create device nodes ====
Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl
BUILD_# mknod -m 666 /dev/zero c 1 5
==== sysinit script modification ====
Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts
[...]
==== modify the main configuration file ====
BUILD_# nano /etc/rc.conf
DAEMONS=(syslog-ng network netfs crond ssh)
==== enable ssh connections ====
{{Note|All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap}}
BUILD_# echo "ssh: ALL : ALLOW" >> /etc/hosts.allow
==== lock (disable) the root account ====
BUILD_# passwd -l root
==== exit the chroot to CT0 ====
BUILD_# exit
=== build a exclude list ===
Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE
CT0_# find ./root/.bash_history >> ../exclude.list-$ARCH
=== create OS template ===
CT0_# tar --numeric-owner -X ../exclude.list-$ARCH -czf /vz/template/cache/arch-0.8-$ARCH-minimal.tar.gz ./
=== use the OS template ===
CT0_# vzctl create <VEID> --ostemplate arch-0.8-$ARCH-minimal ...
=== update the OS template ===
To update a template is really easy, enter the build with chroot, performing upgrade task
Update the exclude list, and pack upgraded OS - Template
=== Links ===
* [http://wiki.archlinux.org/index.php/Main_Page Archlinux wikiArch Linux Wiki]
[[Category: HOWTO]]
[[Category: Templates]]
Anonymous user

Navigation menu