Difference between revisions of "Creating a CentOS 5.0 Template"
Josh.hogle (talk | contribs) |
(cagegorized, added {{wikify}}, removed some crap) |
||
Line 1: | Line 1: | ||
− | + | [[Category: HOWTO]] | |
+ | [[Category: Templates]] | ||
+ | {{wikify}} | ||
<ol style='margin-top:0in' start=1 type=1> | <ol style='margin-top:0in' start=1 type=1> | ||
Line 5: | Line 7: | ||
style='font-size:10.0pt;font-family:Tahoma'>Install a system (virtual or | style='font-size:10.0pt;font-family:Tahoma'>Install a system (virtual or | ||
physical) with the default <span class=SpellE>CentOS</span> installation | physical) with the default <span class=SpellE>CentOS</span> installation | ||
− | that you wish to package.<span style='mso-spacerun:yes'> | + | that you wish to package.<span style='mso-spacerun:yes'> </span>This |
could be a minimal <span class=SpellE>distro</span> or the default <span | could be a minimal <span class=SpellE>distro</span> or the default <span | ||
class=SpellE>distro</span> or even something custom.</span></li> | class=SpellE>distro</span> or even something custom.</span></li> | ||
Line 65: | Line 67: | ||
font-family:"Courier New"'>tar –<span class=SpellE>czvf</span> | font-family:"Courier New"'>tar –<span class=SpellE>czvf</span> | ||
/tmp/centos-5.0-<ARCH>-<DISTRO>-<span class=SpellE>image.tar.gz</span> | /tmp/centos-5.0-<ARCH>-<DISTRO>-<span class=SpellE>image.tar.gz</span> | ||
− | / –X<span style='mso-spacerun:yes'> | + | / –X<span style='mso-spacerun:yes'> </span>/<span class=SpellE>tmp</span>/exclude</span></p> |
<p class=MsoNormal style='margin-left:.75in;text-indent:-.25in'><span | <p class=MsoNormal style='margin-left:.75in;text-indent:-.25in'><span | ||
style='font-size:10.0pt;font-family:"Courier New"'><span style='mso-tab-count: | style='font-size:10.0pt;font-family:"Courier New"'><span style='mso-tab-count: | ||
− | 2'> | + | 2'> </span></span></p> |
<p class=MsoNormal style='margin-left:1.0in'><span style='font-size:10.0pt; | <p class=MsoNormal style='margin-left:1.0in'><span style='font-size:10.0pt; | ||
Line 102: | Line 104: | ||
normal'><span style='font-size:8.0pt;font-family:Tahoma;color:red'>50</span></b><span | normal'><span style='font-size:8.0pt;font-family:Tahoma;color:red'>50</span></b><span | ||
style='font-size:8.0pt;font-family:Tahoma;color:red'> is the VEID for the | style='font-size:8.0pt;font-family:Tahoma;color:red'> is the VEID for the | ||
− | VPS.<span style='mso-spacerun:yes'> | + | VPS.<span style='mso-spacerun:yes'> </span>You can choose any unused VEID on |
the <span class=SpellE>OpenVZ</span> server.</span></p> | the <span class=SpellE>OpenVZ</span> server.</span></p> | ||
Line 225: | Line 227: | ||
normal'>/<span class=SpellE>sbin/mingetty</span></b> on <b | normal'>/<span class=SpellE>sbin/mingetty</span></b> on <b | ||
style='mso-bidi-font-weight:normal'>tty1</b> through <b style='mso-bidi-font-weight: | style='mso-bidi-font-weight:normal'>tty1</b> through <b style='mso-bidi-font-weight: | ||
− | normal'>tty6</b>.<span style='mso-spacerun:yes'> | + | normal'>tty6</b>.<span style='mso-spacerun:yes'> </span>Just put a <b |
style='mso-bidi-font-weight:normal'>#</b> at the beginning of the line.</span></li> | style='mso-bidi-font-weight:normal'>#</b> at the beginning of the line.</span></li> | ||
<li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'><span | <li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'><span | ||
Line 321: | Line 323: | ||
<li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'><span | <li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'><span | ||
style='font-size:10.0pt;font-family:Tahoma'>Now you’re ready to start the | style='font-size:10.0pt;font-family:Tahoma'>Now you’re ready to start the | ||
− | template.<span style='mso-spacerun:yes'> | + | template.<span style='mso-spacerun:yes'> </span>Type </span><span |
class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>vzctl</span></span><span | class=SpellE><span style='font-size:10.0pt;font-family:"Courier New"'>vzctl</span></span><span | ||
style='font-size:10.0pt;font-family:"Courier New"'> start 50</span><span | style='font-size:10.0pt;font-family:"Courier New"'> start 50</span><span | ||
Line 383: | Line 385: | ||
style='font-size:10.0pt;font-family:Tahoma'>The template is ready for use.</span></li> | style='font-size:10.0pt;font-family:Tahoma'>The template is ready for use.</span></li> | ||
</ol> | </ol> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 10:57, 13 November 2007
Note: this article is not formatted according to this Wiki standards. Please help reformatting it in a better way. |
- 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.
- 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:
.bash_history
lost+found
/dev/*
/mnt/*
/tmp/*
/proc/*
/sys/*
/usr/src/*
- 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.).
- Now transfer the file over to the OpenVZ server into /vz/template/cache folder.
- On the OpenVZ server create a “dummy” VPS by creating a folder called /vz/private/50 and copying the /etc/vz/conf/ve-vps.basic.conf-sample to /etc/vz/conf/50.conf.
NOTE:
50 is the VEID for the VPS. You can choose any unused VEID on the OpenVZ server.
- Now create a new folder called /vz/template/centos/5.0/<ARCH>/config again where <ARCH> represents the system architecture.
- Create a file in the folder called rpm and add the following line:
43
- Create a file called yum.conf in the folder and add the following lines:
[main]
cachedir=/vz/template/centos/5.0/<ARCH>/yum-cache/
reposdir=/dev/null
installonlypkgs=
[centos5-base]
name=CentOS 5 - <ARCH> - Base
baseurl=http://mirror.centos.org/centos/5/os/<ARCH>/
enabled=1
gpgcheck=1
[centos5-updates-released]
name=CentOS 5 - <ARCH> - Released Updates
baseurl=http://mirror.centos.org/centos/5/updates/<ARCH>/
enabled=1
gpgcheck=1
- Copy /etc/vz/dists/centos-4.conf to /etc/vz/dists/centos-5.0.conf.
- 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.
- 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 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 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.
- Now create device nodes by typing:
mknod dev/ptmx c 5 2
mkdir dev/pts
/sbin/MAKEDEV –d /vz/private/50/dev ttyp ptyp
mknod dev/null c 1 3
mknod dev/urandom c 1 9
- Create the var/lock/rpm folder.
- If you wish to disable IPv6, do the following:
- Edit etc/sysconfig/network and set NETWORKING_IPV6 to no.
- Add the following lines to etc/modprobe.d/blacklist:
blacklist ipv6
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.
- 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 VPS by typing vzyum 50 install <package> at the prompt where <package> represents the name of the software package you wish to install.
- Finally, you should turn off unnecessary services.
- Enter the VPS by typing vzctl enter 50.
- View the services that are set to run at startup by typing chkconfig --list | grep 5:on.
- Disable any unwanted service by typing chkconfig --levels 2345 <service> off where <service> represents the service to disable.
Services that you can (and should) turn off without harm are acpid, apmd, kudzu, and microcode_ctl.
- Exit the VPS by typing exit at the prompt.
- Stop the VPS by typing vzctl stop 50.
- Finally, package up the new template by typing tar –czvf /vz/template/cache/centos-5.0-<ARCH>-<DISTRO>.tar.gz .
- The template is ready for use.