Editing Creating a CentOS 5.0 Template

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 4: Line 4:
  
 
# Install a system (virtual or physical) with the default CentOS installation that you wish to package. This could be a minimal distro or the default distro or even something custom.
 
# Install a system (virtual or physical) with the default CentOS installation that you wish to package. This could be a minimal distro or the default distro or even something custom.
## It's generally quicker to bootstrap a CentOS system on another yum/rpm-based, or Debian based system by following the instructions in [http://faiwiki.informatik.uni-koeln.de/index.php/FAI_multi-distribution#bootstrapping_the_base_images__for_other_distributions]
 
 
# Once the OS has been installed, you need to '''tar''' the contents of the OS.
 
# Once the OS has been installed, you need to '''tar''' the contents of the OS.
 
## First, create a file called '''/tmp/exclude''' and add the following lines to it:
 
## First, create a file called '''/tmp/exclude''' and add the following lines to it:
Line 15: Line 14:
 
#:  /sys/*
 
#:  /sys/*
 
#:  /usr/src/*
 
#:  /usr/src/*
## Now, tar the OS file up by typing: '''tar --numeric-owner -czvf /tmp/centos-5.0-<ARCH>-<DISTRO>-image.tar.gz -X /tmp/exclude /''' where <'''ARCH'''> represents the system architecture ('''i386''' or  
+
## Now, tar the OS file up by typing: '''tar –czvf /tmp/centos-5.0-<ARCH>-<DISTRO>-image.tar.gz / –X #: /tmp/exclude''' where <'''ARCH'''> represents the system architecture ('''i386''' or  
 
#: '''x86_64''') and <'''DISTRO'''> represents the distribution (default, minimal, etc.).
 
#: '''x86_64''') and <'''DISTRO'''> represents the distribution (default, minimal, etc.).
 
## Now transfer the file over to the OpenVZ server into '''/vz/template/cache''' folder.
 
## Now transfer the file over to the OpenVZ server into '''/vz/template/cache''' folder.
Line 21: Line 20:
 
#: and copying the '''/etc/vz/conf/ve-vps.basic.conf-sample''' to '''/etc/vz/conf/50.conf'''.
 
#: and copying the '''/etc/vz/conf/ve-vps.basic.conf-sample''' to '''/etc/vz/conf/50.conf'''.
 
#: '''NOTE''': 50 is the CTID for the container. You can choose any unused CTID on the OpenVZ server.
 
#: '''NOTE''': 50 is the CTID for the container. You can choose any unused CTID on the OpenVZ server.
# Now create a new folder called '''/vz/template/centos/5/<ARCH>/config''' again where  
+
# Now create a new folder called '''/vz/template/centos/5.0/<ARCH>/config''' again where  
 
#: <'''ARCH'''> represents the system architecture.
 
#: <'''ARCH'''> represents the system architecture.
 
# Create a file in the folder called rpm and add the following line:
 
# Create a file in the folder called rpm and add the following line:
Line 28: Line 27:
 
#:  [main]
 
#:  [main]
 
#:   
 
#:   
#:  cachedir=/vz/template/centos/5/<ARCH>/yum-cache/
+
#:  cachedir=/vz/template/centos/5.0/<ARCH>/yum-cache/
 
#:   
 
#:   
 
#:  reposdir=/dev/null
 
#:  reposdir=/dev/null
Line 52: Line 51:
 
#:   
 
#:   
 
#:  gpgcheck=1
 
#:  gpgcheck=1
# Copy '''/etc/vz/dists/centos-4.conf''' to '''/etc/vz/dists/centos-5.conf'''.
+
# Copy '''/etc/vz/dists/centos-4.conf''' to '''/etc/vz/dists/centos-5.0.conf'''.
# Copy '''/vz/template/centos/4/i386/config/minimal.list''' to ''' /vz/template/centos/5/i386/config/minimal.list'''.  
+
# Change to the '''/vz/private/50''' folder and then run the command '''gunzip –dc /vz/template/cache/centos-5.0-<ARCH>-<DISTRO>-image.tar.gz | tar –xvf''' to unpack the base image to the folder.
# Change to the '''/vz/private/50''' folder and then run the command '''gunzip –dc /vz/template/cache/centos-5-<ARCH>-<DISTRO>-image.tar.gz | tar –xvf ''' to unpack the base image to the folder.
 
 
# Make sure you are in the '''/vz/private/50''' folder.
 
