1

If you accidentally delete a crucial library folder, such as /usr/lib, how can you recover from that?

8
  • 7
    install a second identical system and copy paste from this, or use your backup.
    – Kiwy
    Mar 20, 2014 at 13:44
  • Either re-install the system or check your backups. Only some high-level package management system would save you (apt-get, yum or whatever your system is using) and I seriously doubt that some static version is already installed or available.
    – Ouki
    Mar 20, 2014 at 13:46
  • 1
    apt-get install --reinstall if you know what are the packages on Debian systems or on Red Hat based systems: for file in $(rpm -qla|grep ^/usr/lib/); do echo $(rpm -qf $file); done | uniq | sort > /root/packages.ls and then yum reinstall $(cat /root/packages.lst | uniq) THe other way, do as said by @Kiwy
    – user34720
    Mar 20, 2014 at 13:55
  • @nwildner there is probably no possibility of using apt-get or dpkg without /usr/lib
    – Kiwy
    Mar 20, 2014 at 13:57
  • 1
    @nwildner: and /usr/lib/rpm ... so no rpm as well. So a very very lucky one.
    – Ouki
    Mar 20, 2014 at 15:52

3 Answers 3

1

If you delete /usr/lib, you will kill your system as very crucial libraries reside in this directory. Like the LibC library which is used by all binaries. So it is unlikely that you will be able to something. (If you are lucky and interrupted the command with a quick CTRL+C before is comletion, maybe only sub-dirs are deleted and the LibC is still there)

If the system is totally blocked (login impossible, boot fails, ...), let's hope that you have a Live CD of the same distribution and the same version under the hand.

Boot from this CD, mount the filesystem of your hard-disk and copy the /usr/lib from the Live system to the one on the hard-disk.

2
  • 1
    In fact it is not that bad, as libc and many crucial libraries are usually in the /lib and/or /lib64 directories.
    – Ouki
    Mar 20, 2014 at 15:46
  • @Ouki: +1 for you, how could it be possible that I forgot this ;-)
    – Benoit
    Mar 20, 2014 at 18:03
0

extundelete --restore-all when having your file system mounted as read-only. (Be sure you have a ext filesystem.)

! Be sure not to install it on the device you want to recover !

4
  • But installing the extundelete binary could write things into /usr/lib right?
    – user34720
    Mar 20, 2014 at 14:27
  • as extundelete relies on some library I'm not sure this would work. also you're not sure to get 100% of the files you delete specially on a SSD
    – Kiwy
    Mar 20, 2014 at 14:28
  • @nwildner: Yes, you shouldn't install or write or download anything on your disk, if you want to recover it. But as commented above, there are other ways. (I would give it a try, especially if you have your home partition seperatly. You would need a extra system to install or start extundelete, or just install extundelete and their libs locally.)
    – PythoNic
    Mar 20, 2014 at 14:33
  • 1
    Yeah. And that's why i asked ;). Probably if someone run yum install extundelete or apt-get install extundelete could overwrite the deleted data on this partition. Probably the best option to this alternative is to use a totally static binary compiled outside this box. RIP LInux livecd already have this tool installed: tux.org/pub/people/kent-robotti/looplinux/rip/Changelog
    – user34720
    Mar 20, 2014 at 16:34
-1

In some cases, you can try to update or reinstall the package. For example, if you delete or degrade libpthread.so file inside /usr/lib, you can reinstall upper level and container package like glibc to recover the file. This procedure will be done by dependency library and file check during reinstall or updating.

For example, try:

# to recover and take libpthread.so back.
sudo yum install glibc   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .