Steve Litt <slitt@???> wrote:
> Simon Hobson <linux@???> wrote:
>> 1) use grub rescue cd (which you can put on a USB stick). Then fairly
>> easy to sort out by picking the right menu options.
>
> Do you mean:
>
> * Super Grub2 Disk (https://sourceforge.net/projects/supergrub2/)
> * boot-repair-disk (https://sourceforge.net/p/boot-repair-cd/home/Home/)
> * System Rescue CD (http://www.system-rescue-cd.org/)
> * GrubEFIReinstall (https://wiki.debian.org/GrubEFIReinstall)
> * Ultimate Boot CD (http://www.ultimatebootcd.com/)
The first one, SuperGrub2 - more details at
https://www.supergrubdisk.org
And step-by-step guide at
https://www.supergrubdisk.org/wizard-restore-grub-with-super-grub2-disk/
I suspect the others would also be suitable, but not ones I've used (for this)
fsmithred via Dng <dng@???> wrote:
> Steve Litt wrote:
>> Simon Hobson <linux@???> wrote:
>
>>>
>>> 2) use these incantations, lifted from a post elsewhere :
>>>
>>> mkdir /sysroot
>>> mount /dev/your-root-dev /sysroot
>>> mount /dev/your-boot-dev /sysroot/boot
>>> mount --bind /dev /sysroot/dev
>>> mount --bind /sys /sysroot/sys
>>> mount --bind /proc /sysroot/proc
>>> mount --bind /run /sysroot/run (recommended if you are using systemd)
>>> chroot /sysroot
>>> grub-install /dev/your-grub-boot-device (may be grub2-install on some
>>> distro)
>> *Exactly* what do you mean by "your-grub-boot-device"? Does it vary
>> depending on MBR vs UEFI?
>
> Yes, it varies depending on BIOS vs. UEFI boot. For bios boot, the grub boot device is the drive whose mbr you want to use, like /dev/sda or /dev/sdb.
>
> For UEFI, you don't name the device. Grub knows to put the bootloader in the efi partition. In that case, an extra step above would be to mount the efi partition to /sysroot/boot/efi
>
>> So now you've installed Grub(2), but then how do you configure grub?
>
> While you are still in the chroot, run:
>
> update-grub
>
> And that will make a new boot menu.
Beat me to it ;-)
This option will re-install Grub as long as you can boot the system from any disk containing a vaguely similar Linux - when you chroot you'll be using the tools/executables/etc from your "broken" system while running the kernel from your recovery system.
So lets say you can boot a system from sda, and your "broken" one is currently showing as sdb - with boot as sdb1 and root as sdb2. the relevant lines from above would then become :
mount /dev/sdb2 /sysroot
mount /dev/sdb1 /sysroot/boot
...
grub-install /dev/sdb
And as fsmithred says, you can add update-grub to update the menu - this will work just as if you'd really booted from sdb.
As to which method is "best", well that's a case of "horses for courses"* I've used both methods in the past (not for some time though). The first method is providing the bootable system and providing some assistance with the second method - probing disks, creating (IIRC) the chroot environment, etc. If you are able to boot the system then the second method is just a few commands (which you can do remotely, eg via SSH, if required); if you can't already boot the system at all then you'll need the boot disk to get it running.
* A phrase meaning to pick the tool best suited for the job. Literally it's referring to the fact that different race horses will perform best at different courses (or under different conditions) so you pick the one that's best suited for the course/conditions.
https://en.wiktionary.org/wiki/horses_for_courses