4

I recently accidentally deleted the file /lib/x86_64-linux-gnu/libc.so.6. This file is needed by most programs, so my computer is basically broken and I can only access the hard drive through a live USB.

I'm running 64-bit Crunchbang Waldorf, which is Debian-based.

How can I replace libc.so.6? (/lib64/ does not contain a copy.)

Output of locate libc.so (on live USB, with broken hard drive mounted)

/lib/x86_64-linux-gnu/libc.so.6
/rofs/lib/x86_64-linux-gnu/libc.so.6
/rofs/usr/lib/x86_64-linux-gnu/libc.so.6
/usr/lib/x86_64-linux-gnu/libc.so.6

Content of /etc/apt/sources.list

deb http://mozilla.debian.net/ wheezy-backports iceweasel-release

## CRUNCHBANG
## Compatible with Debian Wheezy, but use at your own risk.
deb http://packages.crunchbang.org/waldorf waldorf main contrib
# deb-src http://packages.crunchbang.org/waldorf waldorf main

## DEBIAN
deb http://http.debian.net/debian wheezy main contrib non-free
# deb-src http://http.debian.org/debian wheezy main contrib non-free

## DEBIAN SECURITY
deb http://security.debian.org/ wheezy/updates main contrib
# deb-src http://security.debian.org/ wheezy/updates main
LonelyWebCrawler
  • 237
  • 2
  • 4
  • 12

4 Answers4

4

I am going to assume your live USB stick has the same distribution as you're running otherwise or at least it is a Debian based one.

With those assumptions first boot your system with your live USB stick. Then query which package owns the file /lib/x86_64-linux-gnu/libc.so.6 with command dpkg -S /lib/x86_64-linux-gnu/libc.so.6 (the file will turn out to be owned by the package called "libc6" but it is a nice exercise anyway).

When you have your system running from a USB stick live distro, download required package or packages from Crunchbang Waldorf site.

Then mount your hard disk drive to some directory. For the sake of example I'm going to, again, assume that you'll be mounting your root partition from your hard disk drive under /mnt.

Then all there is left to do is to re-install the required package or packages using --root /mnt directive for dpkg. That way the packages are not going to end up onto your live USB stick filesystem but instead into the system you already have on your hard disk.

  • Thanks, I will try this out soon. But I'm wondering: Wouldn't it also be possible to boot to the exact same distro and simply copy the missing file from USB to hard drive? Or will this mess up packaging? – LonelyWebCrawler Jul 27 '14 at 14:20
  • 2
    Most likely that will work, but in case you've ran some updates on the system on your hard disk, the file on your USB live system might not be identical. What I suggested above is not the only way to get it right (another would be to download the exact same version of the deb-package, unpacking it and copying the file by hand, but then you might as well use dpkg then). –  Jul 27 '14 at 16:06
  • Please help, Sami! I cannot find the package `libc.so.6` at [packages.crunchbang.org](http://packages.crunchbang.org). – LonelyWebCrawler Aug 23 '14 at 23:41
  • I think it's [this one](https://packages.debian.org/wheezy/amd64/libc6/download). As instructed: download first and then install using dpkg. – agtoever Oct 20 '14 at 14:15
1

The libc.so.6 file is present in the libc6 package.

You have to find out from what repository the libc6 package was installed on your machine. (Check /etc/apt/sources.list, etc).

Then manually download it (For instance, if it was a Debian machine using the default repositories you could download it from here), and then install it using the instructions provided by @SamiLaine.

That Brazilian Guy
  • 6,834
  • 10
  • 64
  • 102
  • Sorry, I'm not that good with packages and don't quite understand. The package is libc6, but where do I find it? I've pasted the content of `/etc/apt/sources.list` in the post. – LonelyWebCrawler Aug 27 '14 at 20:50
1

Try this in a root shell :

ln -s /lib/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6

If libc-2.13.so is not the right version for your system, use tab-completion in bash to find the right one.

If this doesn't work, you could follow with the statically-linked version of ldconfig in a root shell :

/sbin/ldconfig

If the target library for the libc links was deleted, download the debian package from the Package: libc6 page, unpack it using dpkg-deb -X (man page) and copy libc-2.13.so to /lib/x86_64-linux-gnu. Then run ldconfig to ensure that all links are correct.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • I deleted `libc.so.6` through making a similar link, so excuse me if I'm a little skeptical. Are libc-2.13 (in my case) and libc.so.6 identical? Why should I place `libc.so.6` in `/lib64/` and not in `/lib/x86_64-linux-gnu/`, where I deleted it from? – LonelyWebCrawler Aug 28 '14 at 17:21
  • If you have not deleted the library that is the source of all these links, it might be worthwhile to try ldconfig which re-establishes all links. You could use the `-v` verbose parameter for more info. – harrymc Aug 28 '14 at 18:48
  • Unfortunately I did delete the library—it's complicated. – LonelyWebCrawler Aug 29 '14 at 07:19
  • I added above some more advice for this case. – harrymc Aug 29 '14 at 08:38
  • So sorry, I misunderstood you. I still have `libc-2.13.so` (though not `2.19`). I will try the link above. – LonelyWebCrawler Aug 29 '14 at 13:49
1

Open a terminal (Ctrl+Alt+T) and run the following commands:

For 64-bit Ubuntu:

sudo ln -s /lib64/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6

For 32-bit Ubuntu:

sudo ln -s /lib/i386-linux-gnu/libc.so.6 /lib/libc.so.6
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Jollyfreak
  • 11
  • 2