How-To: Reinstall rpm and yum without rpm/yum in CentOS/RHEL
We were trying to reinstall the Munin package last week in one of our production servers and I somehow managed to screw things up. I accidentally removed rpm (and since yum depends on it, it was removed also!). And since yum and rpm are now gone, we can’t install anything! Cr*p!
Desperate times indeed. Luckily, Google search somehow pointed me in the right direction. I stumbled on this site, [www.thedumbterminal.co.uk] and it gave me the answer that I was looking for
NOTE: Check first if what version of CentOS do you have and what architecture. URLs must be changed if you’re not using CentOS 4.1
These are the commands that I executed in shell:
$ mkdir /tmp/install && cd /tmp/install
$ wget -c http://vault.centos.org/4.1/os/i386/CentOS/RPMS/rpm-4.3.3-9_nonptl.i386.rpm
$ rpm2cpio rpm-4.3.3-9_nonptl.i386.rpm | cpio -dim
$ find . -type d -exec chmod 755 {} \;
$ tar cf - ./usr ./etc ./bin | (cd /; tar xvf -)
$ rpm --rebuilddb
$ rpm -i rpm-4.3.3-9_nonptl.i386.rpm
In the last line (above), rpm has to be re-installed to update the package version in CentOS db. rpm won’t install a .rpm package otherwise. You have to copy the rpm2cpio command from other existing CentOS/RHEL installations if you can’t find/run it.
To re-install yum, I ran these commands:
$ wget -c http://vault.centos.org/4.1/os/i386/CentOS/RPMS/yum-2.2.1-1.centos4.noarch.rpm
$ wget -c http://vault.centos.org/4.1/os/i386/CentOS/RPMS/rpm-python-4.3.3-9_nonptl.i386.rpm
$ rpm -i rpm-python-4.3.3-9_nonptl.i386.rpm
$ rpm -i yum-2.2.1-1.centos4.noarch.rpm
And that’s how I cleaned-up my mess. And yes, the server is running CentOS 4.1





![#1 sunrise in Canlamay [111229] #1 sunrise in Canlamay [111229]](http://farm8.staticflickr.com/7173/6662552081_28099375b5_m.jpg)
Huh ) Pretty tricky! U’ve saved my life man!
dude…you rock…you saved my time…i never found this information anywhere…luv u!
Not sure what’s happening here, but I follow the steps happily until I get to rpm –rebuild – I get this error:
rpm: error while loading shared libraries: librpm-4.3.so: cannot open shared object file: No such file or directory
This is causing me a major stress now and don’t know what to do! I’m on CentOS 5.5 (though for some reason after this, it told me I was now using 5.6).
Any help will be greatly appreciated as yum is currently rendered useless!!!
Thanks
Hi Ian. Did you manage to fix it? What rpm package did you download?
Dude,
same issue I have no rpm as well no yum….following the steps over here but how do i copy rpm2cpio from another machine and how do I run on this machine …I have Centos 5.2…