[PLUG] grub and fdisk problems mean what?

Daniel Hedlund daniel at digitree.org
Mon Sep 25 10:00:50 UTC 2006


Eric,

I hope you make backups (see more below).


eehouse wrote:
> Disk /dev/hda: 40.0 GB, 40016019456 bytes
> 255 heads, 63 sectors/track, 4865 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/hda1               1           1        8001    1  FAT12
> 
> If I go ahead and mount /dev/hda1 (allowing mount to determine the
> fs type itself) things look ok:

It actually looks like you've hosed (overwritten) your partition table 
somehow.  You said there should be 3 partitions.  There is only one 
partition listed and that maxed out at 8 gigabytes.

If I had to guess about what caused the problem, it might be that you 
(or a script) accidentally selected or typed /dev/hda instead of 
/dev/sda1 when repartitioning/reformatting an external USB drive of some 
description.  Either that or you managed to overwrite your /dev/hda 
partition table with one from an 8 gig external drive.  I highly doubt 
you would've manually repartitioned the hard disk and chose the 
partition layout it's set at.  The final possibility is that part of 
your hard disk just corrupted itself, but if that was the case then 
fdisk would most likely report back that the partition table was corrupt 
and ask you to reinitialize it.


> ubuntu at ubuntu:~$ mount | grep hda1
> /dev/hda1 on /mnt type ext2 (rw)

If /dev/hda1 mounted then it was probably a Linux filesystem.  Your 
partition table above should've read "Linux" under the System column if so.


> And the size and amount of stuff on there look about right:
> But when I try to look at any of the files I get errors:

This is because your partition's start and end blocks are wrong.  Your 
partition was large enough that it was able to read enough of the inodes 
to display the filesystem but probably not enough for the rest of your 
files...not completely sure about how the ext2 filesystem works under 
these circumstances, but you're possibly in big trouble if you write 
anything back to the hard disk (especially the partition was mounted 
read-write above).  If you mount the partition in the future, please 
consider using mount's '-o ro' argument.


> ubuntu at ubuntu:/mnt$ ls /mnt/boot
> ls: /mnt/boot: Input/output error

This probably occurred because the inodes that Linux was looking for 
couldn't be found because they were outside of the partition's geomentry 
(start and end blocks).


> In addition, I can't mount any of the other partitions:

You can't mount any of the other partitions because Linux doesn't know 
where to find the start and end of each partition since they're not 
listed in your partition table (above).


> I don't know much about udev, which this cd is using, but I gather
> that the device files being missing (and they are) could just mean
> that udev didn't notice the partitions (rather than that they really
> don't exist.)

It's not a problem with udev unfortunately.


> Oh, and looking through the logs I found a suggestion that I run
> e2fsck:

I'd be extremely careful and NOT run e2fsck at this point.


> Can anybody suggest what might be going on here, and maybe how to go
> about fixing it?  Is this a situation I could have gotten into by
> installing a new kernel?  Or did my superblock get trashed sometime
> over the 40 days since I last re-booted?

There are some tools you can get that will search your hard disk for 
partition boundaries and try to rebuild any partition tables you might 
have.  Have a look at the following program:
http://www.cgsecurity.org/wiki/TestDisk

The TestDisk software is included on Knoppix and a few other live CDs. 
I'm not sure about Ubuntu's live CD though:
http://www.cgsecurity.org/wiki/TestDisk_Livecd

If the above doesn't work and if you can find a way to get into your 
/dev/hda1's /boot/grub/ directory (which you've already demonstrated 
above that you probably can't), there is a file called 'stage1'.  That 
should be a copy of your MBR/primary partition table.  If you can 
somehow manage to read that file, you should be able to execute 
something similar to:
dd bs=1 count=512 if=/mnt/boot/grub/stage1 of=/dev/hda

Provided the stage1 file is up to date, you *might* have some luck.  It 
probably won't kill things any more than they are.

Cheers,

Daniel Hedlund
daniel at digitree.org



More information about the PLUG mailing list