Centos Upgrade 4.x to 5.x
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:
Contents
- 1 Create the container
- 2 Enter container
- 3 Install centos-5-release packages
- 4 Backup dev
- 5 Install initscripts package
- 6 Exit from container
- 7 Update conf file
- 8 Copy existing template
- 9 Update yum.conf
- 10 Upgrade container packages
- 11 Test your VE
- 12 Stop your VE
- 13 Replace the new /dev/ with the old one
- 14 Remove container IP
- 15 Create the template
Create the container
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 container
vzctl enter $CTID
Install centos-5-release packages
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.6-0.i386.rpm \ http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-6.el5.centos.1.i386.rpm
Note: centos-release-5 depends on notes-package, start with that one.
Backup dev
Backup your /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup:
tar -cf dev.tar /vz/private/$CTID/dev
Install initscripts package
Install initscripts package (forced and with no deps), as per below:
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.33-1.el5.centos.i386.rpm --force --nodeps
Note: If the "transfer failed", go to the CentOS5 mirror and find the latest initscripts rpm and use that instead.
Exit from container
exit
Update conf file
Edit /etc/vz/conf/$CSID.conf and replace
OSTEMPLATE="centos-4-i386-minimal"
with
OSTEMPLATE="centos-5-i386-minimal"
Alternatively, use the 'sed' command to replace it:
sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5#g' /etc/vz/conf/$CTID.conf
Copy existing template
Copy existing template from:
/vz/template/centos/4
to
/vz/template/centos/5
Update yum.conf
In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5
Using sed:
sed -i 's#centos4#centos5#g' /vz/template/centos/5/i386/config/yum.conf sed -i 's#CentOS 4#CentOS 5#g' /vz/template/centos/5/i386/config/yum.conf sed -i 's#centos/4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf
Upgrade container packages
db-version will complain, so delete the conflicting database first:
rm -fr /vz/root/$CTID/var/lib/rpm/__*
Now run vzyum to upgrade the contain packages:
vzyum $CTID upgrade
Troubleshooting
If you get this error:
Error: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree
and/or
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897 Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed
You need to run the following before trying again:
vzctl exec $CTID rpm -e --justdb python-elementtree --nodeps vzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
Test your VE
Check you can enter your VE:
vzctl enter $CTID
All went OK? Exit the VE:
exit
Troubleshooting
Unable to open pty: No such file or directory
If you see errors like this, see the VPS_enter_failed article.
Stop your VE
vzctl stop $CTID
Replace the new /dev/ with the old one
cd /vz/private/$CTID mv dev dev.old tar -xvf dev.tar
Remove container IP
vzctl set $CTID --ipdel all --save
Create the template
cd /vz/private/$CTID tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .