Difference between revisions of "Centos Upgrade 4.x to 5.x"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(fixed typos + improved remove db part)
(formatted 17 steps)
Line 6: Line 6:
 
follow these steps:
 
follow these steps:
  
1 - Create a container using centos-4-i386-minimal and set a valid nameserver  
+
==Create a container using centos-4-i386-minimal and set a valid nameserver==
 
<pre>
 
<pre>
 
vzctl create CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
 
vzctl create CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
 
vzctl set CTID --nameserver NAMESERVER_IP --save
 
vzctl set CTID --nameserver NAMESERVER_IP --save
 
</pre>
 
</pre>
2 - Enter in container
+
 
 +
==Enter in container==
 
<pre>
 
<pre>
 
vzctl enter CTID
 
vzctl enter CTID
 
</pre>
 
</pre>
3 - Install centos-5-release packages
+
 
 +
==Install centos-5-release packages==
 
<pre>
 
<pre>
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm
Line 22: Line 24:
 
Note: centos-release-5 depends on notes-package, start with that one.
 
Note: centos-release-5 depends on notes-package, start with that one.
  
4 - Backup your /dev/, since initscripts need udev and will remove vzdev you'll net the backup
+
==Backup your /dev/, since initscripts need udev and will remove vzdev you'll net the backup==
 
<pre>
 
<pre>
 
tar -cf dev.tar ./dev
 
tar -cf dev.tar ./dev
 
</pre>
 
</pre>
5 - Install initscripts package (forced and with no deps)
+
 
 +
==Install initscripts package (forced and with no deps)==
 
<pre>
 
<pre>
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.30-2.el5.centos.i386.rpm --force --nodeps
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.30-2.el5.centos.i386.rpm --force --nodeps
 
</pre>
 
</pre>
6 - Exit from container
+
 
 +
==Exit from container==
 
<pre>
 
<pre>
 
exit
 
exit
 
</pre>
 
</pre>
7 - In /etc/vz/conf/CSID.conf replace
+
 
 +
==In /etc/vz/conf/CSID.conf replace==
 
<pre>
 
<pre>
 
OSTEMPLATE="centos-4-i386-minimal"
 
OSTEMPLATE="centos-4-i386-minimal"
Line 42: Line 47:
 
OSTEMPLATE="centos-5-i386-minimal"
 
OSTEMPLATE="centos-5-i386-minimal"
 
</pre>
 
</pre>
8 - Copy existing template from
+
 
 +
==Copy existing template from==
 
<pre>
 
<pre>
 
/vz/template/centos/4
 
/vz/template/centos/4
Line 50: Line 56:
 
/vz/template/centos/5
 
/vz/template/centos/5
 
</pre>
 
</pre>
9 - In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5
 
  
10 - Upgrade container packages using vzyum (32bit only)
+
==In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5==
 +
 
 +
==Upgrade container packages using vzyum (32bit only)==
 
<pre>
 
<pre>
 
vzyum CTID upgrade
 
vzyum CTID upgrade
Line 58: Line 65:
 
Note: If yum db-version complains do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting db.
 
Note: If yum db-version complains do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting db.
  
11 - Stop your VE
+
==Stop your VE==
 
<pre>
 
<pre>
 
vzctl stop CTID
 
vzctl stop CTID
 
</pre>
 
</pre>
12 - Replace the new /dev/ with the old one
+
 
 +
==Replace the new /dev/ with the old one==
 
<pre>
 
<pre>
 
cd /vz/private/CTID
 
cd /vz/private/CTID
Line 68: Line 76:
 
tar -xvf dev.tar
 
tar -xvf dev.tar
 
</pre>
 
</pre>
13 - Leave the container private dir (or it will not start)
+
 
 +
==Leave the container private dir (or it will not start)==
 
<pre>
 
<pre>
 
cd
 
cd
 
</pre>
 
</pre>
14 - Start the container
+
 
 +
==Start the container==
 
<pre>
 
<pre>
 
vzctl start CTID
 
vzctl start CTID
 
</pre>
 
</pre>
15 - Remove container IP
+
 
 +
==Remove container IP==
 
<pre>
 
<pre>
 
vzctl set --ipdel container_IP
 
vzctl set --ipdel container_IP
 
</pre>
 
</pre>
16 - Stop container
+
 
 +
==Stop container==
 
<pre>
 
<pre>
 
vzctl stop CTID
 
vzctl stop CTID
 
</pre>
 
</pre>
17 - Create the template
+
 
 +
==Create the template==
 
<pre>
 
<pre>
 
cd /vz/private/CTID
 
cd /vz/private/CTID
 
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
 
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
 
</pre>
 
</pre>

Revision as of 13:53, 28 May 2011

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

To create a CentOS 5 minimal template from centos-4-i386-minimal, follow these steps:

Create a container using centos-4-i386-minimal and set a valid nameserver

vzctl create CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
vzctl set CTID --nameserver NAMESERVER_IP --save

Enter in container

vzctl enter CTID

Install centos-5-release packages

rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-5.el5.centos.i386.rpm

Note: centos-release-5 depends on notes-package, start with that one.

Backup your /dev/, since initscripts need udev and will remove vzdev you'll net the backup

tar -cf dev.tar ./dev

Install initscripts package (forced and with no deps)

rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.30-2.el5.centos.i386.rpm --force --nodeps

Exit from container

exit

In /etc/vz/conf/CSID.conf replace

OSTEMPLATE="centos-4-i386-minimal"

to

OSTEMPLATE="centos-5-i386-minimal"

Copy existing template from

/vz/template/centos/4

to

/vz/template/centos/5

In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5

Upgrade container packages using vzyum (32bit only)

vzyum CTID upgrade

Note: If yum db-version complains do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting db.

Stop your VE

vzctl stop CTID

Replace the new /dev/ with the old one

cd /vz/private/CTID
rm -rf dev
tar -xvf dev.tar

Leave the container private dir (or it will not start)

cd

Start the container

vzctl start CTID

Remove container IP

vzctl set --ipdel container_IP

Stop container

vzctl stop CTID

Create the template

cd /vz/private/CTID
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .