LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 08-27-2007, 11:53 PM   #1
xi_guadiy
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Rep: Reputation: 0
Unhappy / Var directory was delete.system cannot login!


i made a mistake that i delete my /var directory

Does anybody can help me to recover it ? i can not login my

system now.My server is :redhat as5.0
 
Old 08-28-2007, 05:54 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,743
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
Is it a local or remote system?
Do you have similar systems or just one RHEL-5 AS box?
Don't you have a backup?
Else do you have a backup of /var/lib/rpm (highly unlikely but OK)?
Else do you still have the /root/install.log?
 
Old 08-28-2007, 11:49 PM   #3
xi_guadiy
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Is it a local or remote system?
Do you have similar systems or just one RHEL-5 AS box?
Don't you have a backup?
Else do you have a backup of /var/lib/rpm (highly unlikely but OK)?
Else do you still have the /root/install.log?
Thanks for your reply.

It`s a local system,not remote. But i do not have any backup.

I can not login my server with ant runlevel.but i

think /root/install.log exist in my server.As this server is an new-

instlled system on few days ago. IF an similar systems exist, how can i

use that similar system to fix this server?

Thanks again!
 
Old 08-29-2007, 12:59 AM   #4
xi_guadiy
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Now i can login in my server with init 1.

i found install.log in /root directory.i do not have /var/lib/rpm backup.

But /var/lib/rpm is exsit in my /var directory. That`s means all things under /var has

deleted except /var/lib/rpm.

# cd /var/lib/rpm
# ls -l

__db.0001,__db.002,__db.0003,Packages,Providename

as you can see, five files exist in /var/lib/rpm.

How can i fix that problem ?

Many thanks !
 
Old 08-29-2007, 03:14 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,743
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
Quote:
Originally Posted by xi_guadiy View Post
/var/lib/rpm is exsit in my /var directory. That`s means all things under /var has deleted except /var/lib/rpm.
That's definately weird but OK...


Quote:
Originally Posted by xi_guadiy View Post
__db.0001,__db.002,__db.0003,Packages,Providename
Cool. We only need the "Packages" file. The steps are below. Please remove outer single quotes before running commands and if you are not sure read the manual page for the command or ask BEFORE executing these steps.

1. The "__db.00" files are temporary files and should be deleted first: 'rm -f /var/lib/rpm/__db.00?'.
2. Test the RPM database to make sure we don't waste time: '/usr/lib/rpm/rpmdb_verify /var/lib/rpm/Packages || echo BAD && echo OK'.
3. If the database is OK make a list of files in /var: 'rpm -qa --dump|grep ^/var/|awk '{print $1}'|sort|uniq > /tmp/rpm_varfiles'.
4. Finds the RPM's that these files are in: 'cat /tmp/rpm_varfiles|while read file; do rpm -q --whatprovides "${file}"; done|sort|uniq > /tmp/rpm_varrpms'. You now have a file called "/tmp/rpm_varrpms" which contains the RPM's that should be restored. Now you have a choice:

A. You can choose to reinstall the RPM's. Pro: you can be sure all permissions are right and the RPM database is synced. Con: If you install a package that made changes in configuration files in /etc you will lose those changes. If there are not that many packages affected this may be your best choice.

B. You can choose to extract the RPM's contents to a safe directory, move the files in place and then fix the permissions. Con: it takes more steps, misses out on all things post-install scripts configure (unless you extract and run those too) and it isn't really "the RPM way". Pro: this is selective since you won't overwrite files.

I'd suggest you perform steps 1-4, tell us if all went OK, what the output of 'wc -l /tmp/rpm_varrpms' is and which path you choose.

And make sure you have all the install CDROMs ready.

Last edited by unSpawn; 08-29-2007 at 07:09 PM.
 
Old 08-29-2007, 11:00 PM   #6
xi_guadiy
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Hi unSpawn,

Thanks for your info,i executed it step by step:

1, delete the temporary files
#rm -fr __db.00??

2.RPM data base is OK

# /usr/lib/rpm/rpmdb_verify /var/lib/rpm/Packages || echo BAD && echo OK
OK

3.

#rpm -qa --dump|grep ^/var/|awk '{print $1}'|sort|uniq > /tmp/rpm_varfiles

#cd tmp/
#ls -l rpm_varfiles
-rw-r--r-- 1 root root 0 Aug 30 10:17 rpm_varfiles

4.

#cat /tmp/rpm_varfiles|while read file; do rpm -q --whatprovides "${file}"; done|sort|uniq > /tmp/rpm_varrpms

#cd /tmp
#ls -l rpm_varrpms

-rw-r--r-- 1 root root 0 Aug 30 10:19 rpm_varrpms

# wc -l rpm_varrpms

0 /tmp/rpm_varrpms

As you can see,size of file that generate by step 3 and 4 is 0.

Does anything wrong with me ? Tks again!

P.S, there is another similiar server on my office.does this can

help.me ?
 
Old 08-30-2007, 12:27 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,743
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
Quote:
Originally Posted by xi_guadiy View Post
As you can see,size of file that generate by step 3 and 4 is 0. Does anything wrong with me ?
No RPM's listed? That's sad...


Quote:
Originally Posted by xi_guadiy View Post
P.S, there is another similiar server on my office.does this can help.me ?
If it's similar it might help. Let's try. This is going to be somewhat of a kludge...

1. Generate a list of files on your system: 'find /etc /usr /bin /sbin /lib /opt not -type d -xdev 2> /tmp/2ndtry.err > /tmp/2ndtry.log'. The file /tmp/2ndtry.log contains a list of all itemnames. Copy it to the similar system.

2. Generate a list of RPM's. Basically step 4 of the previous post: 'cat /tmp/2ndtry.log|while read file; do rpm -q --whatprovides "${file}"; done|sort|uniq > /tmp/2ndtry.rpms'

3. Count the lines again with 'wc' like you did before: 'wc -l /tmp/2ndtry.rpms' and tell us how many you got now.

4. Ponder the A/B choice of the previous post...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Permission Denied when trying to delete /var robintw Linux - General 4 09-17-2005 03:00 PM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 07:54 PM
VAR - logs - when to delete High-gain Linux - Newbie 4 02-27-2005 10:54 AM
Delete file in /var chii-chan Linux - Newbie 5 03-19-2004 05:58 PM
Cleaning up /var partition - what to delete? mattkat Red Hat 1 09-24-2003 03:56 PM


All times are GMT -5. The time now is 06:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration