Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Creating a Red Hat Template with mach

1,808 bytes added, 15:12, 27 August 2008
New page: Using the "mach" program you can easily create a minimal template for virtually any Red Hat OS. The following example creates a template for Centos 5.2 i386. # Install mach on the host n...
Using the "mach" program you can easily create a minimal template for virtually any Red Hat OS. The following example creates a template for Centos 5.2 i386.

# Install mach on the host node or your build server
#: yum install mach
# Edit /etc/mach/conf to use the OS version / architecture you want
# Setup the chroot
#: mach setup base
# Setup any additional packages you want in the chroot
#: mach yum install yum
edit /etc/mach/conf to use the centos i386 extras template
run mach setup base
mach yum install yum vim-minimal passwd ssh-clients openssh-server
# Run the script below in the chroot directory (/var/lib/mach/roots/template-name)
# Package the template into /vz/template/cache
#: cd /var/lib/mach/roots/template-name
#: tar czf /vz/template/cache/template-name.tar.gz .
# At this point I create a "template" VE and do any other additional configuration inside the running VE, verify that it works, etc. Then I repackage it again.

''Script to turn mach chroot into vz template:''

Run these commands from /var/lib/mach/root/template. Replace the ROOT_PWD_HASH with your root password hash with your own hash if you want to set the password for the template. (otherwise, you can vzctl enter VEID and change the password).

<pre>
OS=$(basename $(pwd))
alias rm=rm
sed -i -e /getty/d etc/inittab
sed -i -e /sbin\\/start_udev/d etc/rc.sysinit
sed -i -e 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' etc/ssh/sshd_config
#sed -i -e "s/root:.:/root:ROOT_PWD_HASH:/g" etc/passwd
echo "PS1='[\u@\h \W]\$'" >> /etc/profile
rm etc/mtab
ln -s /proc/mounts etc/mtab
mknod dev/ptmx c 5 2
mkdir dev/pts
/sbin/MAKEDEV -d dev ttyp ptyp
mknod dev/null c 1 3
mknod dev/urandom c 1 9
mknod dev/tty c 5 0
mkdir -p var/lock/rpm
ln -s /etc/init.d /s
mkdir -p /var/lib/mach/roots/$OS/var/lib/yum/
</pre>
2
edits