Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is the history:

I have (or had), a linux box with CentOS 5.9 and a pre installed LAMP configuration. It was working but was too out of date, for instance mysql was version 4. So I decided to upgrade everything with yum.

Weirdly my sqlite was 3.6 what is newer that 3.3 that is listed as a dependence for newer PHP, Apache and subversion, so yum stopped upgrade and complained about that.

Then I did a very wrong thing: I used yum erase sqlite to remove the old (yet newer), sqlite from my system. At this point yum removed sqlite and ALL other packages that have it as a dependence. This included basically everything :)

Now I still have ssh access to my box but apache, mysql, php, was gone, a lot of other stuff was deleted too, including development package, rpm and yum itself.

I'm experienced with debian and apt-get, and I can hardly believe that I did this in my first 30 minutes on a centos machine with yum. Now I have no idea at all how to fix that.

I've found how to install yum from a rpm file, or rpm from yum, but since I have none...

In my root I have this file: initrd-2.6.18-308.13.1.el5.centos.plus.img I imagine it is a image of my system as preinstalled but I have no ideia of how to recover my system from this file.

Does someone can help me with this?

share|improve this question
    
Could you show output of the following command # file initrd-2.6.18-308.13.1.el5.centos.plus.img –  ALex_hha Jul 9 '13 at 18:18
1  
It's time to restore from your backup. –  Michael Hampton Jul 9 '13 at 18:30
    
It returns: initrd-2.6.18-308.13.1.el5.centos.plus.img: gzip compressed data, from Unix, last modified: Wed May 8 15:18:18 2013, max compression –  Gustavo Vargas Jul 9 '13 at 18:31
    
I have no backup... It is a virtual box running god know where and, I did this half hour after I've put my hands on it... shame!! –  Gustavo Vargas Jul 9 '13 at 18:33

2 Answers 2

up vote 2 down vote accepted

You could try to extract the following packages on another host:

http://mirror.mirohost.net/centos/5.9/updates/x86_64/RPMS/rpm-4.4.2.3-32.el5_9.x86_64.rpm http://mirror.mirohost.net/centos/5.9/updates/x86_64/RPMS/rpm-libs-4.4.2.3-32.el5_9.x86_64.rpm

and then just copy binary files with scp/wget/rsync. I have tried on vmware workstations and all works fine

