> Over the years I could not count the number of times that one of
> my machines which uses lilo has lost its boot sector. I use grub now
> sda2. I followed these steps:
> mkdir /sda2
> cp /sda2/boot/vmlinuz /boot
> mount /dev/sda2 /sda2
> mount --bind /dev /sda2/dev
> /dev/sda2/sbin/lilo -r /sda2
> umount /sda2
> and the affected machine was able to boot.
> What would you have done apart from switching to grub?
Backing up the boot sector (mental note, back up my boot sectors) to a
filesystem -- I prefer / to make it easy to find -- each time it changes
would reduce your recovery to...
dd if=/boot.sector.backup of=/dev/sda bs=512 count=1
I would back it up only to a filesystem on the hard drive where it
exists. The usual considerations for backups motivating a separate drive
or off site copy don't apply. You want only the most recent (non-corrupt
-- a gotcha there?) bytes. If the drive goes, the root file system
corrupts or is wiped, or if your apartment burns down then the sector is
no longer useful.
Using grub the backup is slightly more complicated. Its first stage
lives where exactly? Somewhere between the MBR boot sector and the
first sector of the first partition? So dd out some number of the first
N sectors up to but not including the beginning of the first partition?
Or up to and including its PBR if you use and want to preserve that?
Off by one errors here could be really annoying.
One thing I've been doing is to make each operating system on my disk
boot from its PBR if possible. So Slackware 14.2 (I have 15.0 on
another machine with no multibooting and a GPT partition table) boots
with lilo from its PBR. Grub is set up from Debian using all the gunk
they have to detect everything and create boot entries, these being
bootable directly from the Grub installed in the MBR + early sectors.
My custom Grub configuration includes chain loaders to Slackware and
NetBSD's PBR bootloaders. I also have an inactive Grub configuration on
the Slackware partition that is, I hope, more or less up to date, in
case I erased Debian. The Slackware PBR would be bootable with a simple
fdisk /mbr and active flag if needed. Once into the Slackware area (via
lilo on the PBR) I could run grub-mkconfig to get the other things
booting again. So there's some redundancy but probably too much
There's also grub-mkrescue.
- Mike Sm.