Page 1 of 1

[SOLVED] Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 10:29
by skylion
So I was dual-booting mageia 6 and windows 7 on my machine and after a while the win7 install was so bloated that i had to reinstall it ... forgetting that it would replace GRUB.
So I was wondering if it was possible to reinstall GRUB through the GNOME live DVD or if It would be better just to reinstall mageia and install GRUB that way.

Thanks in advance! :D

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 13:08
by gohlip
State if grub is grub-legacy or grub 2.
Then if system is UEFI or bios-legacy.
Methods are different.
Provide "parted -l" (as root, and small 'L') if possible, if not details of partitions, including stating if there is a separate boot and where it is).

Yes,it is possible, but we need details.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 13:40
by skylion
Thanks for answering.
My GRUB is GRUB2 and the system is bios.

This is my partition table on the HDD:
/dev/sdb1 500MB NTFS System reserved partition
/dev/sdb2 292 GB NTFS windows install partition
/dev/sdb3 75 GB NTFS partition for storage
/dev/sdb5 88 GB ext4 Mageia 6 partition
/dev/sdb6 8 GB swap partition

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 14:43
by gohlip
Boot up livecd, at terminal, and I assume primary drive is your (current) sdb [not sda]
first verify that disk is sdb (not sda or sdc) with one of (root may be required)
parted -l
lsblk -f
blkid


Then assuming sdb (change below if otherwise) and commands in root
Code: Select all
mount /dev/sdb5 /mnt
grub2-install --boot-directory=/mnt/boot /dev/sdb


Again reminder that the drive that Mageia is is the primary drive, and if drive is shown as sda, then everything is sda. To be clear, if shows sda, then

Code: Select all
mount /dev/sda5 /mnt
grub2-install --boot-directory=/mnt/boot /dev/sda


Hope this is clear.

Not finished yet.
After booting up to Mageia (your windows is not bootable yet as it is a fresh reinstall)
at rebooted Mageia, as root
Code: Select all
grub2-mkconfig -o /boot/grub2/grub.cfg


Good luck.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 16:28
by skylion
/dev/sda is another hdd that I use for backup in case anything breaks.

The grub2-install command didn't work.
It printed out an error saying that /usr/lib/grub/i386-pc/modinfo.sh didn't exist.
The /usr/lib/grub directory doesn't exist at all on the dvd but on my mageia partition it does including the modinfo.sh file.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 17:02
by isadora
Did you run this as root?

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 17:26
by gohlip
skylion wrote:/dev/sda is another hdd that I use for backup in case anything breaks.
.
.

The grub2-install command didn't work.

If you had run this as root, (and you should have said earlier you have a hdd as sda)
gohlip wrote:....and I assume primary drive is your (current) sdb [not sda]

Then your primary drive is not your Mageia drive but the hdd that you use for backup.

So repeat commands, again (each time booting up) checking what your mageia partition, is it sdb5 or sda5. Don't assume it will be the same (sdb5) each time you boot up.
So the commands this time will be...
Code: Select all
mount /dev/sdb5 /mnt
grub2-install --boot-directory=/mnt/boot /dev/sda

note /dev/sdb5 and /dev/sda
or
(if Mageia drive is sda)
Code: Select all
mount /dev/sda5 /mnt
grub2-install --boot-directory=/mnt/boot /dev/sdb

note /dev/sda5 and /dev/sdb


[edit] - it not a good thing where the OS drive is not the primary drive.
backup drives should not be the primary drive.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 17:58
by skylion
I ran lsblk and my mageia partition was /dev/sdb5.
after that I ran:
$ su
# mount /dev/sdb5 /mnt
# grub2-install --boot-directory=/mnt/boot /dev/sda
then the same error appeared, I also tried
# grub2-install --boot-directory=/mnt/boot /dev/sdb
but again the same error appeared.
Also how do I change /dev/sdb to be my primary hdd? In my boot sequence sdb comes before sda.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 19:14
by gohlip
# mount /dev/sdb5 /mnt
# grub2-install --boot-directory=/mnt/boot /dev/sda


The error is indeed strange. Perhaps Mageia install dvd does not come with grub2 package, which is possible based on your error message and Mageia being grub-legacy centric.

/usr/lib/grub directory doesn't exist


I can only suggest you install the grub packages in the live cd OS (please look it up what the grub2 packages you require, you don't need grub-efi and that stuff) and then
repeat the commands again.

Right now, I'm rushing this message for you and hope hope you can find the packages yourself.
But a point I want to make for grub install in bios-legacy (your case) is that you can do the 'grub-install commands to all the devices without problem, just get the Mageia partition correctly.
meaning if mageia partition is indeed /dev/sdb5, you can grub-install to /dev/sda, dev/sdb, dev/sdc...... without fear of any issue.


As to your point of hdd being the primary, let's handle this separately, we'll fix it after we've done your boot.
It is not critical or germane to the problem you are having now.

Good luck. Wish you get fixed soon. Cheers.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 3rd, '17, 19:22
by gohlip
Another quick note. while we search for Mageia grub packages. (it has its own different names for grub packages and I don't want to get it wrong).

What I want to say is that you can use any OS install media that comes with grub packages; don't need to be Mageia; and use the commands, the commands for most linux OS is grub-install (not grub2-install) and grub-mkconfig, not grub2-mkconfig.
Just get the directories right; Mageia is in /boot/grub2/; other OS is /boot/grub/,and /boot/efi not boot/EFI..

Right, mageia package names are just 2.
grub2
grub2-common.

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 4th, '17, 13:28
by skylion
Sorry for such a late reply but it worked!
After Installing the 'grub2' package the grub2-install command worked without any errors. And the grub2-mkconfig command didn't output any errors either.
Thanks for the help! :D

EDIT: umm.. how do I mark this as [SOLVED] ?

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 4th, '17, 13:53
by isadora
You can do so, by editing the subject/title in the first message in this topic.
Write [SOLVED] to the left of subject/title, thanks ahead. ;)

Re: Reinstalling GRUB from live dvd

PostPosted: Sep 4th, '17, 14:56
by gohlip
Good to hear and you're welcome.

Now as promised, your primary drive. For sata drives and cables, all we need to do is to reverse the cables. connect the cable to the hdd to the Mageia drive and vice versa and you're good to go.
However, before doing so, make sure you have the bootloader (grub) set to the the Mageia drive as well before doing it, as the Mageia drive will become the "sda" and the primary drive, as we know now, needs a bootloader in the mbr.

As mentioned earlier we can 'grub-install' (grub2-install) to all devices. So do this first (doing again is no problem) before changing the sata cables. When booted to Mageia,
Code: Select all
# grub2-install /dev/sda
# grub2-install /dev/sdb


where sda is the hdd
and sdb is the Mageia drive.

After changing the cables, check if Mageia drive is now the 'sda' by the usual
fdisk -l
parted -l
blkid
lsblk -f

ps: if it is not sata, but ide drives and cables, different way (change master and slave jumpers in each drive).
sata cables are red, about 15 mm wide; ide cables are white/grey about 2 inches wide.

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 12th, '18, 04:57
by waferhead
Just ran into this myself while upgrading to a larger hard drive.
got the same "/usr/lib/grub/i386-pc/modinfo.sh didn't exist"

The problem is the version of grub2 actually installed on the live filesystem is broken/incomplete.
There is an updated RPM on the dvd that you simply install as root in a shell

Code: Select all
su (no password prompt in live environment)
urpmi grub2


Once THAT is installed it all works as expected.

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 12th, '18, 06:09
by gohlip
waferhead wrote:The problem is the version of grub2 actually installed on the live filesystem is broken/incomplete.
.
.
Once THAT is installed it all works as expected.



Correct,
gohlip wrote:
Perhaps Mageia install dvd does not come with grub2 package, which is possible based on your error message and Mageia being grub-legacy centric.


Mageia install media, unlike the other linux distro install media does not have grub (grub2) in it but will be 'activated' during installation itself.
Similarly, grub2 modules (like configfile,chainload etc.. total size less than 2.5 MB) are also not in the install media.
It is therefore preferable to use other OS install media to fix grub issues in Mageia. If there are other linux OS in the system, use that grub instead.

By the way, Mageia installation media boots up using grub2 for uefi install and syslinux for bios-legacy install.
But I understand M7 will start using grub2 for both uefi and bios-legacy installation.
But I think grub and modules will also not be present until activated at installation process.
A pity.

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 13th, '18, 15:03
by waferhead
The LiveDVD has most of Grub2 in /boot, but is MIA in /usr, which is how you get the "fix" failures...
If it was missing entirely the issue would be more obvious.

I'm still hoping for a still dead simple, EFI-capable version of syslinux. :twisted:

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 13th, '18, 18:40
by gohlip
waferhead wrote:The LiveDVD has most of Grub2 in /boot, but is MIA in /usr, which is how you get the "fix" failures...
If it was missing entirely the issue would be more obvious.
I'm still hoping for a still dead simple, EFI-capable version of syslinux. :twisted:


If installer is syslinux, you would not be able to resolve your problem. :lol:

As for why grub2 is needed for uefi installs, not syslinux, I almost replied that syslinux (extlinux for linux) is not capable, but to be technically correct, at installation, the user has to manually mount points,move bootable kernels to...so, I'll let the link speak for itself.
https://superuser.com/questions/746553/ ... om-efi-gpt

Anyway, I hope Mageia installer media is more grub 2 capable. An extra 2.5 MB do not hinder other (non-Fedora) distro installers.
And I'm getting more dubious about Fedora's motives. Let's hope we do not just blindly

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 14th, '18, 03:39
by waferhead
So syslinux/extlinux is just a bash/python script away from being a universal boot loader? :twisted:

I'm just not a huge fan of grub2, although it does seem to work reasonably now, although I have reinstalled Mageia a few times since release largely due to grub2/systemd etc. At least it boots reliably and fast right now.

Grub2 is much like systemd in that it defies all things that have been considered good practice in Unix for 40 years, to no obvious gain...
...and those that ignore the lessons of Unix are destined to rediscover them.
...or something like that.

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 16th, '24, 12:55
by laidlaws
Sorry to reopen such an old thread, but why does /dev/sda become the primary drive when it has nothing to do with the piece of code but is there only by accident? How do I determine which is the primary drive?

Re: [SOLVED] Reinstalling GRUB from live dvd

PostPosted: Mar 16th, '24, 15:59
by doktor5000
IMHO those parts about primary drive are nonsense. You can easily have 3 or 4 disks, have a linux on each of those and have a separate grub on each of those in the root partition,
and use one bootloader from MBR or UEFI to chainload the others. It does not matter what the "primary" drive is.