WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved} Grub2 does not load grub.cfg automatically  (Read 1388 times)

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
[Solved} Grub2 does not load grub.cfg automatically
« on: May 22, 2020, 03:20:36 AM »
Hi !
I have installed TCL on my BIOS laptop recently. I have installed grub2-multi extension from app browser. After that, I ran
Code: [Select]
sudo grub-install /dev/sda5
I inserted "/dev/sda5" because I have Win 10 on my second partition.
I have manually created grub.cfg in /tce/boot/grub and entered
Code: [Select]
timeout=11
menuentry "Tiny Core Linux" {
root (hd0,4)
kernel /tce/boot/vmlinuz quiet
initrd /tce/boot/core.gz
Now, I get grub console when I select Tiny Core in Windows Bootloader. What should I do to get the grub automated ?

A small doubt : I installed grub2-multi but I get "GRUB4DOS 0.4.6a" at the top of grub console. Why ?
I also get "File not found" error when I type "insmod ntfs" but ntfs.mod is present in /mnt/sda5/tce/boot/grub/i386-pc .
« Last Edit: May 30, 2020, 05:20:13 AM by Rich »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8223
Re: Grub2 does not load grub.cfg automatically
« Reply #1 on: May 22, 2020, 05:42:02 AM »
Hi Sashank999
You neglected to tell  grub2  where to look for files. From the  grub2  .info file:
http://tinycorelinux.net/11.x/x86/tcz/grub2-multi.tcz.info
Code: [Select]
Comments:       grand unified bootloader with legacy bios and efi modules
                ----------
                howto:
                $ sudo mount /dev/sdc1
                $ sudo grub-install --boot-directory=/mnt/sdc1/boot /dev/sdc
                $ cat /mnt/sdc1/boot/grub/grub.cfg
                insmod ext2
                search --no-floppy --fs-uuid --set=root 3916536c-ab5b-45f4-92de-a6b8af8ec630
                menuentry "core" {
                linux /boot/vmlinuz quiet noswap waitusb=10:UUID="3916536c-ab5b-45f4-92de-a6b8af8ec630" tce=UUID="3916536c-ab5b-45f4-92de-a6b8af8ec630" tz=GMT-4 blacklist=bcma blacklist=ssb blacklist=b43 text
                initrd /boot/rootfs.gz /boot/modules.gz
                }
                ----------

Based on where you placed your config file (/tce/boot/grub/grub.cfg), you should have used:
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/tce/boot /dev/sda5
    [EDIT]: Fixed typo.  Rich
« Last Edit: May 22, 2020, 06:02:54 AM by Rich »

aus9

  • Guest
Re: Grub2 does not load grub.cfg automatically
« Reply #2 on: May 22, 2020, 07:07:25 AM »
@Sashank999

Have you previously used grub-legacy?

You have mixed up your kernel line syntax.

its no longer kernel blah blah but
linux blah blah.

2) best to define the boot partition by
set root=(hdA,y)

count A hard drive by zero,1,2,3
count y partitions by normal count 1,2,3

Rich has assumed that which is why he is thinking /dev/sda5

3) It might be best you post the full contents of your grub.cfg

4) however, you will notice the info file shows /boot at the root of /mnt/sdc1
but you appear to be trying to use boot as a sub-directory to /mnt/sda5/tce

sorry to butt in.

Quote
File not found
  would suggest grub is not correctly installed but you have not reported what errors you saw when you attempted to install grub2?

5) also its not clear to me, does windows boot ok?

Does windows bootloader have a chainload command to grub2?
Is that your intention?

In which case your windows menu must chainload to the Partition boot record for /dev/sda5.
and so it might also mean you need to show that part of your windows boot loader menu too please.
« Last Edit: May 22, 2020, 07:12:22 AM by aus9 »

aus9

  • Guest
Re: Grub2 does not load grub.cfg automatically
« Reply #3 on: May 22, 2020, 09:12:46 PM »
hi

I forgot to address this question
Quote
A small doubt : I installed grub2-multi but I get "GRUB4DOS 0.4.6a" at the top of grub console. Why ?

reason: on 64 bit grub2 at command mode should display the characters
"GRUB version 2 <something>"

Therefore, grub2 was never installed into your partition boot record.(PBR)

At some time in the past, someone had installed grub4dos.
You can only have one bootloader in your MBR
You can only have one bootloader in your PBR

You don't even need a bootloader in MBR, you could use a usb or optical disc to boot the hard drive.
You don't need a bootloader in PBR, unless you want to keep Microsoft things separate from Linux things.

To get rid of grub4dos, you just need to overwrite that PBR with another boot loader.
It does not have to be grub2 if you are struggling with it.

Hope that helps
« Last Edit: May 22, 2020, 09:24:04 PM by aus9 »

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #4 on: May 22, 2020, 11:25:38 PM »
Hi Sashank999
You neglected to tell  grub2  where to look for files. From the  grub2  .info file:
http://tinycorelinux.net/11.x/x86/tcz/grub2-multi.tcz.info
Code: [Select]
Comments:       grand unified bootloader with legacy bios and efi modules
                ----------
                howto:
                $ sudo mount /dev/sdc1
                $ sudo grub-install --boot-directory=/mnt/sdc1/boot /dev/sdc
                $ cat /mnt/sdc1/boot/grub/grub.cfg
                insmod ext2
                search --no-floppy --fs-uuid --set=root 3916536c-ab5b-45f4-92de-a6b8af8ec630
                menuentry "core" {
                linux /boot/vmlinuz quiet noswap waitusb=10:UUID="3916536c-ab5b-45f4-92de-a6b8af8ec630" tce=UUID="3916536c-ab5b-45f4-92de-a6b8af8ec630" tz=GMT-4 blacklist=bcma blacklist=ssb blacklist=b43 text
                initrd /boot/rootfs.gz /boot/modules.gz
                }
                ----------

Based on where you placed your config file (/tce/boot/grub/grub.cfg), you should have used:
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/tce/boot /dev/sda5
    [EDIT]: Fixed typo.  Rich
TY for the reply and sorry for the late.
I have seen in some other website that the grub2 looks for grub.cfg in (hdX,Y)/boot/grub. So, I copied entire /tce/boot folder and pasted it beside tce. Now, it works !
Another thing, do we have a way to change the boot directory after installation of grub2 ?

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #5 on: May 22, 2020, 11:32:36 PM »
@Sashank999

Have you previously used grub-legacy?

You have mixed up your kernel line syntax.

its no longer kernel blah blah but
linux blah blah.

2) best to define the boot partition by
set root=(hdA,y)

count A hard drive by zero,1,2,3
count y partitions by normal count 1,2,3

Rich has assumed that which is why he is thinking /dev/sda5

3) It might be best you post the full contents of your grub.cfg

4) however, you will notice the info file shows /boot at the root of /mnt/sdc1
but you appear to be trying to use boot as a sub-directory to /mnt/sda5/tce

sorry to butt in.

Quote
File not found
  would suggest grub is not correctly installed but you have not reported what errors you saw when you attempted to install grub2?

5) also its not clear to me, does windows boot ok?

Does windows bootloader have a chainload command to grub2?
Is that your intention?

In which case your windows menu must chainload to the Partition boot record for /dev/sda5.
and so it might also mean you need to show that part of your windows boot loader menu too please.
No, I didn't previoulsy used grub-legacy. But, I learnt its syntax from the grub console and some web articles.
When I type "kernel /tce/boot/vmlinuz", it says "Kernel command not found". Hence, I changed it to kernel command.
2) When I use "set root=(hd0,4)", it changes for the next boot.
3) I posted the full contents previously. That was all the grub.cfg.
4) There were no errors reported when installing grub2.
5) The Windows boots up perfectly.
The windows cannot boot from grub2 but "EasyBCD" chainloads grub2 from win bootloader.
Yes my intention is to boot grub2 from win bootloader.

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #6 on: May 22, 2020, 11:35:20 PM »
hi

I forgot to address this question
Quote
A small doubt : I installed grub2-multi but I get "GRUB4DOS 0.4.6a" at the top of grub console. Why ?

reason: on 64 bit grub2 at command mode should display the characters
"GRUB version 2 <something>"

Therefore, grub2 was never installed into your partition boot record.(PBR)

At some time in the past, someone had installed grub4dos.
You can only have one bootloader in your MBR
You can only have one bootloader in your PBR

You don't even need a bootloader in MBR, you could use a usb or optical disc to boot the hard drive.
You don't need a bootloader in PBR, unless you want to keep Microsoft things separate from Linux things.

To get rid of grub4dos, you just need to overwrite that PBR with another boot loader.
It does not have to be grub2 if you are struggling with it.

Hope that helps
TY for the reply.
I did not install grub4dos. But, when I copy the /mnt/sda5/tce/boot directory to /mnt/sda5 (beside /tce), the grub shows GRUB Version 2. Thank You all for the replies  ;D!

aus9

  • Guest
Re: Grub2 does not load grub.cfg automatically
« Reply #7 on: May 23, 2020, 02:41:28 AM »
@Rich
@Juanito

Hi...win10.....is that a 32 bit or 64 bit OS?
You appear to have a 32 bit TC without a 32 bit efi grub install.

I am thinking out loud that you may have a UEFI/BIOS that coupled with BCD, that:
you are unable to turn off secure boot,
your bios expects to find a signed linux key

and only if that thinking is correct....you might need to consider the following,
but wait for a second opinion from with Rich, Juanito or Curaga or other gurus please.

A) you might need a 64 bit TC....assuming you have a 64 bit CPU
but there might be a 32 bit efi command as per below or even better from the gurus
B) you might need a different grub2 install command probably
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/boot --target=x86_64-efi  /dev/sda5
but if 32 bit efi works....I don't know as I have not got it a command that might work is
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/boot --target=i386-efi  /dev/sda5
« Last Edit: May 23, 2020, 02:46:18 AM by aus9 »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8223
Re: Grub2 does not load grub.cfg automatically
« Reply #8 on: May 23, 2020, 07:18:10 AM »
Hi Sashank999
... Another thing, do we have a way to change the boot directory after installation of grub2 ?
I think running the install command again using the  --boot-directory=  option should do it:
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/tce/boot /dev/sda5
I would create a backup of your  grub.cfg  file before running the install command just to be safe.

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #9 on: May 23, 2020, 11:39:14 PM »
@Rich
@Juanito

Hi...win10.....is that a 32 bit or 64 bit OS?
You appear to have a 32 bit TC without a 32 bit efi grub install.

I am thinking out loud that you may have a UEFI/BIOS that coupled with BCD, that:
you are unable to turn off secure boot,
your bios expects to find a signed linux key

and only if that thinking is correct....you might need to consider the following,
but wait for a second opinion from with Rich, Juanito or Curaga or other gurus please.

A) you might need a 64 bit TC....assuming you have a 64 bit CPU
but there might be a 32 bit efi command as per below or even better from the gurus
B) you might need a different grub2 install command probably
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/boot --target=x86_64-efi  /dev/sda5
but if 32 bit efi works....I don't know as I have not got it a command that might work is
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/boot --target=i386-efi  /dev/sda5
Hi @aus9
My Windows 10 is 64 bit OS.
I don't know if my TCL is 32 bit and, I don't know that TCL has a 64 bit version  ??? .
"BIOS/UEFI" My Laptop is BIOS. It does not have secure boot and fast boot.
Mine is not an EFI laptop so none of the above command should be followed. I think so...
And one more thing, In previous post, I mentioned that my Grub shows v2 and it shows menu. It loads the grub.cfg in /tce/boot/grub/grub.cfg, not the one in /boot (copied and pasted beside tce folder)/grub/grub.cfg.

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #10 on: May 23, 2020, 11:47:57 PM »
Hi Sashank999
... Another thing, do we have a way to change the boot directory after installation of grub2 ?
I think running the install command again using the  --boot-directory=  option should do it:
Code: [Select]
sudo grub-install --boot-directory=/mnt/sda5/tce/boot /dev/sda5
I would create a backup of your  grub.cfg  file before running the install command just to be safe.
@Rich . Now, I am gonna do a new grub install with --target=i386-pc (of course unnecessary) and also with --boot-directory=/tce/boot/ like this :
Code: [Select]
grub-install --target=i386-pc --boot-directory=/tce/boot/ /dev/sda5
I will also report any errors during installation, make a backup of current grub.cfg and restore grub.cfg after new grub installation.
P.S. I am also doing rm-rf those old grub folders (/boot and /tce/boot/grub)
[EDIT] : Added P.S.
« Last Edit: May 23, 2020, 11:50:59 PM by Sashank999 »

aus9

  • Guest
Re: Grub2 does not load grub.cfg automatically
« Reply #11 on: May 23, 2020, 11:58:29 PM »
Quote
I don't know if my TCL is 32 bit

for 32 bit....menu might show vmlinuz and core.gz 
for 64 bit ....menu might show vmlinuz64 and corepure64.gz as per
http://tinycorelinux.net/11.x/x86_64/release/distribution_files/

BTW I am not trying to force you on onto 64 bit as generally speaking 32 bit packages are smaller than 64 bit. But if you have lots of RAM....well you decide   ;D

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #12 on: May 24, 2020, 12:51:21 AM »
I rm -rf the old grub directories,got "sudo su" and typed :
Code: (bash) [Select]
grub-install --target=i386-pc --boot-directory=/tce/boot /dev/sda5
Then I got this error : "grub-install: error: failed to get canonical path of "rootfs" "
So, I tried this :
Code: (bash) [Select]
grub-install --target=i386-pc --boot-directory=/mnt/sda5/tce/boot /dev/sda5
Then, I got :
Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

But the grub folder was created in /mnt/sda5/tce/boot . So, I used the --force :
Code: (bash) [Select]
grub-install --target=i386-pc --boot-directory=/mnt/sda5/tce/boot --force /dev/sda5
Then I got :
Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.

Then, I restored the old grub.cfg into the grub folder and then rebooted. Then, I got the GRUB v0.4.6a console.
I booted into TCL and then did the previous trick: Copying /mnt/sda5/tce/boot directory to /mnt/sda5. Then, the GRUB v2 booted with the menu.

Quote
I don't know if my TCL is 32 bit

for 32 bit....menu might show vmlinuz and core.gz 
for 64 bit ....menu might show vmlinuz64 and corepure64.gz as per
http://tinycorelinux.net/11.x/x86_64/release/distribution_files/

BTW I am not trying to force you on onto 64 bit as generally speaking 32 bit packages are smaller than 64 bit. But if you have lots of RAM....well you decide   ;D
Then, I got 32 bit TCL now. How to change to 64 bit ? Is replacing the vmlinuz and core.gz to vmlinuz64 and corepure64.gz enough ?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 12495
Re: Grub2 does not load grub.cfg automatically
« Reply #13 on: May 24, 2020, 12:58:19 AM »
You can either replace them or copy them alongside and add a grub.cfg menu entry so that you have the choice of 32/64-bit.

If you decide to add a menu entry, use "tce=tce64" to create a separate tce folder for 64-bit tinycore.
« Last Edit: May 24, 2020, 01:00:45 AM by Juanito »

Offline Sashank999

  • Sr. Member
  • ****
  • Posts: 372
Re: Grub2 does not load grub.cfg automatically
« Reply #14 on: May 24, 2020, 02:17:32 AM »
You can either replace them or copy them alongside and add a grub.cfg menu entry so that you have the choice of 32/64-bit.

If you decide to add a menu entry, use "tce=tce64" to create a separate tce folder for 64-bit tinycore.
Hi Juanito
Thanks for the reply.
My question is why does the grub only load GRUB v2.02 from /boot/grub but not from /tce/boot/grub ?
UPDATE : The GRUB v2.02 loads grub.cfg from /tce/boot/grub, not from /boot/grub.