Hi,
my partiton table is corrupted, And I'm very keen to try the simple
algorithm described in the post bellow [no I'm not a top-poster].
Since my IDE is disabled all I've got to get in is mulinux - loaded from
2 floppies [one for mc - which I can't live without].
But mulinux uses [the more compact] ash shell.
BTW what shell language is the script below ?
As you can see I've 'commented' the script by adding eg.
" = next try @ start sector".
I think this should be part of every one's took box.
Thanks for any help, perhaps also emailed to:
easlab AT absamail . co . za
since this group tends to scroll past me.
== Chris Glur.
----- query inspired by this post below ---------
Newsgroups: comp.os.linux.misc[15]
Date: 2002-11-19 17:43:59 PST
On Tue, 19 Nov 2002 at 21:16 GMT, Paul Lutus wrote:> On Tue, 19 Nov 2002 20:01:47 +0000, Chris F.A. Johnson wrote:
Mandrake 9.0 install CD (I forget exactly why), and all of a
sudden the partitions disappeared, and I was left with one 248MB
partition, and the rest of my drive was empty. The drive had
originally been partitioned more or less the same as I now have
it:
Device Boot Start End Blocks Id System
/dev/hda1 * 1 243 1951866 83 Linux
/dev/hda2 244 487 1959930 83 Linux
/dev/hda3 488 548 489982+ 82 Linux swap
/dev/hda4 549 2498 15663375 83 Linux
And I couldn't boot from that partition.
My backups were not as up-to date as they should have been, so I
had some moments of anxiety. I mapped out a recovery plan in my
head that would minimize the loss if I couldn't restore the drive
and get my work from the last two or three months.
That calmed me down enough to think about the problem. I told
myself that it was only the partition table that was blown away,
and that all my data was still on the drive.
I didn't remember exactly where I had my partitions other than the
first one, comprising sectors 1 to 248. (An ulterior motive for
this post: I will henceforth be able to find my partition
information through Google!) I deleted the one partition and
recreated /dev/hda1. It mounted, and I could see all the files,
but I couldn't boot from it.
I deleted that partition and booted from a Knoppix CD, which gave
me an environment I could work in, and even do some real work if
necessary (newspapers and magazines have deadlines, and I've
forgotten how to compose crossword puzzles without a computer).
I wasn't terribly concerned about the two small partitions; the
large one contained everything that mattered. I knew it started
around sector 500, give or take a hundred.
I called up fdisk, tried starting a partition at 458 (that number
seemed vaguely familiar), saved it, exited fdisk and tried to
mount the partition. It didn't mount.
I called up fdisk again, deleted the partition and tried another
sector. Same thing. After half a dozen tries, I thought: There
must be a better way.
So, I wrote the following script:
n=400
while [ $n -lt 600 ]
do
fdisk /dev/hda > /dev/null 2>&1 << EOT
d = delete
1 = hda1
n = new one add
p = primary type
1 = hda1
$n = next try @ start sector
2498 = last sector of disk
p = print partn-table
w = write partn-table to disk
EOT
mount -t ext2 /dev/hda1 /d1 && exit || echo -e "\aMount failed $n"
(( ++n ))
done
That's how the script ended up after two or three failed attempts
using:
echo -e "d\n1\nn\np....." | fdisk /dev/hda1
I started the script running and went away to cook dinner. When I
came back, the script had exited, the partition was mounted,
starting at sector 549, and all my files were safe! I was drunk
with relief (soon helped along by a few pints in celebration).
I reinstalled MDK 9.0 in the first partition, made a few symlinks,
and my system was as good as before.
The backup script I had been planning to write was soon completed,
and it now runs every morning at 6:00 a.m., tarballs all the files
that have been added or changed in the last 24 hours, and copies
them to another computer, where they are burnt to CD when there is
enough to fill one.
--
Chris F.A. Johnson http://cfaj.freeshell.org [16]