Editing Archlinux Template creation

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
Script & archived instructions for creating an Arch container.
+
Instructions manually create a minimal Archlinux (0.8) "Voodoo" OS Template.
  
== Script ==
+
== Prerequisites ==
 
 
Script for creating a minimal Arch Linux template adapted from the script in [[Talk:Archlinux_Template_creation|Disussion]].
 
<pre>#!/bin/bash -x
 
 
 
DISTRO=arch
 
VERSION=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/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
 
Architecture = ${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/mirrorlist
 
EOF
 
 
 
mkarchroot -C pacman.conf ${ROOT} ${PACKS}
 
 
 
if [[ $? -ne 0 ]]; then
 
    echo "Build failed".
 
    exit 1
 
fi
 
 
 
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}"</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/
 
I used a modified archbootstrap script which can be found at http://forzza.systs.org/openvz-misc/
Line 121: Line 30:
 
|}
 
|}
  
=== bootstrapping Archlinux ===
+
== bootstrapping Archlinux ==
  
 
Syntax:
 
Syntax:
Line 129: Line 38:
 
{{Note|Please use mirrors! A full list of Archlinux mirrors: http://wiki.archlinux.org/index.php/Mirror}}
 
{{Note|Please use mirrors! A full list of Archlinux mirrors: http://wiki.archlinux.org/index.php/Mirror}}
  
=== enter the Build with chroot ===
+
== 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!
 
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!
Line 135: Line 44:
 
  CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/
 
  CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/
  
==== setting DNS server ====
+
=== setting DNS server ===
  
 
For the chroot BUILD we also need to specify a DNS for it:
 
For the chroot BUILD we also need to specify a DNS for it:
Line 141: Line 50:
 
  BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf
 
  BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf
  
==== update and install packages ====
+
=== update and install packages ===
  
 
Update (sync) pacman cache and update installed packages
 
Update (sync) pacman cache and update installed packages
Line 151: Line 60:
 
  BUILD_# pacman -S openssh quota-tools iproute
 
  BUILD_# pacman -S openssh quota-tools iproute
  
==== fix /etc/mtab ====
+
=== fix /etc/mtab ===
  
 
Add symlink /proc/mount /etc/mtab
 
Add symlink /proc/mount /etc/mtab
Line 157: Line 66:
 
  BUILD_# ln -s /proc/mounts /etc/mtab
 
  BUILD_# ln -s /proc/mounts /etc/mtab
  
==== fix /etc/inittab ====
+
=== fix /etc/inittab ===
  
 
Remove getty lines from inittab:
 
Remove getty lines from inittab:
Line 163: Line 72:
 
  BUILD_# sed -i -e '/getty/d' /etc/inittab
 
  BUILD_# sed -i -e '/getty/d' /etc/inittab
  
==== create device nodes ====
+
=== create device nodes ===
  
 
Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl
 
Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl
Line 178: Line 87:
 
  BUILD_# mknod -m 666 /dev/zero c 1 5
 
  BUILD_# mknod -m 666 /dev/zero c 1 5
  
==== sysinit script modification ====
+
=== sysinit script modification ===
  
 
Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts
 
Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts
Line 195: Line 104:
 
  [...]
 
  [...]
  
==== modify the main configuration file ====
+
=== modify the main configuration file ===
  
 
  BUILD_# nano /etc/rc.conf
 
  BUILD_# nano /etc/rc.conf
Line 219: Line 128:
 
  DAEMONS=(syslog-ng network netfs crond ssh)
 
  DAEMONS=(syslog-ng network netfs crond ssh)
  
==== enable ssh connections ====
+
=== enable ssh connections ===
  
 
{{Note|All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap}}
 
{{Note|All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap}}
Line 227: Line 136:
 
  BUILD_# echo "ssh: ALL : ALLOW" >> /etc/hosts.allow
 
  BUILD_# echo "ssh: ALL : ALLOW" >> /etc/hosts.allow
  
==== lock (disable) the root account ====
+
=== lock (disable) the root account ===
  
 
  BUILD_# passwd -l root
 
  BUILD_# passwd -l root
  
==== exit the chroot to CT0 ====
+
=== exit the chroot to CT0 ===
  
 
  BUILD_# exit
 
  BUILD_# exit
  
=== build a exclude list ===
+
== build a exclude list ==
  
 
Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE
 
Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE
Line 256: Line 165:
 
  CT0_# find ./root/.bash_history >> ../exclude.list-$ARCH
 
  CT0_# find ./root/.bash_history >> ../exclude.list-$ARCH
  
=== create OS template ===
+
== create OS template ==
  
 
  CT0_# tar --numeric-owner -X ../exclude.list-$ARCH -czf /vz/template/cache/arch-0.8-$ARCH-minimal.tar.gz ./
 
  CT0_# tar --numeric-owner -X ../exclude.list-$ARCH -czf /vz/template/cache/arch-0.8-$ARCH-minimal.tar.gz ./
  
=== use the OS template ===
+
== use the OS template ==
  
 
  CT0_# vzctl create <VEID> --ostemplate arch-0.8-$ARCH-minimal ...
 
  CT0_# vzctl create <VEID> --ostemplate arch-0.8-$ARCH-minimal ...
  
=== update the OS template ===
+
== update the OS template ==
  
 
To update a template is really easy, enter the build with chroot, performing upgrade task
 
To update a template is really easy, enter the build with chroot, performing upgrade task
Line 272: Line 181:
 
Update the exclude list, and pack upgraded OS - Template
 
Update the exclude list, and pack upgraded OS - Template
  
=== Links ===
+
== Links ==
  
* [http://wiki.archlinux.org/index.php/Main_Page Arch Linux Wiki]
+
* [http://wiki.archlinux.org/index.php/Main_Page Archlinux wiki]
  
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]
 
[[Category: Templates]]
 
[[Category: Templates]]

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: