6

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?

  • Try adding sudo to the start of your commands, just in case it's a permissions issue. – recantha Mar 12 '13 at 8:41
  • 1
    It's not a permissions issue. It may work coincidentally (but I doubt it) -- even so, it is not a permissions issue. Stuff is broken. – goldilocks Mar 12 '13 at 8:45
  • No go running commands with sudo. – rebellion Mar 13 '13 at 10:50
  • Install GDB + symbols, and get a backtrace, to see where it SIGSEGVs? – James Bennet Mar 14 '13 at 22:15
  • If "segmentation fault" only occurs when running apt-get your card may not be corrupt. See my answer below. – NULL Mar 8 '16 at 16:46
4

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.

  • 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 7:14
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.

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

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. See this tutorial on using a SD card for booting and USB 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 :)

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.

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.

protected by goldilocks Sep 30 '16 at 0:59

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.