Knoppix rescue of Linux Laptop

n1vux on 2006-09-24T03:15:19

My Linux laptop (thinkpad) was NFG for 24 hours, with GRUB Error 17. [Duration was unrelated to severity, just I had other things to do after I noticed the issue. ]

Problem was caused by shutting down hard (power switch) during boot (due to real life intervening). Apparently I powered down at exactly the wrong moment during boot ...

Error 17 means the MBR was read ok, but the /boot filesystem is NG, format not recognized. Loosely translated, this means /boot superblock was corrupted.

Why would shutdown write a superblock? Mis-calculated dirty-buffer flush, maybe? Who knows what hardware does when power is removed? sigh

Wasn't really all that hard to fix, once I dug around ... finding the RIGHT args for the FSCK to not fsck-up, of course ... but getting to the point where I could FSCK at all was awkward.

Google for Error 17. (Of course I have alternate computers. This does help.)

Boot Knoppix 5 DVD from UK Linux (Pro) Magazine.

See that /dev/hda2 and /dev/hda4 are auto-detected, have icons on Knoppix desktop.

HDA2 is clean. HDA3 is swap (/mnt/hda2/etc/fstab agrees it should be), but where's /dev/hda1 => /boot ? FSTAB says it should be ext3 on hda1.

Gpart can't guess, it's says everything is 0 size. That's helpful. Just helpful. Can't gpart find and use default alt-superblocks in its heuristics ???

Knoppix didn't even create a block device for hda1 since it wasn't automountable. So I had to # cd dev # ls hda* # see hda hda2 hda4 all looking similar # man mknod # haven't used this command in YEARS !! # mknod b 3 1 hda1 # follow pattern # chown root:disk hda1 # chmod g+w,o-r hda1 to match the others.

Once I did that, it still won't mount -r; it informs me it's got a bad superblock (as I'd figured).

And FSCK refuses to do anything with bad superblock either.

I had to read the Man page to find out the default backup-superblock position for a 1K block size, and then ask it "are you 1k blocksize" by doing # fsck.ext3 -b 8193 -B 1024 -n /dev/hda1 to see if it was a 1k blocksize /boot, in which case it would have simple errors, or if (since /vmlinux is a big file) someone made it 2k or 4k block, that would die gloriously and I'd try the other default -b's for -B 2024 and -B 4096. Since it was ok but for block 3 on 6+ pass, I ran it for real. # fsck.ext3 -b 8193 -B 1024 -n /dev/hda1 It prompted to ignore a read error and prompted to re-write superblock.

So then I # mount -t /dev/hda1 /mnt/hda2/boot and poke around to see that it looks good. Ok, time to try booting again.

Then I remembered to # umount /mnt/hda2/boot before # umount /mnt/hda2 so we're clean, and before shutdown Knoppix for reboot and remove DVDrom ... and see Grub choice menu come up.

Yeah! Knoppix wins again!

I'm glad that worked, since I'm still not sure how to mount the several volumes in /dev/hda4 via LVM from Knoppix, if I'd had to rescue my data. Knoppix 5 has an LVM command, but ...