[Wylug-help] There is a god - was Re: Restoring /boot and MBR

Gary Stainburn gary.stainburn at ringways.co.uk
Thu, 16 Jan 2003 16:57:38 +0000


Praise be!!

I now have a perfectly working system again.  Here's a synopsis for all those
who helped, and for the archives for those yet to come.

I managed to splat the 1st 1.4MB of my hard disk by running

dd if=boot.img of=/dev/hda bs=1024

instead of

dd if=boot.img of=/dev/fd0 bs=1024

with the net result that I had just splatted the MBR and the /boot partition.
Other than that I had a happily working system.

Here's a few facts/assumptions I had.

I had a full and up to date backup (I didn't at the point where I cocked up,
but as my machine was still working, I could take one).

I had partitioned the disks with fdisk, placing the partitions in sequence and
left no holes - hda6 followed straight on from hda5.

First I umounted /boot. This partition was stuffed, and I didn't want (know
if) faulty inodes would point to blocks on another partition.

I dumped /proc/partitions to the printer for reference.  I noted that I had
/dev/hda1 size 16033KB,
/dev/hda2 size 1
/dev/hda5 size 72261KB and
/dev/hda6 size 19920568KB

This told me I had 1 primary partition and 1 secondary containing two logical
partitions. I then ran 'mount' which told me
hda1 was /boot
hda5 was swap
hda6 was /

I then used fdisk to rebuild the partition table - i.e.
fdisk /dev/hda
d<cr>1<cr>		# delete faulty primary partitions 1
d<cr>2<cr>
d<cr>3<cr>
d<cr>4<cr>		# through 4
n<cr>p<cr>1<cr>1<cr>+16033K<cr>	# create 1st partition from /proc/partitions
n<cr>e<cr>2<cr><cr><cr>			# create extended part - default full disk
n<cr>l<cr><cr>+72261K<cr>			# create hda5
n<cr>l<cr><cr>+19920568K<cr>		# create hda6
t<cr>5<cr>82<cr>					# set hda5 as swap
w<cr>

By specifying the partition sized in +nK format, the info from the
/proc/partitions didn't need converting to cylinder numbers. Having rebuild
the partition table I could now rebuilt /boot. I ran

mkfs -t ext2 /dev/hda1

and then had the edit /etc/fstab to reference /dev/hda1 instead of the LABEL
before I could mount /boot.  I then rebuilt the contents by running

rpm -i --force kernel-2.4.18-19.7.x.i586.rpm
rpm -e grub
rpm -i grub-0.91-4.i386.rpm

and then copying and editing a suitable /boot/grub/grub.conf.  Finally, I ran

/sbin/grub-install /dev/hda

to re-install the Grub boot loader, crossed by fingers, rebooted, and - lo and
behold - it booted fine.

--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000