[Wylug-help] Restoring /boot and MBR
Nigel Metheringham
Nigel.Metheringham at dev.InTechnology.co.uk
15 Jan 2003 17:12:15 +0000
Here's some ideas/notes - don't just follow this stuff blindly!
On Wed, 2003-01-15 at 16:38, Gary Stainburn wrote:
> I've just boobed big time
Yup!
> Can anyone suggest a way of restoring the MBR and partition table and how I
> can rebuild the /boot partition.
OK, unless you have given it a cause to reread the disk, the partition
table in /proc should be accurate.
Take a hard copy of /proc/partition immediately.
Unmount /boot before something nasty happens (disk format is potentially
futzed). I assume that root etc are far enough into the disk to be
safe.
Then if you reckon you have got everything backed up as much as you can,
start fdisk on /dev/hda (do this from multiuser, single user, or a
knoppix or similar boot cd depending on your bravery and/or resources).
It will presumably complain like buggery about the partition table - if
it thinks there is one there and its not right then delete all the bits,
and put the partitions in place using the block counts from
/proc/partitions [NB you are speccing in blocks]
BTW /proc/partitions only gives you the size *not* the start points, so
if you had holes in your partitioning or the partitions are not in order
(ie /dev/hda4 was at the start of the disk) you are going to be
corrupting things totally at this point).
Its worth saving a copy of the actual partition table data "just in
case"
I have heard (only last week) of a tool that derives partition tables
from disk data - ah yes (from the ext3 list):-
Package: gpart
Priority: optional
Section: admin
Installed-Size: 67
Maintainer: David Coe <davidc@debian.org>
Architecture: i386
Version: 0.1h-3
Depends: libc6 (>= 2.2.4-4)
Filename: pool/main/g/gpart/gpart_0.1h-3_i386.deb
Size: 34326
MD5sum: 5e083e52ca013f3f8a83869908aa8330
Description: Guess PC disk partition table, find lost partitions
Gpart is a tool which tries to guess the primary partition table of a
PC-type disk in case the primary partition table in sector 0 is
damaged, incorrect or deleted.
.
It is also good at finding and listing the types, locations, and
sizes of inadvertently-deleted partitions, both primary and logical.
It gives you the information you need to manually re-create them
(using fdisk, cfdisk, sfdisk, etc.).
.
The guessed table can also be written to a file or (if you firmly
believe the guessed table is entirely correct) directly to a disk
device.
.
Supported (guessable) filesystem or partition types:
.
* BeOS filesystem type.
* FreeBSD/NetBSD/386BSD disklabel sub-partitioning
scheme used on Intel platforms.
* Linux second extended filesystem.
* MS-DOS FAT12/16/32 "filesystems".
* IBM OS/2 High Performance filesystem.
* Linux LVM physical volumes (LVM by Heinz Mauelshagen).
* Linux swap partitions (versions 0 and 1).
* The Minix operating system filesystem type.
* MS Windows NT/2000 filesystem.
* QNX 4.x filesystem.
* The Reiser filesystem (version 3.5.X, X > 11).
* Sun Solaris on Intel platforms uses a sub-partitioning
scheme on PC hard disks similar to the BSD disklabels.
* Silicon Graphics' journalling filesystem for Linux.
.
Other types may be added relatively easily, as separately compiled modules.
As for /boot, if you get the partition table back, then mkfs your boot
back again, and either restore it from your backups (from *before* the
accident), or reinstall --force all packages that hit boot - thats the
kernel (including any special ones you use), lilo, grub. Then reinstall
your boot loader (either rerun /sbin/lilo or sacrifice chickens to grub
as appropriate). NB the grub.conf file is on /boot
Hope you get it back...
--
[ Nigel Metheringham Nigel.Metheringham@InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]