Post by rootor grub-install, whatever.
Since I almost always use Grub, I would likely try this:
grub-install --recheck --boot-directory <path to root> <boot device>
Here's a scenario:
-You have a Slackware installation which no longer boots. You believe
this to be due to a damaged boot sector.
-You boot a different Slackware installation in such a way that you
can "see" the device of the broken Slackware. I would do this using
Slackware on a bootable flashdrive, but I imagine this could be done in
other ways.
-You find your broken Slackware installation at /dev/sda1, and you
mount it at /mnt/to.
-Wipe the boot sector. This is a precaution and may not be needed:
dd if=/dev/zero of=/dev/sda bs=512 count=1
-This will install Grub to the MBR of /dev/sda (not /dev/sda1 !):
grub-install --recheck --boot-directory /mnt/to /dev/sda
Here is some discussion:
-I'm using "--boot-directory /mnt/to" instead of
"--boot-directory=/mnt/to". I think the syntax you will find in
documentation is the latter, but it seems I have been successful in using
a different syntax.
-I think you can actually use "/dev/sda1" for <boot device>, but I'm
not sure. I don't ever do that, and I think there is a reason. I think
if you did, then your BIOS wouldn't see the boot instructions when it
boots your system. Perhaps the use of /dev/sda1 would be useful for
"boot chaining".
-For this to work in a "turn key" fashion you will need a Grub
configuration file. Grub exects to find it in the directory named by
"--boot-directory" at "boot/grub/grub.cfg". For example, in the above
scenario that would be here:
/mnt/to/boot/grub/grub.cfg
I think you can still boot without a grub.cfg file, but you will need to
know what to type at the Grub command line. That is a very interesting
and useful subject, but I will not address it here.
Here is a sample grub.cfg file with one stanza (0):
default='0'
timeout='3'
menuentry 'Slackware Linux on prodesk'{
ROOT=220506aa1Drive
search --label --set root $ROOT
echo 'Loading Linux kernel ...'
linux /boot/vmlinuz-generic ro root=LABEL=$ROOT \
rootfs=ext4 quiet
echo 'Loading initial ramdisk ...'
echo 'Starting Slackware Linux ...'
initrd /boot/initrd.gz
}
This assumes the root that you are booting has an ext4 filesystem and a
LABEL of "220506aa1Drive". And it assumes you have a suitable initrd.gz
at (per the above scenario) /mnt/to/boot/initrd.gz. Of course the use of
an initrd.gz is not always needed--this is the subject of another
discussion. If yours is not needed, just omit that line from the
corresponding stanza.
Also I recommend, although it isn't always needed, that your fstab (at /
mnt/to/etc/fstab in the above scenario) refers to the devices to mount
and use as swap by LABEL= names like this:
LABEL=220506aa1Drive / ext4 defaults,noatime,errors=panic 0 1
LABEL=220506aa2Swap swap swap defaults,noatime 0 0
Per this example, you will need to give your swap partition a label of
"220506aa2Swap", and I already mentioned above that you need to give the
root partition a LABEL also. The other details of your fstab are, of
course, up to you!
Note that the LABEL syntax is not always needed in either of the fstab
file nor the grub stanza, but I will not discuss the exceptions here.
What I have described is not always the least work to setup, but for me
it is the most robust and understandable way.
If you're going to use Grub you will beneifit from knowing:
-The above scenario defines a 3 second timeout. That means when
booting you have 3 seconds to press a key to interupt the booting.
-Once interupted you can:
-Use the up and down arrows to choose other stanzas, if any.
-Press "e" to make temporary edits to the booting instructions or
"c" to get a Grub command line. The "escape" key returns you to the Grub
menu.
-Press the "enter" key to run the selected stanza.
I hope this helps!
-Joe