Creating Rpm database

Ed Wilts ewilts at ewilts.org
Wed May 4 11:44:49 UTC 2005


On Wed, May 04, 2005 at 11:10:04AM +0200, Padiyath Sreekumaran wrote:
> 
>    #mkdir /var/lib/rpm
>    #rpm --initdb
>    # ls -la /var/lib/rpm
> total 24
> drwxr-xr-x    2 root     root         4096 May  4 08:58 .
> drwxr-xr-x   25 root     root         4096 May  4 08:57 ..
> -rw-r--r--    1 root     root        24576 May  4 08:57 Packages
> 
>    When I execute "rpm -qa" I get no output.Iam missing a lot of information
> in rpm directory.

That's because initdb creates an *empty* database.

>    How can I recreate it? I donot know how I lost the whole directory
>    and the contents?  Iam missing rpmpkgs file also.

You really have 3 choices (in order of preference):
1.  Restore /var/lib/rpm from your backups
2.  Re-install 
3.  Attempt to re-populate your empty database.

Seriously, there is no easy way for a tool to go through your filesystem
and guess what package owns what file in an attempt to recreate the rpm
database.  On a weekly basis, a cron job runs and creates
/var/log/rpmpkgs.  This file has a list of all the installed rpms in it.
You can try (no guarantees) to install all of those packages again with
the --justdb option and you'll be better off than where you are now, but
you've still got a long battle on your hands installing all those
packages manually.

You should also go through your .bash_history file to see how you
deleted the directory in the first place...  The files and directory are
owned by user rpm and group rpm and normally no users are members of
this group.  The most likely candidate to delete the files is root.

-- 
Ed Wilts, RHCE
Mounds View, MN, USA
mailto:ewilts at ewilts.org
Member #1, Red Hat Community Ambassador Program




More information about the redhat-list mailing list