# yum erase rpm
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package rpm.x86_64 0:4.4.2.3-32.el5_9 set to be erased
--> Processing Dependency: rpm = 4.4.2.3-32.el5_9 for package: rpm-python
--> Processing Dependency: rpm = 4.4.2.3-32.el5_9 for package: rpm-libs
--> Processing Dependency: rpm for package: man
--> Processing Dependency: rpm = 4.4.2.3-32.el5_9 for package: rpm-build
--> Processing Dependency: rpm = 4.4.2.3-32.el5_9 for package: rpm-devel
--> Processing Dependency: rpm >= 4.4.2 for package: yum
--> Running transaction check
---> Package man.x86_64 0:1.6d-3.el5 set to be erased
--> Processing Dependency: man >= 1.6d-2 for package: man-pages-overrides
---> Package rpm-build.x86_64 0:4.4.2.3-32.el5_9 set to be erased
---> Package rpm-devel.x86_64 0:4.4.2.3-32.el5_9 set to be erased
--> Processing Dependency: rpm-devel for package: net-snmp-devel
---> Package rpm-libs.x86_64 0:4.4.2.3-32.el5_9 set to be erased
--> Processing Dependency: librpm-4.4.so()(64bit) for package: net-snmp
--> Processing Dependency: librpmio-4.4.so()(64bit) for package: net-snmp
---> Package rpm-python.x86_64 0:4.4.2.3-32.el5_9 set to be erased
--> Processing Dependency: rpm-python for package: system-config-network-tui
---> Package yum.noarch 0:3.2.22-40.el5.centos set to be erased
--> Processing Dependency: yum >= 3.2.22 for package: yum-updatesd
--> Processing Dependency: yum >= 3.0 for package: yum-fastestmirror
--> Running transaction check
---> Package man-pages-overrides.noarch 0:5.9.2-2.el5 set to be erased
---> Package net-snmp.x86_64 1:5.3.2.2-20.el5 set to be erased
---> Package net-snmp-devel.x86_64 1:5.3.2.2-20.el5 set to be erased
---> Package system-config-network-tui.noarch 0:1.3.99.21-1.el5 set to be erased
--> Processing Dependency: system-config-network-tui for package: firstboot-tui
---> Package yum-fastestmirror.noarch 0:1.1.16-21.el5.centos set to be erased
---> Package yum-updatesd.noarch 1:0.9-5.el5 set to be erased
--> Running transaction check
---> Package firstboot-tui.x86_64 0:1.4.27.9-1.el5.centos set to be erased
--> Processing Dependency: /usr/bin/man for package: redhat-lsb
--> Processing Dependency: /usr/bin/man for package: redhat-lsb
--> Processing Dependency: /bin/rpm for package: policycoreutils
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package policycoreutils.x86_64 0:1.33.12-14.8.el5_9 set to be erased
--> Processing Dependency: policycoreutils >= 1.33.12-14.5 for package: selinux-policy-targeted
--> Processing Dependency: policycoreutils for package: sudo
--> Processing Dependency: policycoreutils for package: sudo
--> Processing Dependency: policycoreutils >= 1.33.12-14.5 for package: selinux-policy
--> Processing Dependency: policycoreutils for package: setools
---> Package redhat-lsb.i386 0:4.0-2.1.4.el5 set to be erased
---> Package redhat-lsb.x86_64 0:4.0-2.1.4.el5 set to be erased
--> Running transaction check
---> Package selinux-policy.noarch 0:2.4.6-338.el5 set to be erased
---> Package selinux-policy-targeted.noarch 0:2.4.6-338.el5 set to be erased
---> Package setools.x86_64 0:3.0-3.el5 set to be erased
---> Package sudo.x86_64 0:1.7.2p1-22.el5_9.1 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                                      Arch                      Version                                    Repository                    Size
======================================================================================================================================================
Removing:
 rpm                                          x86_64                    4.4.2.3-32.el5_9                           installed                    3.6 M
Removing for dependencies:
 firstboot-tui                                x86_64                    1.4.27.9-1.el5.centos                      installed                    652 k
 man                                          x86_64                    1.6d-3.el5                                 installed                    354 k
 man-pages-overrides                          noarch                    5.9.2-2.el5                                installed                    181 k
 net-snmp                                     x86_64                    1:5.3.2.2-20.el5                           installed                    2.8 M
 net-snmp-devel                               x86_64                    1:5.3.2.2-20.el5                           installed                    8.0 M
 policycoreutils                              x86_64                    1.33.12-14.8.el5_9                         installed                    2.1 M
 redhat-lsb                                   i386                      4.0-2.1.4.el5                              installed                     21 k
 redhat-lsb                                   x86_64                    4.0-2.1.4.el5                              installed                     22 k
 rpm-build                                    x86_64                    4.4.2.3-32.el5_9                           installed                    1.5 M
 rpm-devel                                    x86_64                    4.4.2.3-32.el5_9                           installed                    4.1 M
 rpm-libs                                     x86_64                    4.4.2.3-32.el5_9                           installed                    2.0 M
 rpm-python                                   x86_64                    4.4.2.3-32.el5_9                           installed                    131 k
 selinux-policy                               noarch                    2.4.6-338.el5                              installed                    7.9 M
 selinux-policy-targeted                      noarch                    2.4.6-338.el5                              installed                     33 M
 setools                                      x86_64                    3.0-3.el5                                  installed                    3.3 M
 sudo                                         x86_64                    1.7.2p1-22.el5_9.1                         installed                    884 k
 system-config-network-tui                    noarch                    1.3.99.21-1.el5                            installed                    4.9 M
 yum                                          noarch                    3.2.22-40.el5.centos                       installed                    3.3 M
 yum-fastestmirror                            noarch                    1.1.16-21.el5.centos                       installed                     47 k
 yum-updatesd                                 noarch                    1:0.9-5.el5                                installed                     55 k

Transaction Summary
======================================================================================================================================================
Remove       21 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y

And then

# wget http://mirror.mirohost.net/centos/5.9/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm

# wget http://mirror.mirohost.net/centos/5.9/os/x86_64/CentOS/rpm-python-4.4.2.3-31.el5.x86_64.rpm

# wget http://mirror.mirohost.net/centos/5.9/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm

# rpm -ivh --nodeps yum-3.2.22-40.el5.centos.noarch.rpm  rpm-python-4.4.2.3-31.el5.x86_64.rpm yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
Preparing...                ########################################### [100%]
   1:rpm-python             ########################################### [ 33%]
   2:yum-fastestmirror      ########################################### [ 67%]
   3:yum                    ########################################### [100%]

Check that all works fine

# yum install mc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.colocall.net
 * epel: ftp.colocall.net
 * extras: ftp.colocall.net
 * rpmforge: ftp.colocall.net
 * updates: centos.itt-consulting.com
base                                                                                                                           | 1.1 kB     00:00
epel                                                                                                                           | 3.6 kB     00:00
extras                                                                                                                         | 2.1 kB     00:00
rpmforge                                                                                                                       | 1.9 kB     00:00
updates                                                                                                                        | 1.9 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.6.1a-35.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                        Arch                               Version                                     Repository                        Size
======================================================================================================================================================
Installing:
 mc                             x86_64                             1:4.6.1a-35.el5                             base                             2.1 M

Transaction Summary
======================================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 2.1 M
Is this ok [y/N]:
Downloading Packages:
mc-4.6.1a-35.el5.x86_64.rpm                                                                                                    | 2.1 MB     00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mc                                                                                                                             1/1

Installed:
  mc.x86_64 1:4.6.1a-35.el5

Complete!

P.S After that don't forget to reinstall rpm via yum ;)

# yum install rpm
share|improve this answer
    
Alex_hha It took me some days to have available time to do this procedure, but I did this morning and it worked! I've lost a long time trying to figure out what to copy between machines and at the end I think I have made a copy of almost everything, but rpm command and yum is live again on my machine! Thank you so much! –  Gustavo Vargas Jul 14 '13 at 14:17

You could try the following commands

# cd /mnt
# zcat /root/initrd-2.6.18-308.13.1.el5.centos.plus.img | cpio -i

But I think it doesn't solve your problem. You could try to download сentos dvd, mount them and install all necessary packages

# cd /root 
# wget http://mirror.mirohost.net/centos/5.9/isos/x86_64/CentOS-5.9-x86_64-bin-DVD-1of2.iso
# mount -o loop /root/CentOS-5.9-x86_64-bin-DVD-1of2.iso /mnt

P.S. You can see all removed packages in /var/log/messages

share|improve this answer
    
Your first option gave me a few directories in /mnt. /mnt/lib have files inside (some big .ko files), and /mnt/bin have 3 executables, others are empty. I'm downloading DVD to give it a try! Thank you by now! –  Gustavo Vargas Jul 9 '13 at 19:01
    
It's just an initial ramdisk. Is a scheme for loading a temporary root file system into memory in the boot process of the Linux kernel. initrd used to make preparations before the real root file system can be mounted. –  ALex_hha Jul 9 '13 at 19:16
    
Ok, I got the DVD mounted and I found a list of erased packages where you told me to look for (a lot of them). On DVD there is a lot of .rpm files but how can I install then if rpm command is missing on my system? I already tried download source code of rpm and compile it but the system also lacks the development package –  Gustavo Vargas Jul 9 '13 at 19:37
    
Since I have now the CentOS DVD there is a way for me to install it from zero on my system? I can erase all system, I don't care at this point. Even a very basic setup will work for me. If I could have RPM working again I could install all I need from scrap. –  Gustavo Vargas Jul 9 '13 at 19:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.