5

My Raspberry Pi has been hosting a small site from home for a few days, and everything was working fine.

It's completely headless, so I use SSH for everything.

This morning however when I woke up, I was unable to login via SSH, however the site was still functioning fine. I cycled power and tried again- still I was unable to login.

So I connected my Pi to my TV via HDMI and saw the warning in the title:

Unable to mount root fs on unknown-block (179,2)

After that, I inserted my SD card (4GB) into my computer, however in Nemo (Linux Mint 14), only the 59MB (boot) partition shows up.

If I do need to completely wipe the card and put Raspbian Wheezy back on, is there any way I can access the / partition and get my files back (I hadn't made any backups yet)?

Torvero
  • 220
  • 1
  • 2
  • 6

3 Answers3

4

Try the procedure I discovered that I wrote about on my blog: on my blog

I've copy and pasted here: This has happened to me a few times, and it’s not a nice problem to find yourself in. You computer won’t boot, all your filesystem checks tell you you’ve a bad superblock, but you cant seem to find how to fix it. Well, here goes

This guide is for ext4 , though I’ll explain how other filesystems can be cured along the way. The easiest way to carry all this out, seeing as your computer probably won’t boot at this stage, is to download and burn a copy of Parted Magic. Boot from that, and you’ll access to a number of useful tools.

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 let's 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.

techraf
  • 4,254
  • 10
  • 29
  • 41
recantha
  • 4,469
  • 18
  • 26
  • At first, this wouldn't work, however later on after formatting the SD card, I realized it was because I supplied the wrong partition name. I'll keep this bookmarked though in case something similar happens in the future. – Torvero Jan 06 '13 at 16:32
  • Excellent advice. Just followed it to the letter and got my troublesome SD card working again. Used a free `SystemRescueCd` on a USB stick that I just happened to have instead of `Parted Magic`. Thanks! – Ghanima Nov 25 '14 at 20:41
2

Despite its name, photorec is a quite generic tool to recover many types of files on a lost partition. I'm assuming "web site" means you need to recover text config files.
Use it before overwriting your data with a new image.

photorec is packaged with testdisk on debian. Should be lurking somewhere on Mint.

M Noit
  • 36
  • 1
  • Thanks, I was able to restore a large number of my files, but not all. I'll reformat the SD card and put Raspbian Wheezy back on. Even though I didn't get all my files back, it's definitely been a good experience for me and I'll put backups higher on my priority list. – Torvero Jan 06 '13 at 16:16
0

This panic problem occurs mostly because of not well formatted or incorrect partitions (of the SD card).

This can be solved using GParted software, which formats the SD card in a correct manner.

Greenonline
  • 2,448
  • 4
  • 18
  • 33