# Make sure you are in the '''/vz/private/50''' folder.
 
# Edit '''etc/shadow''' and remove the replace the '''root''' password with !! instead of the hashed value.
 
# Edit '''etc/shadow''' and remove the replace the '''root''' password with !! instead of the hashed value.
 
# Edit the '''etc/inittab''' file and comment out the lines that respawn '''/sbin/mingetty''' on '''tty1''' through '''tty6'''. Just put a # at the beginning of the line.
 
# Edit the '''etc/inittab''' file and comment out the lines that respawn '''/sbin/mingetty''' on '''tty1''' through '''tty6'''. Just put a # at the beginning of the line.
# Remove the '''etc/mtab''' file and then create a symbolic link by typing '''ln -s /proc/mounts etc/mtab'''.
+
# Remove the '''etc/mtab''' file and then create a symbolic link by typing '''ln –s /proc/mounts etc/mtab'''.
 
# Remove all of the lines from '''etc/fstab''' except for the line that mounts '''/dev/pts'''.
 
# Remove all of the lines from '''etc/fstab''' except for the line that mounts '''/dev/pts'''.
 
# Edit '''etc/rc.d/rc.sysinit''' and comment out the line that starts '''/sbin/start_udev''' by placing a # at the beginning of the line.
 
# Edit '''etc/rc.d/rc.sysinit''' and comment out the line that starts '''/sbin/start_udev''' by placing a # at the beginning of the line.
Line 64: Line 62:
 
#:  mknod dev/ptmx c 5 2
 
#:  mknod dev/ptmx c 5 2
 
#:  mkdir dev/pts
 
#:  mkdir dev/pts
#:  /sbin/MAKEDEV –d/vz/private/50/dev ttyp ptyp
+
#:  /sbin/MAKEDEV –d /vz/private/50/dev ttyp ptyp
 
#:  mknod dev/null c 1 3
 
#:  mknod dev/null c 1 3
#:  mknod -m 644 dev/random c 1 8
 
 
#:  mknod dev/urandom c 1 9
 
#:  mknod dev/urandom c 1 9
 
# Create the '''var/lock/rpm''' folder.
 
# Create the '''var/lock/rpm''' folder.
Line 75: Line 72:
 
#:  blacklist net-pf-10
 
#:  blacklist net-pf-10
 
# Disable any physical NICs by modifying the '''etc/sysconfig/network-scripts/ifcfg-ethX''' files (where '''X''' is the interface number starting from '''0''') and setting '''ONBOOT''' to '''no'''.
 
# Disable any physical NICs by modifying the '''etc/sysconfig/network-scripts/ifcfg-ethX''' files (where '''X''' is the interface number starting from '''0''') and setting '''ONBOOT''' to '''no'''.
# Check etc/sysconfig/init to see if PROMPT=yes, and then change to no. Otherwise when startup init script rc will enter interactive mode and wait there forever
 
 
 
# Now you’re ready to start the template. Type '''vzctl start 50''' and wait for it to start.
 
# Now you’re ready to start the template. Type '''vzctl start 50''' and wait for it to start.
 
# You can install additional packages into the container by typing '''vzyum 50 install <package>''' at the prompt where <'''package'''> represents the name of the software package you wish to install.
 
# You can install additional packages into the container by typing '''vzyum 50 install <package>''' at the prompt where <'''package'''> represents the name of the software package you wish to install.
Line 86: Line 81:
 
# Exit the container by typing '''exit''' at the prompt.
 
# Exit the container by typing '''exit''' at the prompt.
 
# Stop the container by typing '''vzctl stop 50'''.
 
# Stop the container by typing '''vzctl stop 50'''.
# Make sure you are in the '''/vz/private/50''' folder.
+
# Finally, package up the new template by typing '''tar –czvf /vz/template/cache/centos-5.0-<ARCH>-<DISTRO>.tar.gz'''.
# Finally, package up the new template by typing '''tar –czvf /vz/template/cache/centos-5-<ARCH>-<DISTRO>.tar.gz ./'''.
 
 
# The template is ready for use.
 
# The template is ready for use.

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)

Templates used on this page: