2

Last night, I turned my Raspberry Pi off; now, it doesn't finish booting.

After serveral I/O reading failures it hangs on kbd. I've tried booting with several configurations of no mouse, no keyboard, no hub etc. but it always hangs in the same place.

Could it be a corrupt OS?

nc4pk
  • 1,378
  • 1
  • 13
  • 25
LaurieGould
  • 21
  • 1
  • 2

3 Answers3

4

You've almost certainly caused a corruption to the SD card. Assuming you have a Linux machine you can boot into to do some fixing of the card, you can try this guide to recovery (which I blogged about here: http://www.recantha.co.uk/blog/?p=1208)

First of all, find a computer that you can boot into Linux with that has an SD card slot. Boot into Linux, put the card in.

First, figure out what partition we’re dealing with.

sudo fdisk -l

The above will list all the partitions on all the drives in your computer. To recover a lost partition, your going to need Testdisk. Testdisk is included in Parted Magic, and there’s a great guide on their site. For this though, we just need the partition number, such as /dev/sda3 or /dev/hdb1.

Now, make sure your superblock is the problem, by starting a filesystem check, replacing xxx with your partition name. Here, you can change ext4 to ext3, or ext2 to suit the filesystem.

sudo fsck.ext4 -v /dev/xxx

If your superblock is corrupt, the output will look like this

fsck /dev/sda5
fsck 1.41.4 (27-Jan-2009)
e2fsck 1.41.4 (27-Jan-2009)
fsck.ext4: Group descriptors look bad... trying backup blocks...
fsck.ext4: Bad magic number in super-block while trying to open /dev/sda5
The superblock could not be read or does not describe a correct ext4
filesystem. 

If the device is valid and it really contains an ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:

e2fsck -b 8193 <device>;

Now lets find where your superblock backups are kept.

sudo mke2fs -n /dev/xxx

Down at the bottom of this output, should be a list of the backups

Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

You’re almost there. Finally, restore the superblock from the backup, again replacing the x’s with your partition name, and block_number with the first backup superblock.

sudo e2fsck -b block_number /dev/xxx

Now reboot, and your superblock should be fixed. If it’s not, repeat the steps, but restore a different backup superblock

goldilocks
  • 58,859
  • 17
  • 112
  • 227
recantha
  • 4,489
  • 20
  • 26
  • Presuming the card contains raspbian or similiar, most likely a simple fsck -y /dev/XX2 where XX is the unmounted SD card device will do the trick. Do look at the manpage to understand -y first. – goldilocks Feb 25 '13 at 14:35
  • Thanks for editing it for code formatting - I didn't have time earlier :-) – recantha Feb 25 '13 at 18:44
0

I had this problem several times using an Amazon Basics SD card. I switched cards and the problem stopped happening. After each failure, I had to fully re-image the card and all data on it was lost.

Card that's working for me:

SanDisk Ultra 16 GB SDHC Class 6 Flash Memory Card 30MB/s SDSDH-016G-U46

Edit: Um.. it's working more often, but not all the time.

DonGar
  • 273
  • 1
  • 3
  • 9
0

I had a similar error. Luckily I made a backup a few days ago. After restoring the backup, it worked again like a charm.

How do I backup my Raspberry Pi?

keiki
  • 1,628
  • 1
  • 17
  • 18