5

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.

Bittrance
  • 2,970
  • 2
  • 21
  • 27

3 Answers3

5

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.

Alien Life Form
  • 2,279
  • 2
  • 21
  • 31
3

Problems

The issues are as follows:

  1. rpm files from RHEL6 use different magic number
  2. RHEL5 python2.4 does not recognize sha256 which is used to checksum downloads in CentOS 6
  3. 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.

Bittrance
  • 2,970
  • 2
  • 21
  • 27
-1

Great,

in that case for me system crash, was needed to do something more creazy with respect to system.

Many things are so depended on actual state of system so diferences are excepted Moust importatn thing was to resolve "RPM: the bad magic"

before start check Other WAY !!! as


Sometihing is wrong? then you can use rpm2cpio or mc to extract cpio then cpio for extract rpm files and copy manualy to folders don't forget to run ldconfig after that

Probably you have to get new version of cpio for extracting cpio contents

So im going to el6 versions to fix that.

Means, have to made RPM going to work again then i can reinstall other packages.

Because system is broken and no more libraries for el6 are avaiable to install have to compile everything depended from sources.

1) install so much as possible depencies from el5 repository by yum with devel packages where are header files like nss3 + devel lzma + devel nspr4 + devel ncurses + devel readline db-4.5.20 + devel rpm-libs + devel

in other case have to download sources and compile

2) keep going cpio,lzma for get content of SRPMs and patches download cpio 2.10+ better = from home page compile and install download rpm 4.6.0+ better = from home page compile and install download rpm-libs 4.6.0+ better = from home page compile and install download db-4.5.20 better = from home page compile and install

rpm* el6 has 4.8.* but for compatibility is ok 4.6+

If works rpmbuild --rebuild will be greate full in midle lines means it that GOD bless you and you have already installed proper versions of headers and libs

Or for other depencies download src.rpm files Unpack rpm,cpio, main archive apply patches to one folder

http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/

always apply patches like, have to specify right file names or make symlinks in same folder

ls *.patch.bz2|while read a;do bzcat $a > $a.patch;done
ls *.patch.gz|while read a;do zcat $a > $a.patch;done
ls cpio*.patch|while read p;do patch -p0 < "$p";done

after all build of libs like lzma and other you have to do

ldconfig

for configuring RPM

CFLAGS="-lncurses -lnss3 -I/usr/include/nss3 -I/usr/include/nspr4 -lnspr4"
./configure --prefix=/usr --with-lua --with-lzma --with-nss3 --with-nspr4 --with-external-db
make

other configures like cpio

CFLAGS="-lncurses -lnss3 -I/usr/include/nss3 -I/usr/include/nspr4 -lnspr4"
# or specify bin folder
./configure --prefix=/ 
make
# test, !!! make backup of rpm binaries and libs in case rollback /usr/lib/rpm /usr/bin /bin and rpm-db
make install
# then move man and other to /usr/share from / where are now

in case of rollback you have to reinstall rpm manualy or replace files with backuped versions and run ldconfig

command

All is correct?

% make install

and continue with "We can now install baseline:" or if you prefer just update remove other repositories from /etc/yum.repos.d keep just el6 packages

BE CAREFULL and say no if you are not sure there will be some removes, other depencies you have to install manualy with rpm

yum clean all
yum update --skip-broken
package-clean --problems
package-clean --dups
yum update

to create local repository from install DVD just mount isos to mnt and call in mnt

yum install yum-utils
cd /mnt
createrepo .

SOME repositories FIX $releasever with version of el5

    cat << _EOF_ > /etc/yum.repos.d/all-in-one-`date +%s`.repo     
    [base]
    name=CentOS-6.4-colacl-dvd mount
    baseurl=file:///mnt
    gpgcheck=0
    ### Name: RPMforge RPM Repository for RHEL 5 - dag
    ### URL: http://rpmforge.net/
    [rpmforge]
    name = RHEL $releasever - RPMforge.net - dag
    baseurl = http://apt.sw.be/redhat/el5/en/5.7/rpmforge
    mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge-extras]
    name = RHEL $releasever - RPMforge.net - extras
    baseurl = http://apt.sw.be/redhat/el5/en/$basearch/extras
    mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge-extras
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge]
    name = RHEL $releasever - RPMforge.net - dag
    baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
    mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge-extras]
    name = RHEL $releasever - RPMforge.net - extras
    baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras
    mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge-extras
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1


    #---- Packages previously released as 5.7, and its updates
    [C5.7-base]
    name=CentOS-5.7 - Base
    baseurl=http://vault.centos.org/5.7/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-updates]
    name=CentOS-5.7 - Updates
    baseurl=http://vault.centos.org/5.7/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-extras]
    name=CentOS-5.7 - Extras
    baseurl=http://vault.centos.org/5.7/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-centosplus]
    name=CentOS-5.7 - Plus
    baseurl=http://vault.centos.org/5.7/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.6, and its updates
    [C5.6-base]
    name=CentOS-5.6 - Base
    baseurl=http://vault.centos.org/5.6/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-updates]
    name=CentOS-5.6 - Updates
    baseurl=http://vault.centos.org/5.6/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-extras]
    name=CentOS-5.6 - Extras
    baseurl=http://vault.centos.org/5.6/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-centosplus]
    name=CentOS-5.6 - Plus
    baseurl=http://vault.centos.org/5.6/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.5, and its updates
    [C5.5-base]
    name=CentOS-5.5 - Base
    baseurl=http://vault.centos.org/5.5/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-updates]
    name=CentOS-5.5 - Updates
    baseurl=http://vault.centos.org/5.5/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-extras]
    name=CentOS-5.5 - Extras
    baseurl=http://vault.centos.org/5.5/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-centosplus]
    name=CentOS-5.5 - Plus
    baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.4 and its updates
    [C5.4-base]
    name=CentOS-5.4 - Base
    baseurl=http://vault.centos.org/5.4/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-updates]
    name=CentOS-5.4 - Updates
    baseurl=http://vault.centos.org/5.4/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-extras]
    name=CentOS-5.4 - Extras
    baseurl=http://vault.centos.org/5.4/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-centosplus]
    name=CentOS-5.4 - Plus
    baseurl=http://vault.centos.org/5.4/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    #---- Packages previously released as 5.3 and its updates
    [C5.3-base]
    name=CentOS-5.3 - Base
    baseurl=http://vault.centos.org/5.3/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-updates]
    name=CentOS-5.3 - Updates
    baseurl=http://vault.centos.org/5.3/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-extras]
    name=CentOS-5.3 - Extras
    baseurl=http://vault.centos.org/5.3/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-centosplus]
    name=CentOS-5.3 - Plus
    baseurl=http://vault.centos.org/5.3/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.2 and its updates
    [C5.2-base]
    name=CentOS-5.2 - Base
    baseurl=http://vault.centos.org/5.2/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-updates]
    name=CentOS-5.2 - Updates
    baseurl=http://vault.centos.org/5.2/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-extras]
    name=CentOS-5.2 - Extras
    baseurl=http://vault.centos.org/5.2/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-centosplus]
    name=CentOS-5.2 - Plus
    baseurl=http://vault.centos.org/5.2/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.1 and its updates
    [C5.1-base]
    name=CentOS-5.1 - Base
    baseurl=http://vault.centos.org/5.1/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-updates]
    name=CentOS-5.1 - Updates
    baseurl=http://vault.centos.org/5.1/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-extras]
    name=CentOS-5.1 - Extras
    baseurl=http://vault.centos.org/5.1/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-centosplus]
    name=CentOS-5.1 - Plus
    baseurl=http://vault.centos.org/5.1/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    #---- Packages previously released as 5.0 and its updates
    [C5.0-base]
    name=CentOS-5.0 - Base
    baseurl=http://vault.centos.org/5.0/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-updates]
    name=CentOS-5.0 - Updates
    baseurl=http://vault.centos.org/5.0/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-extras]
    name=CentOS-5.0 - Extras
    baseurl=http://vault.centos.org/5.0/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-centosplus]
    name=CentOS-5.0 - Plus
    baseurl=http://vault.centos.org/5.0/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    [basee]
    name=CentOS-$releasever - Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #released updates
    [updatese]
    name=CentOS-$releasever - Updates
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #additional packages that may be useful
    [extrase]
    name=CentOS-$releasever - Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #additional packages that extend functionality of existing packages
    [centospluse]
    name=CentOS-$releasever - Plus
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #contrib - packages by Centos Users
    [contribe]
    name=CentOS-$releasever - Contrib
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.8, and its updates
    [C5.8-base]
    name=CentOS-5.8 - Base
    baseurl=http://vault.centos.org/5.8/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-updates]
    name=CentOS-5.8 - Updates
    baseurl=http://vault.centos.org/5.8/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-extras]
    name=CentOS-5.8 - Extras
    baseurl=http://vault.centos.org/5.8/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-centosplus]
    name=CentOS-5.8 - Plus
    baseurl=http://vault.centos.org/5.8/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
_EOF_

Kindly yould like to invite you to my pages, than who like it, do likes.

Facebook page