1

First, I'm sorry for my poor English. I'm a Windows user and new with grub2 also Linux. So I came here to get some advice from you.

I'm running windows 10 UEFI and now I want to use grub2 is main loader to chainload Windows also chainload to Linux. I use bootx64.efi from Ubuntu install ISO and replace bootx64.efi (windows) by it. grubx64.efi and grub.cfg (let say grub1.cfg) put on EFI partition. i use grub1.cfg to call another grub.cfg (let say grub2.cfg) put on NTFS partition. But after restart computer, grub1.cfg can not find grub2.cfg.

After some work, I found that if I use bootx64.efi from clonezilla then it work fine.

But I would like to use bootx64.efi from Ubuntu because it support

if [ -e "..."]; then command.

Does any one can give me some hint. Tks

  • Paths or locations of extra grub files are also important. And different installs of grub have different paths. If using live installer it has one location for grub.cfg and rest of grub files. But a full install has shimx64.efi that you can rename to bootx64.efi, but that is hard coded to look for /EFI/ubuntu for grub.cfg. Have you tried putting entire boot stanza into grub.cfg in /EFI/Boot or path where grub in ESP expects to find it? – oldfred Mar 10 '16 at 18:05
  • Hi Vishunu, I'm not going to install full OS on my HDD. I just like to run live OS. So i use grub2 to chainload windows and Live Linux OS. But if i use bootx64.efi clonezilla, it can file grub2.cfg in any partition even if NTFS. But if use ubuntu bootxt64.efi, with same code in grub1.cfg but grub2 was no called. Here my grub1.cfg put on EFI partition, same directory with grubx64.efi insmod part_gpt insmod ntfs insmod fat insmod part_msdos insmod ext2 search --file --no-floppy --set=root /boot/grub/grub.tag set prefix=/boot/grub/ configfile "${prefix}/grub.cfg" – congnt92 Mar 11 '16 at 3:23
  • After some works i found that command insmod ntfs does not work because it required ntfs.mod in x86_64-efi folder. So bootx64.efi from ubuntu install ISO not embedded insmod ntfs but bootx64.efi from clonezilla embedded it. I just do not like copy x86_64-efi folder to EFI partition. I just need copy bootx64.efi grubx64.efi and grub1.cfg to EFI partition. So how can I rebuuld bootx64.efi from ubuntu ISO. It has if -e command so i can hide some menuentry if file not exist. Tks – congnt92 Mar 11 '16 at 6:01
  • I directly install grub to flash drive and copy several ISO to it. The manually create my own grub. cfg to boot each ISO. I often also add boot stanza for my working install in SSD or HDD also. I do something similar to this: wiki.archlinux.org/index.php/Multiboot_USB_drive And this even though HDD: help.ubuntu.com/community/Grub2/ISOBoot and:help.ubuntu.com/community/Grub2/ISOBoot/Examples But drive as seen by BIOS or UEFI and path are critical. BIOS:askubuntu.com/questions/388382/… – oldfred Mar 11 '16 at 15:15
  • Tks oldfred, your link is useful for newbie like me. But let me say something, i just need to add grub2 menu that can allow me multiboot OS, i no need to create USB multiboot. My problem come from ntfs partition. I must insmod ntfs but bootx64.efi not embed ntfs module in .efi file. I must use x86_64 folder to insmod ntfs. I do not want to copy many files and folder to EFI partition. So i'm try to use bootx64.efi from clonezilla, but it does not support if -exist command – congnt92 Mar 12 '16 at 3:47
0

When GRUB loads grub.cfg from the EFI partition, it sets your EFI partition as the root for GRUB. In order to load another grub.cfg from another partition, you would have to change GRUB's root so it knows where to look for the second config.

Also, loading the ntfs module may be required. So, your menu entry would look something like this:

menuentry 'Windows' {
  insmod part_gpt
  insmod ntfs
  set root='hd1,gpt2' #This is where you tell grub where to start searching for the new config file
  configfile ${root}/path/to/grug2.cfg
}

If the ntfs module cannot be loaded, copy it from Ubuntu's /boot/grub/x86_64-efi/ntfs.mod to /boot/efi/boot/grub.

Or you could hard-code it a bit more and make it more simple with something like this:

menuentry 'Windows' {
  insmod part_gpt
  insmod ntfs
  configfile (hd1,gpt2)/path/to/grub2.cfg
}

Note, this is not tested, but if you have any issues let me know and I'd be glad to help.

  • Hi Chuck R, Tks for your help. Here my grub1.cfg code.insmod part_gpt insmod ntfs insmod fat insmod part_msdos insmod ext2 search --file --no-floppy --set=root /boot/grub/grub.tag set prefix=/boot/grub/ configfile "${prefix}/grub.cfg" – congnt92 Mar 11 '16 at 3:19
  • I cannot set special root because i would like to use tag file and grub1.cfg will find tag file and set root here. But i do not know it does not work. – congnt92 Mar 11 '16 at 3:21
  • After some works i found that command insmod ntfs does not work because it required ntfs.mod in x86_64-efi folder. So bootx64.efi from ubuntu install ISO not embedded insmod ntfs but bootx64.efi from clonezilla embedded it. I just do not like copy x86_64-efi folder to EFI partition. I just need copy bootx64.efi grubx64.efi and grub1.cfg to EFI partition. So how can I rebuuld bootx64.efi from ubuntu ISO. It has if -e command so i can hide some menuentry if file not exist. Tks – congnt92 Mar 11 '16 at 5:57
  • You'd just be assigning the new root within the menuentry and right before boot, so that would not affect the rest of your config. Once you load into grub2.cfg, you could also reset the root back to EFI. There is a way to embed mod files in the grub2 image. I haven't attempted this in a long time, so I'll have to do a little research and update my answer. – Chuck R Mar 12 '16 at 2:38
  • OK, so the way to embed modules into the grub image is with grub-mkimage. You can embed just the modules you need for your config using something like this: grub-mkimage -O x86_64-efi -o bootx64.efi fat part_msdos part_gpt ext2 ntfs [more modules]. Then, copy the generated bootx64.efi to your EFI partition. You can also embed a config file with the -c switch. But, there's really no reason to go through the embedding hassle or to copy the whole x86_64-efi folder, simply copy the .mod files you need into (EFI Partition)/boot/grub. – Chuck R Mar 12 '16 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.