7

I'm getting an error every time I try to run commands on my RPi:

pi@rpi ~ $ apt-get install wkhtmltopdf
Segmentation fault

Even when I try running other commands:

pi@rpi ~ $ uptime
-bash: /usr/bin/uptime: cannot execute binary file

But others work:

pi@rpi ~ $ w
 09:09:24 up 8 days, 15:01,  1 user,  load average: 0.90, 0.67, 0.37
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
pi       pts/0    241-6.allergrupp 09:02    0.00s  1.91s  0.03s w

Has anyone experienced this?

Diogo Gomes
  • 121
  • 6
rebellion
  • 179
  • 1
  • 1
  • 5

6 Answers6

7

That's very unfortunate. Segmentation faults should not be happening like that, and it strongly implies to me you have filesystem corruption. It could also be the result of something malicious, but that is probably less likely on the pi since it is prone to such corruption if, eg, it is subject to inappropriate voltages, or frequently unplugged without a proper shutdown.

Take the SD card out, salvage whatever you want/can off it using another computer, then umount it there but leave it plugged in and try:

e2fsck -y -c /dev/[sdXN]

Where 'sdXN' is the second partition. That might fix things. If not, give up and replace the image on it -- it's wrecked.

After you replace the image, run the same slow fsck (with -c to check for bad blocks) on the 2nd partition while the card is in another computer. This is to make sure the card is not faulty or worn out.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • This didn't help. What I now experience is that the SD card won't be formatted with either Mac, PC nor SD Formatter. Corrupt card maybe? – rebellion Aug 15 '13 at 07:14
3

These kinds of issues are like trying chase a white Rabbit. You will waste a lot of time and never catch it. It sounds like the file system is corrupt. In my experience with Raspberry Pi Distros and the Pi is to make backups of your images. I take backups at critical points, so when this does happen, I can just re-image the SD card.

I have had too many cards or file systems become corrupt. A good work-around is to use a USB stick for the File System. Some useful info can be found here.

I personally think that using a SD card in inherently flawed. With no built in power switch to perform a safe shutdown you are almost guarantee to corrupt your file system. I know because it has happen to me a lot. I always do a "Safe Shutdown" and have had SD card break. The best you can do is use the USB as the file system and always backup your images :)

PhillyNJ
  • 1,210
  • 2
  • 16
  • 28
1

This seems to be the result of filesystem corruption on the SD card. My two RPi-s have both experienced it, usually after either a lot of use over a short period (say, downloading torrents), or just after long uptimes. I haven't found any easy way to repair the damage, and have just reflashed images onto the cards.

Trying another power adapter is always a good idea, too.

Toby
  • 11
  • 2
0

Like all strange and semi-random errors on a Pi, this can also be caused by a power supply that doesn't deliver enough and/or stable power. Try a different model.

0

I know this is an old question but I had this problem with apt-get. If the segmentation fault only occurs when running apt-get this might help:

sudo rm -rf /var/cache/apt/*.bin

After running this command I was able to install packages again.

NULL
  • 2,240
  • 8
  • 26
  • 49
0

Can you confirm that you have enough space on the SD card, I think I saw this when I forgot to expand my rootfs after install. It fills up pretty quick after initial configuration and loading of packages. Do a df -k and make sure you are not at 100% on rootfs.

Ghanima
  • 15,855
  • 15
  • 61
  • 119
Robert
  • 271
  • 1
  • 1