CentOS6 installation from CentOS5 box?
I am trying to build a new CentOS 6 VM from my CentOS 5 host, but it appears that something fundamental has changed between these versions:
$ rpm -ivh --nodeps --nodigest --ignorearch --ignoreos --force --root=/mnt centos-release-6-0.el6.centos.5.i686.rpm
warning: centos-release-6-0.el6.centos.5.i686.rpm: Header V3 RSA/SHA256 signature: NOKEY, key ID c105b9de
Preparing... ########################################### [100%]
1:centos-release ########################################### [100%]
error: unpacking of archive failed: cpio: Bad magic
$ rpm --version
RPM version 4.4.2.3
Did the magic number of RPMs change between these versions? How do I work around this?
EDIT (Clarification):
I am not trying to upgrade an existing machine. I am trying to create a new installation using yum --installroot=/mnt groupinstall core. In order to get a working config, step one is to install the release rpm which contains the yum repo config.
Solution 1:
Cant do that, AFAIK: the bad magic in the RPM is the least of the problems.
In short: there is no reccommended RHEL5->RHEL6 upgrade path, hence no Centos5->6. I tried a little skulduggery in that direction (I have a largish number of C5 servers myself) but decided against it.
Consider that a 5->6 transition amounts to a fedora core 6->12 transition BUT without preupgrade support in yum. So you could conceivably pop a FC7 DVD, boot with
selinux=0 upgradeany
rinse, and repeat with FC8...FC11 ending with CentOS6. And good luck with that - speaking of my own machines I'd be rather surprised by ending up with anything more sophisticated than bash in working order - this after a couple of days spent in attempting this funky feat.
I estimate I'd probably rebuild a (working) machine in less time. Which is just as well, given that RHEL5 still has a couple of years of support.
Solution 2:
Problems
The issues are as follows:
- rpm files from RHEL6 use different magic number
- RHEL5 python2.4 does not recognize sha256 which is used to checksum downloads in CentOS 6
- yum uses different database format in RHEL6 such that a chroot environment built by RHEL5 yum will not be comprehensible to yum from RHEL6
Solution
WARNING: Below solution to issue 1 is DANGEROUS. If RPM upgrade breaks you are likely to end up with a broken system. Solution to issue 2 may result in installation of broken packages!
Issue 1 can be circumvented by backporting RPM 4.6 from source RPM. See http://orcorc.blogspot.com/2009/03/oh-my-goodness.html.
Build dependencies for soure RPM:
$ yum install redhat-rpm-config elfutils-devel elfutils-libelf-devel readline-devel zlib-devel nss-devel gettext-devel libselinux-devel ncurses-devel bzip2-devel python-devel lua-devel xz-devel xz
No proper lua in my CentOS dist. Acquired from rpmsearch:
$ rpm -i lua-5.1.2-1.el5.x86_64.rpm lua-devel-5.1.2-1.el5.x86_64.rpm
Install and build the source RPM. May of course require additional packages, such as gcc:
$ rpm -i rpm-4.6.0-4.0.notting.1.el5.src.rpm
$ rpmbuild -ba /usr/src/redhat/SPECS/rpm.spec
Test before actually installing replacement RPMs:
$ rpm -U --test /usr/src/redhat/RPMS/i386/rpm-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-libs-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-python-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-build-4.6.0-4.0.notting.1.i386.rpm
We can now install baseline:
$ rpm -i --root=/mnt centos-release-6-0.el6.centos.5.i686.rpm
Issue 2 can be worked around by manually editing /usr/lib/python2.4/site-packages/yum files (PYTHONPATH magic could be used to make this somewhat less hackish). The diff looks thus:
--- yum-python/__init__.py 2011-10-05 11:03:00.000000000 +0200
+++ /usr/lib/python2.4/site-packages/yum/__init__.py 2011-10-05 11:14:24.000000000 +0200
@@ -1215,7 +1215,7 @@
if ylp.pkgtup != po.pkgtup:
failed = True
-
+ failed = False
if failed:
# if the file is wrong AND it is >= what we expected then it
# can't be redeemed. If we can, kill it and start over fresh
diff -ru yum-python/yumRepo.py /usr/lib/python2.4/site-packages/yum/yumRepo.py
--- yum-python/yumRepo.py 2011-10-05 11:03:00.000000000 +0200
+++ /usr/lib/python2.4/site-packages/yum/yumRepo.py 2011-10-05 11:12:51.000000000 +0200
@@ -1461,6 +1461,7 @@
else:
file = fn
+ return 1
try:
l_csum = self._checksum(r_ctype, file) # get the local checksum
except Errors.RepoError, e:
We are now ready to perform yum groupinstall:
$ yum groupinstall --nogpgcheck --installroot=/mnt core
Note that since we have disabled most package verification, packages may fail installation at this step. Pay close attention to output:
Failed:
python.i686 0:2.6.5-3.el6_0.2 redhat-logos.noarch 0:60.0.14-10.el6
$ yum install --nogpgcheck --installroot=/mnt python redhat-logos
Rinse and repeat.
Since core won't do any system setup, you may need to do any number of things before next step. I need to provide /mnt/etc/resolv.conf.
We now have an environment that can be chrooted into for issue 3:
$ SHELL=/bin/bash chroot /mnt
$ yum install zsh
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm
Fortunately, this is easy to fix: just rebuild /var/lib/rpm:
$ mv /var/lib/rpm/ /var/lib/old.rpm
$ rpm --initdb
At this point I ran into the classic $releasever issue, so I had to edit /etc/yum.repos.d/* to replace $releasever with 6. Something like:
sed -re 's/\$releasever/6/g' -i /etc/yum.repos.d/CentOS-Base.repo
There is probably a better way to do this, but I haven't found it.
$ yum install zsh
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. $releasever is not a valid release or hasnt been released yet/
removing mirrorlist with no valid mirrors: /var/cache/yum/i386/$releasever/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
After this edit, yum works as expected and I have a working CentOS 6 built from CentOS 5. Any chroot environment/VM guest setup instruction for CentOS 6 should be able to get you to a full-blown system.