LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-07-2008, 03:47 AM   #1
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Rep: Reputation: 0
/lib in rescue mode


Hi,

I accidentally deleted /lib in the / directory. There was no indication that this was a serious situation until I rebooted my computer; most essential drivers are gone - so Ethernet, removable h-disk, CD etc cannot be initiated.

Is there a way to restore the lib file from the rescue disk?


Thanks
 
Old 12-07-2008, 06:45 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Please fill in your distro details in your profile. That may help us give better answers.

If you're still running Fedora 8 (http://www.linuxquestions.org/questi...-found-687475/) then if you still have your RPM database (/var/lib/rpm) you could list the packages contents, see what uses /lib and reinstall those. Since RPM provides you with usable package management tools you can use the "verify" command. Boot your rescue CD, mount the root and /var partition if not mounted already, run rpm in verify mode, pipe it through awk or grep to find only missing entities, then query the RPMDB to find the corresponding packages. To get the list of packages to install you could do something like:
Code:
rpm -qVa --noscripts --nodeps --nomd5 --nosignature --nouser --nosize --nogroup --nomode --nomtime --nordev \
--dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm --root /RESCUEDISKMOUNTPOINT/ | awk '/missing/ {print $NF}' \
| while read FILE; do rpm --dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm -qf "${FILE}"; done|sort|uniq
The problem of course is getting the packages. If you can configure your Live CD beforehand to have a working network connection you could feed the list to (a with the right repo's configured) yum, else maybe copy installer CD contents to an external USB or other internal HD and use rpm, else save the package list and find another way. You may find the above commands hard to fathom or execute and that is perfectly OK. If there's one lesson to be learnt it's that it's bad news to go off and just delete whatever you fancy.

Good luck!
 
Old 12-07-2008, 07:24 AM   #3
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks UnSpawn, this is a hard lesson. I'll try to run through the exercise. On the other hand, is it possible to re-install Fedora 8 with minimal impact on existing files? Could you run me through the process? I have the following partitions

/boot 100 MB ext3 partition
swap 2 GB swap

LVM
/ 3 GB ext3
/usr 8 GB ext3
/usr/local 2 GB ext3
/var 4 GB ext3
/home 25 GB ext3

10 GB Free

Thanks
 
Old 12-07-2008, 07:40 AM   #4
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Please fill in your distro details in your profile. That may help us give better answers.

If you're still running Fedora 8 (http://www.linuxquestions.org/questi...-found-687475/) then if you still have your RPM database (/var/lib/rpm) you could list the packages contents, see what uses /lib and reinstall those. Since RPM provides you with usable package management tools you can use the "verify" command. Boot your rescue CD, mount the root and /var partition if not mounted already, run rpm in verify mode, pipe it through awk or grep to find only missing entities, then query the RPMDB to find the corresponding packages. To get the list of packages to install you could do something like:
Code:
rpm -qVa --noscripts --nodeps --nomd5 --nosignature --nouser --nosize --nogroup --nomode --nomtime --nordev \
--dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm --root /RESCUEDISKMOUNTPOINT/ | awk '/missing/ {print $NF}' \
| while read FILE; do rpm --dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm -qf "${FILE}"; done|sort|uniq
The problem of course is getting the packages. If you can configure your Live CD beforehand to have a working network connection you could feed the list to (a with the right repo's configured) yum, else maybe copy installer CD contents to an external USB or other internal HD and use rpm, else save the package list and find another way. You may find the above commands hard to fathom or execute and that is perfectly OK. If there's one lesson to be learnt it's that it's bad news to go off and just delete whatever you fancy.

Good luck!


I get no output after running the above.
 
Old 12-07-2008, 08:14 AM   #5
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Please fill in your distro details in your profile. That may help us give better answers.
To get the list of packages to install you could do something like:
Code:
rpm -qVa --noscripts --nodeps --nomd5 --nosignature --nouser --nosize --nogroup --nomode --nomtime --nordev \
--dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm --root /RESCUEDISKMOUNTPOINT/ | awk '/missing/ {print $NF}' \
| while read FILE; do rpm --dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm -qf "${FILE}"; done|sort|uniq

Content of /RESCUEDISKMOUNTPOINT/...

Packages _db.001 _db.002 _db.003

What does this mean?

Thanks
 
Old 12-07-2008, 08:24 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Quote:
Originally Posted by attaro View Post
is it possible to re-install Fedora 8 with minimal impact on existing files?
Would be easier (faster, less error-prone) I think to boot your rescue CD, mount the LVM, save contents of /home (and /etc, /var/log and /var/lib/rpm) to some other physical disk and reinstall?..


Quote:
Originally Posted by attaro View Post
I get no output after running the above.
I hope you got the hint to change "RESCUEDISKMOUNTPOINT" to the actual mount point path where your original partitions are mounted? Running 'mount' should show. If the LVM isn't mounted automagically you may have to run 'vgchange -ay' manually. Run something like 'lvmdiskscan' beforehand if you like some diagnostics. Once mounted maybe run this command first to see if it finds the RPMDB: "rpm --dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm -q kernel". Posting any errors you encounter makes it easier to diagnose what's going on. If that returns the currently installed kernel versions it means the original RPM database can be queried OK.


Quote:
Originally Posted by attaro View Post
Content of /RESCUEDISKMOUNTPOINT/...
Packages _db.001 _db.002 _db.003
The "_db.00?" files are temporary ones. If you only have one file called "Packages" in that directory, and /RESCUEDISKMOUNTPOINT/ is the right mount point, then you can safely abort now. Rescuing what's there needs references and those are in the RPMDB which, next to the file Packages, contains some ten-ish more database files. Once the RPMDB goes missing reconstruction isn't impossible (see /var/log/rpmpkgs, /var/log/yum.*) but will be incomplete and, unless there's overriding arguments, isn't faster than reinstalling. So do check if that's the only file you got.
 
Old 12-07-2008, 08:47 AM   #7
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Would be easier (faster, less error-prone) I think to boot your rescue CD, mount the LVM, save contents of /home (and /etc, /var/log and /var/lib/rpm) to some other physical disk and reinstall?..
I think it may be wise to reinstall.

Quote:
I hope you got the hint to change "RESCUEDISKMOUNTPOINT" to the actual mount point path where your original partitions are mounted?
My Partitions are mounted in /dev/VolGroup00

Quote:
If the LVM isn't mounted automagically you may have to run 'vgchange -ay' manually. Run something like 'lvmdiskscan' beforehand if you like some diagnostics. Once mounted maybe run this command first to see if it finds the RPMDB: "rpm --dbpath /RESCUEDISKMOUNTPOINT/var/lib/rpm -q kernel". Posting any errors you encounter makes it easier to diagnose what's going on. If that returns the currently installed kernel versions it means the original RPM database can be queried OK.
RPM doesn't return the installed kernel


Thanks
 
Old 12-07-2008, 08:55 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Do you mean the LVM partitions don't get mounted? What does 'lvmdiskscan' return?
 
Old 12-07-2008, 09:06 AM   #9
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
lvmdiskscan returns all partitions
 
Old 12-07-2008, 09:11 AM   #10
attaro
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
If I upgrade from Core 8 to 9 or 10, will it fix the problem?

Thanx
 
Old 12-07-2008, 11:50 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Quote:
Originally Posted by attaro View Post
lvmdiskscan returns all partitions
Does that mean you can't mount them manually or what? And I'd rather see a tool listing like 'lvmdiskscan; mount' if you don't mind.


Quote:
Originally Posted by attaro View Post
If I upgrade from Core 8 to 9 or 10, will it fix the problem?
I think upgrading requires at least the RPMDB to be complete. And you didn't tell us what the contents of /var/lib/rpm are ('find', 'ls', whatever).
 
  


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
Linux Rescue script question, in rescue mode vijay_aras Linux - General 1 01-09-2008 06:03 PM
Is there any way to run rescue mode in test mode. kadhiravan.r Linux - General 2 07-13-2006 09:11 AM
rescue mode hansi umayangan Linux - General 1 03-17-2005 12:43 AM
about rescue mode morrisset Linux - Newbie 3 07-10-2004 12:11 PM
Rescue Mode Help dsiguy Linux - General 9 09-24-2003 04:52 PM


All times are GMT -5. The time now is 08:59 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration