Re: Restoring partition table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 28 Oct 2002, [iso-8859-2] Dušan Đorđević wrote:

> Hi all,
>
> I have a huge problem. By accident i deleted partition table on my comp.
> It is still running, but fdisk shows that partition table is wrong. Is
> there any idea how to bring partition list back ? From /proc/partitions
> i have sizes, but problem is that partitions are not in order
> (/dev/hda4 should be at the end of the disk). Also, I have extended
> partitions. Is there any idea how to put everything back. Again, the
> comp is still running, i haven't rebooted it yet.

You do need to know the exact sizes of partitions and the order those
partitions appeared on the disk, but they don't necessarily need to have
the same sequence numbers.  Here's one way that you should be able to
solve your problem.  I am assuming that this is a fairly vanilla
installation with Grub as the boot loader installed in the MBR.

Reboot using your CD1 in rescue mode (i.e., type "linux rescue" at the
first prompt.

When it asks if it should look for an existing Linux, say "no".

Run fdisk (carefully!) to reconstruct the partitions in the exact sizes
and order that they appeared on disk.  If you do remember the sequence
numbers, you can try to create them in the same order as before, but *this
is not important*.  What you do need to do is write down the partition ids
and the mount points they correspond to.  The important mount points are
/boot (if you have it) and /.

If you were able to get the partitions to have the correct ids, then you
should be able to just reboot and go.[1] If not, or if you aren't sure you
got everything the right size, then continue.

If you are using Grub as your boot loader, then it's not too hard from
here.  I would now reboot from the CD in rescue mode.  This time let it
look for an existing Linux installation.  It will tell you that mounted
the various partitions someplace.  If this step fails, then you got the
partition table wrong.  You still haven't damaged anything, but you need
to start over again and repeat until you get it right.  cd to the
directory where the partitions are mounted.

If you look in ./etc/fstab, you should see most all the entries in the
first column are of the form LABEL=...  If any are of the form /dev/hd?,
fix those to have the correct partition number (you will need to do this
for your swap partition, at least).

Edit ./boot/grub/grub.conf.  You will see some references that look like
(hd0,0).  You need to fix the digit after the comma to be your new /boot
partition (or / if you don't have /boot).  Note that fdisk counts
partitions from 1, but grub counts them from 0, so if your /boot was
/dev/hda1, then grub should say (hd0,0).

At this point, you should be ready to reboot live.

You might want to exercise patience before trying anything.  If I made any
mmistakes, hopefully someone will call me out.

This advice comes with no warrantee whatsoever.  If it doesn't work as
intended, I will refund exactly what you paid me for it.

[1] You might want to reboot in rescue mode, skip searching for an
existing Linux, and run e2fsck with the -n option on each partition at
this point.  If they all pass, that's a pretty good indication that you
got them right.  If not, start over.

-- 
		Matthew Saltzman

Clemson University Math Sciences
mjs@clemson.edu
http://www.math.clemson.edu/~mjs



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux