LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /lib in rescue mode (https://www.linuxquestions.org/questions/linux-newbie-8/lib-in-rescue-mode-688865/)

attaro 12-07-2008 02:47 AM

/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

unSpawn 12-07-2008 05:45 AM

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!

attaro 12-07-2008 06:24 AM

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

attaro 12-07-2008 06:40 AM

Quote:

Originally Posted by unSpawn (Post 3367006)
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.

attaro 12-07-2008 07:14 AM

Quote:

Originally Posted by unSpawn (Post 3367006)
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

unSpawn 12-07-2008 07:24 AM

Quote:

Originally Posted by attaro (Post 3367025)
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 (Post 3367034)
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 (Post 3367057)
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.

attaro 12-07-2008 07:47 AM

Quote:

Originally Posted by unSpawn (Post 3367064)
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

unSpawn 12-07-2008 07:55 AM

Do you mean the LVM partitions don't get mounted? What does 'lvmdiskscan' return?

attaro 12-07-2008 08:06 AM

lvmdiskscan returns all partitions

attaro 12-07-2008 08:11 AM

If I upgrade from Core 8 to 9 or 10, will it fix the problem?

Thanx

unSpawn 12-07-2008 10:50 AM

Quote:

Originally Posted by attaro (Post 3367089)
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 (Post 3367091)
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).


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