Reinstalling GRUB on SliTaz

Well, the FreeDOS install that shares the disk with SliTaz went barmy, and on reinstall I toasted the MBR so can only boot FreeDOS. Stupid.

Not that hard to fix.

  1. Booted from the SliTaz 4-in-1 CD, same as the one used to install it
  2. Chose my keymap (UK)
  3. Let it boot
  4. Once I had the desktop, opened a terminal window and started a root session:
    $ su

    (the live disc uses ‘root’ as the root password)

  5. Mounted the root (/) partition of the SliTaz install on the HDD:
    # mount /dev/sda3 /mnt
  6. Now, at this point some instructions talk about mounting /proc and stuff and using chroot; this did not need anything so complicated (all the config files were still on /dev/sda3, just the bootloader in the MBR was missing) so first verified the version of GRUB:
    # grub-install --version
    grub (GNU GRUB 0.97)
  7. So you can see that SliTaz uses an older version of GRUB; this is important because the next command is different for versions after 1.98:
    # grub-install --root-directory=/mnt --no-floppy --recheck /dev/sda
  8. Did not throw any errors; great
  9. Rebooted and got a GRUB menu, then dropped through to a menu that allowed me to select FreeDOS or SliTaz
  10. Note: The menu for GRUB1 is in /boot/grub/menu.lst, and you add FreeDOS to it by adding this to the end of that file:
    title FreeDOS
    root (hd0,0)
    chainloader /kernel.sys

Now, this is GRUB instead of GRUB2, which most modern systems will have. GRUB2 would use --boot-directory=/mnt/boot (and has a much more complicated configuration file set up, because we all know that things have to get more complicated instead of remaining simple, because that’s how we can tell progress has happened) but I cannot tell you fort sure that would work, because it’s not what I did.

Caveats:

This approach only works if the software on the install CD matches that in the booted partition, because I am effectively running the install program version that is on the CD, not on the HDD that I am installing it to. I know that this is the exact same CD I installed SliTaz from, and that I never changed the SliTaz install to a different version of GRUB or to some other bootloader. If there are any mismatches, YMMVW (your mileage may vary wildly, up to and including s gyre of flames spewing into the sky).

Other procedures involve mounting the HDD file system and various system directories (like /dev, /proc, /sys and /run) then using chroot to make /mnt the new root of the system. This is the way you would most likely do it if you had GRUB2 installed on the HDD and wanted it to install itself fairly automatically — it would need to be run from the system on the HDD in question, because that meets the programs expectations. As I said, I dunno about installing GRUB2 without chrooting.

SLiTaz is perhaps not the most representative OS.

Note: I am saying HDD because SliTaz is in my case being used on a legacy system with a HDD. I don’t see why it would matter whether it is HDD or SSD.

An explanation

The partition I want to boot (/dev/sda3) is mounted to /mnt , and the live CD can see the drive that partition is on (/dev/sda). So the command tells the installer to write the initial boot stuff to the drive and any other stuff to the mounted file system. That it works is a pleasant surprise, and given how often I futz things up, something that I’ll probably have to use again some time.

 

cor