Good idea, we are struggling with this.
@Daniel_Phillips
What do you think of this
At this point in this thread I would try about anything!!!
Even this?
or this, which is much the same
Here is a totally different method using the grub> shell
This is a good simple account of using chroot method
https://melp.nl/2011/3/how-to-restore-grub-with-a-live-cd
@Sheila_Flanagan
@Daniel_Phillips
I dont like any of the above links
Here is my method ( completely untested)
You need to boot LM on the hard disk first, then configure and install grub.
So, get rid of all those mounts, and from the live usb system
do
grub
and you should get a grub> shell prompt
Then boot the hard disk LM using the grub shell
grub> set root=(hd0,2)
grub> linux /vmlinuz root=/dev/sda2
grub> initrd /initrd.img
grub> boot
The only reason that might not work is
- no vmlinuz in LM
- no initrd.img in LM
They should be in the root directory
if not, look and see where they are and what they are called
So, when LM boots, login and do
update-grub
grub-install
Thats it, when you reboot you should get a grub menu.
Fingers crossed, I cant test it
My mint 21.3 VM are in /boot, but this is a VM and msdos.
Thanks Daniel,
Shiela might have to modify my recipe to
grub> linux /boot/vmlinuz root=/dev/sda2
grub> initrd /boot/initrd.img
grub> boot
At least Mint has vmlinuz and initrd.img as links. That makes it easy.
I unmounted and removed the mounts. But grub from live session is not recognized.
Whereis grub only points to the live session folders/files. In order to use grub from the restored Linux, I thought it had to be mounted, but maybe not.
Cannot get a grub> shell prompt.
I did try mounting sda2 (/) and chroot but still “Command ‘grub’ not found”
Sheila
Did you do sudo grub.?
It is a superuser command
The other way to get it is to press ‘C’ at the grub menu, if yiur live usb gives a grub menu
So I used a bit different method to update-grub. But still cannot use grub-install as this time I get the same error cannot find EFI directory.
First I mounted root and then:
sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys
I used recursive bind.
Then after chroot
sudo update-grub returned:
sourcing file/etc/default/grub
sourcing file /etc/default/grub.d/50_linuxmint.cfg
sourcing file /etc/default/grub.d/init-select.cfg
Generating grub configuration file…
Found linux image: /boot/vmlinuz-5.15.0-88-generic
Found initrd iamge: /boot/initrd.img-5.155.0-88-generic
And found the remaining vmlinuz & initrd of 5.15.0-87 & 5.15.0-56
Of course, grub-probe only gave error for not finding a GRUB drive for /dev/sdc2 (which is the live linux drive).
So does that mean I did not update grub on the root Linux? The live session files show 5.15.0-91-generic, which I take to mean these older ones (above) are from the LM 21.2 so maybe I did update the correct one.
Thanks,
Sheila
Well, take a punt and do grub-install… it may work
Did you get my answer on how to get grub command?
You need to mount it
grub-install --efi-directory=/mnt
remember that, it needs mount /dev/sda1 /mnt
First, no I did not see that as I was editing my post.
I am still in chroot (after mounting root) and grub-install is throwing cannot find EFI dir again.
I tried sudo with grub-install in chroot. So that is with the root drive mounted.
As for pressing “C” at grub menu, no grub menu at this point. Maybe if I rebooted from the flash drive and start, it does open a grub that gives command prompt. besides running live session.
Well, sheesh. I guess between reading your untested solution etc I did not see to do that. I only mounted sda2. So now I will mount sda1 also to /mnt and still need to be in chroot environment?
See previous reply… the solution to that is simple … dont come out of the chroot, you are nearly there
I did this successfully from chroot. Then I tried again with sudo grub-install but still cannot find EFI directory.
Oh, I did not see the part about pointing to the efi directory. Let me try that.
It did not like
unrecognized option ‘–efi-directory=/mnt’
AH,I had a typo and NOW it installed and finished with no error reported!!
But we did that previously
it must want the target defined
grub-install --efi-directory=/mnt --boot-directory=/media/boot
–target=x86_64-efi
was what we used previously.
Now , in the chroot, we dont need the boot directory because we are in it
so do
grub-install --efi-directory=/mnt
–target=x86_64-efi
I didn’t say so, but that is how I found my typo. I used the same command you first gave and added --target=x86_64-efi /dev/sda1
Then it installed without throwing any errors. I don’t think we have had that happen yet.
But I still need to know how to boot to that install since I cannot get a grub prompt from here.