fdisk to edit partition table: help please

fdisk to edit partition table: help please

Post by KS » Thu, 30 Aug 2001 09:18:57



I have a dual partition Pentium II with 8GB IDE hard drive with RedHat
v5.2, and my lilo recently stopped working (due to a foolish upgrade on
my Win OS) --> as I describe below my partition table seems to have
gotten messed up. My RedHat rescue disk does not seem to function (the
PC just freezes up after spinning the floppy). At this point I am
just trying to salvage some files and then re-install if needed.

I got a hold of  tomsrtbt v 1.7.358. When I try and mount my linux
partition I have problems. No problem mounting the Win partition (hda)
but when I try and mount Linux (hdb) I get:
# mount /dev/hda2 /test2
/dev/hda2: Unknown error
...
Transaction block size = 512
VFS: Can't find a valid MSDOS filesystem on dev 3:02.
mount: you must specify the filesystem

More information on the file system does not seem to help:
# mount -t ext2 /dev/hda2 /test2
attempted to access beyond end of device
03:02: rw=0, want=2, limit=1
EXT2-fs: unable to read superblock
mount: wrong fs type, bad option, bad superblock on /dev/hda2,
        or too many mounted fule systems

When I first fdisk I get:
# fdisk /dev/hda
The number of cylinders for this disk is set to 1025.
This is larger than 1024, and may cause problems with:
1) software that runs at boot time (e.g., LILO)
...

Also, when I print the partition table I get,
# fdisk -l
Warning: invalid flag 0x0000 of partition table 5 will be corrected by
w(rite)

Disk /dev/hda: 255 heads, 63 sectors, 1025 cylinders
Units = cylinders of 16065 * 512 bytes

Device    Boot  Start   End     Blocks          Id      System
/dev/hda1 *     1       262     2096608+        6       DOS 16-bit >=32M

Partition 1 does not end on cylinder boundary:
        phys=(519, 127, 63) should be (519, 254, 63)
/dev/hda2       262     514     2028096         5       Extended
Partition 2 does not end on cylinder boundary:
        phys=(1022, 127, 63) should be (1022, 254, 63)
...

Finally, here is some more details:
# rescuept /dev/hda

# total size 16481808 sectors
unit: sectors
# 2047 MB       fat partition (type 6): sectors              63-
4193279
# sector 4209351 looks like an ext2 superblock copy #1;
# in a partition covering sectors 4192965-4514264
# found all preceding superblocks OK
# Warning: overlapping partitions?
#  157 MB       ext2 partition (type 83): sectors       4192965-
4514264
# 1945 MB       ext2 partition (type 83): sectors       4514265-
8498384
#    0 MB       candidate ext pt (type 5): sectors      8498385-
8498385
#  133 MB          found in ept (type 82): sectors      8498448-
8771489
#  204 MB          found in ept (type 83): sectors      8771489-
9189179
# 3004 MB          found in ept (type 83): sectors      9189243-
15342074
#  518 MB          found in ept (type 83): sectors     15342138-
16402364
# 3859 MB       extended part ok (type 5): sectors      8498385-
16402364
/dev/hda0 :  start=      63, size= 4193217, Id= 6
/dev/hda0 :  start= 4192965, size=  321300, Id=83
/dev/hda0 :  start= 4514265, size= 3984120, Id=83
/dev/hda0 :  start= 8498385, size= 7903980, Id= 5
/dev/hda0 :  start= 8498448, size=  273042, Id=82
/dev/hda0 :  start= 8771489, size=  417627, Id=83
/dev/hda0 :  start= 9189243, size= 6152832, Id=83
/dev/hda0 :  start=15342138, size= 1060227, Id=83

Pretty clearly there is something wrong as the windows partition (type
6) is overlapping with the next partition (type 83).

Anyway, I was told by a guru to "use fdisk to edit your partition table
to those beginnings and  endings [listed in rescuept], and then try to
mount the filesystems, in the most brute force approach." As a newbie
this is all beyond me --> I could not figure out from the man page or
messing around with the fdisk menu how this is done. Does anyone have
any suggestions (perhaps using an example with the type 82 partitions
above) on how to proceed?

Thanks in advance,
Koleman

 
 
 

fdisk to edit partition table: help please

Post by dino de » Thu, 30 Aug 2001 11:27:14



> I have a dual partition Pentium II with 8GB IDE hard drive with RedHat
> v5.2, and my lilo recently stopped working (due to a foolish upgrade on
> my Win OS) --> as I describe below my partition table seems to have
> gotten messed up. My RedHat rescue disk does not seem to function (the
> PC just freezes up after spinning the floppy). At this point I am
> just trying to salvage some files and then re-install if needed.

  this is a side issue but related:

  to make a reliable , bootable rescue disk for Linux how do we do that and
also add onto it the partition table and boot record and other such
information.  Corruption of partition tables seems so easy to do since
Linux newbies often have to experiment with fips and fdisk and druid.

thanks

 
 
 

fdisk to edit partition table: help please

Post by Eric » Thu, 30 Aug 2001 16:56:53


Don't crosspost to so many groups.

Quote:> I have a dual partition Pentium II with 8GB IDE hard drive with RedHat
> v5.2, and my lilo recently stopped working (due to a foolish upgrade on
> my Win OS)

Then your partitiontable mst have been incorrect before this.

Quote:>--> as I describe below my partition table seems to have
> gotten messed up. My RedHat rescue disk does not seem to function (the
> PC just freezes up after spinning the floppy). At this point I am
> just trying to salvage some files and then re-install if needed.

Let's see what can be done.

Quote:> I got a hold of  tomsrtbt v 1.7.358. When I try and mount my linux
> partition I have problems. No problem mounting the Win partition (hda)
> but when I try and mount Linux (hdb) I get:
> # mount /dev/hda2 /test2
> /dev/hda2: Unknown error

bizarre error, not very helpfull I admit.

Quote:> Transaction block size = 512
> VFS: Can't find a valid MSDOS filesystem on dev 3:02.
> mount: you must specify the filesystem

> More information on the file system does not seem to help:
> # mount -t ext2 /dev/hda2 /test2
> attempted to access beyond end of device
> 03:02: rw=0, want=2, limit=1
> EXT2-fs: unable to read superblock
> mount: wrong fs type, bad option, bad superblock on /dev/hda2,
>         or too many mounted fule systems

> When I first fdisk I get:
> # fdisk /dev/hda
> The number of cylinders for this disk is set to 1025.
> This is larger than 1024, and may cause problems with:
> 1) software that runs at boot time (e.g., LILO)
> ...

> Also, when I print the partition table I get,
> # fdisk -l
> Warning: invalid flag 0x0000 of partition table 5 will be corrected by
> w(rite)

> Disk /dev/hda: 255 heads, 63 sectors, 1025 cylinders
> Units = cylinders of 16065 * 512 bytes

> Device    Boot  Start   End     Blocks          Id      System
> /dev/hda1 *     1       262     2096608+        6       DOS 16-bit >=32M

> Partition 1 does not end on cylinder boundary:
>         phys=(519, 127, 63) should be (519, 254, 63)
> /dev/hda2       262     514     2028096         5       Extended
> Partition 2 does not end on cylinder boundary:
>         phys=(1022, 127, 63) should be (1022, 254, 63)
> ...

A very inconsistent table.
Are you sure you posted the correct numbers?
especially the ending cyl. boundaries are inconsistent.

- Show quoted text -

Quote:

> Finally, here is some more details:
> # rescuept /dev/hda

> # total size 16481808 sectors
> unit: sectors
> # 2047 MB       fat partition (type 6): sectors              63-
> 4193279
> # sector 4209351 looks like an ext2 superblock copy #1;
> # in a partition covering sectors 4192965-4514264
> # found all preceding superblocks OK
> # Warning: overlapping partitions?
> #  157 MB       ext2 partition (type 83): sectors       4192965-
> 4514264
> # 1945 MB       ext2 partition (type 83): sectors       4514265-
> 8498384
> #    0 MB       candidate ext pt (type 5): sectors      8498385-
> 8498385
> #  133 MB          found in ept (type 82): sectors      8498448-
> 8771489
> #  204 MB          found in ept (type 83): sectors      8771489-
> 9189179
> # 3004 MB          found in ept (type 83): sectors      9189243-
> 15342074
> #  518 MB          found in ept (type 83): sectors     15342138-
> 16402364
> # 3859 MB       extended part ok (type 5): sectors      8498385-
> 16402364
> /dev/hda0 :  start=      63, size= 4193217, Id= 6
> /dev/hda0 :  start= 4192965, size=  321300, Id=83
> /dev/hda0 :  start= 4514265, size= 3984120, Id=83
> /dev/hda0 :  start= 8498385, size= 7903980, Id= 5
> /dev/hda0 :  start= 8498448, size=  273042, Id=82
> /dev/hda0 :  start= 8771489, size=  417627, Id=83
> /dev/hda0 :  start= 9189243, size= 6152832, Id=83
> /dev/hda0 :  start=15342138, size= 1060227, Id=83

> Pretty clearly there is something wrong as the windows partition (type
> 6) is overlapping with the next partition (type 83).

The rest appears to be pretty conisistent though.

Before you continue, find all partitions cylinder boundaries.
hda1 just starts at cyl 1
hda2 starts at (4192965/(255*63)=) cylinder 261
(this means hda1 must end on cylinder 260)
hda3 starts at (4514265/(255*63)) cylinder 281

continuing this you can find the table in cylinders:
hda1 1 260
hda2 261 280
hda3 281 528
hda4 529 1021       <<<<<<odd, you have left 4 cylinders unpartitioned
hda5 529 543

from now on it get's weird: don't recreate the rest yet.

hda6 start is off by one sector, end is even further off from a cyl boundary
hda6 544  571

hda7 start and end are off boundaries
hda7 572 954

hda8 start is still off, hda8 end is okay again.
hda8 955 1021

Now you have two options, both can destroy important data.
Either use the cylinder values, (some are a bit off, and may destroy data)
or use the sector offsets (cfdisk accepts sector offsets) (man cfdisk)
But if rescuept is a bit off, this could also destroy data.

The safest thing to do first is recover all data you want to recover:

use a good rescuesystem that supports loopback mounting (superrescue CD eg)
I'm not sure if tomsrbt does. The follow the following steps:

first calculate BYTE_OFFSET by using the sector ofsets rescuept provided.

eg. BYTE_OFFSET=4192965*512 to calculate the offset for hda2 (your /boot I
assume)

now use this number in:
/sbin/losetup -o BYTE_OFFSET /dev/loop0 /dev/hda

try to mount hda2

mkdir /mnt/rescue
mount -t ext2 -o ro /dev/loop0 /mnt/rescue

and see if /mnt/rescue now contains the data of your /boot
If so copy what you really need to keep from it (not much on /boot I suppose
other mountpoints are probably more interesting)

umount /mnt/rescue
/sbin/losetup -d /dev/loop0

Now you can do the same for the other partitions.(skip hda4 as it's the
extended)
If you are done, and have backupped what you need, you can restore the
table.
If all partitions mounted without problems, use cfdisk, 'cause then the
sector
offsets are correct.

Let us now if you succeeded.

Eric

 
 
 

fdisk to edit partition table: help please

Post by M. Buchenried » Thu, 30 Aug 2001 15:55:21


Note: FollowUp ignored because of invalid newsgroup

[...]

Quote:>  to make a reliable , bootable rescue disk for Linux how do we do that and
>also add onto it the partition table and boot record and other such
>information.  Corruption of partition tables seems so easy to do since
>Linux newbies often have to experiment with fips and fdisk and druid.

Usually the rescue system of your distribution's installation
CDROM will do just fine. Of course you'll need a copy of your
partition table. I prefer keeping a hard copy around - which you
can easily crate by typing

fdisk -l /dev/hda  > /root/table_hda

This will create a file called "table_hda" in your /root
directory. Now all you need to do is to send that file to
your printer.

Sidenote: Please stop using col.questions - this is an obsolete
and invalid group, which should have been deleted years ago.

Michael
--

          Lumber Cartel Unit #456 (TINLC) & Official Netscum
    Note: If you want me to send you email, don't munge your address.

 
 
 

fdisk to edit partition table: help please

Post by M. Buchenried » Thu, 30 Aug 2001 15:40:43


[Non-existant newsgroups removed]
[Please note that col.help and col.questions have been
voted out of existance more than 6 years ago]
[Kick your newsadmin to synchronize the list of active
newsgroups in Big8 with the official list from isc.org]

[...]

Quote:># mount /dev/hda2 /test2
>/dev/hda2: Unknown error

[...]

No surprise, as ...

Quote:>/dev/hda2       262     514     2028096         5       Extended

the partition in question is an extended partition. You can't mount it.

[...]

Quote:>/dev/hda0 :  start=      63, size= 4193217, Id= 6
>/dev/hda0 :  start= 4192965, size=  321300, Id=83
>/dev/hda0 :  start= 4514265, size= 3984120, Id=83
>/dev/hda0 :  start= 8498385, size= 7903980, Id= 5
>/dev/hda0 :  start= 8498448, size=  273042, Id=82
>/dev/hda0 :  start= 8771489, size=  417627, Id=83
>/dev/hda0 :  start= 9189243, size= 6152832, Id=83
>/dev/hda0 :  start=15342138, size= 1060227, Id=83

Hmpf. If you want to believe that output, you could
indeed simply use fdisk to recreate these partitions.
That would be 5 Linux ext2 partitions, the DOS partition and
a swap partition. "fdisk /dev/hda" , then "m" to get a command
listing. Be aware that you should print out the output of
rescuept, since you'll possibly have to delete the existing
partition table prior to being able to use fdisk to create
a new one.

Since your problems arose from installing Win* on that disk,
I would assume that the partitioning scheme wasn't really
correct from the very beginning, as Win* shouldn't even see
your Linux partitions at all. Once you managed to save the
data needed from these partitions, you'd be better off deleting
all partitions and starting from scratch, otherwise you are
possibly doomed to go through the same process again sometime in
the future, in case Win* and Linux have different ideas on what the
layout of your harddisk should be.

Michael
--

          Lumber Cartel Unit #456 (TINLC) & Official Netscum
    Note: If you want me to send you email, don't munge your address.