Difference between revisions of "Creating a Red Hat Template with mach"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(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...)
 
 
Line 1: Line 1:
 +
[[Category: HOWTO]]
 +
[[Category: Templates]]
 +
{{wikify}}
 +
 
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.  
 
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.  
  
Line 7: Line 11:
 
#: mach setup base
 
#: mach setup base
 
# Setup any additional packages you want in the chroot
 
# Setup any additional packages you want in the chroot
#: mach yum install yum
+
#: mach yum install yum vim-minimal passwd ssh-clients openssh-server
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)
 
# Run the script below in the chroot directory (/var/lib/mach/roots/template-name)
 
# Package the template into /vz/template/cache
 
# Package the template into /vz/template/cache
Line 17: Line 18:
 
# 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.  
 
# 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:''
+
'''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).  
 
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).  

Latest revision as of 15:14, 27 August 2008

Yellowpin.svg Note: this article is not formatted according to this Wiki standards. Please help reformatting it in a better way.

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.

  1. Install mach on the host node or your build server
    yum install mach
  2. Edit /etc/mach/conf to use the OS version / architecture you want
  3. Setup the chroot
    mach setup base
  4. Setup any additional packages you want in the chroot
    mach yum install yum vim-minimal passwd ssh-clients openssh-server
  5. Run the script below in the chroot directory (/var/lib/mach/roots/template-name)
  6. Package the template into /vz/template/cache
    cd /var/lib/mach/roots/template-name
    tar czf /vz/template/cache/template-name.tar.gz .
  7. 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).

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/