Jump to content











Photo

Conditions and configfile command issue?


  • Please log in to reply
4 replies to this topic

#1 jakub.j

jakub.j

    Newbie

  • Members
  • 23 posts

Posted 23 June 2022 - 07:37 PM

Hello. I have multiboot usb drive based on this version of grub2: https://github.com/a1ive/grub/releases. For better "managment" of config files i separated submenus for various files like that:

 

/grub/grub.cfg

/grub/inne.cfg

/grub/linux.cfg

/grub/win_efi.cfg

/grub/win_legacy.cfg

 

In main file:

menuentry "Windows" {

	if [ "grub_platform" = "efi"]; then
	configfile /grub/win_efi.cfg
	else
	configfile /grub/win_legacy.cfg
	fi
}

if [ "$grub_platform" = "pc"]; then

menuentry "Windows1" {
	configfile /grub/win_efi.cfg
}

fi

if [ "$grub_platform" = "efi"]; then

menuentry "Windows2" {
	configfile /grub/win_efi.cfg
}

fi

In legacy booting doesn't show "Windows1". In efi mode doesn't show "Windows2" and always in "Windows" sets win_legacy.cfg. Both .cfg files are prepared correctly.



#2 alacran

alacran

    Platinum Member

  • .script developer
  • 2704 posts
  •  
    Mexico

Posted 23 June 2022 - 08:13 PM

You are using  a single = , better use double ==

 

You should have an space before ]

 

Additionally the last two menuentries are calling same config file: win_efi.cfg

 

Please see next post with my suggestion.

 

alacran



#3 alacran

alacran

    Platinum Member

  • .script developer
  • 2704 posts
  •  
    Mexico

Posted 23 June 2022 - 10:02 PM

I would prefer to use only the following:

if [ "${grub_platform}" == "efi" ]; then
    menuentry "Windows UEFI" {
      configfile /grub/win_efi.cfg
    }
else
    menuentry "Windows Legacy" {
      configfile /grub/win_legacy.cfg
    }
fi

This way the menuentry that will be shown on screen, will help you to confirm if you are on a Legacy or on a UEFI environment.

And also can make unnecessary your aditional code for manual selection.

alacran


  • jakub.j likes this

#4 jakub.j

jakub.j

    Newbie

  • Members
  • 23 posts

Posted 24 June 2022 - 02:36 PM

From example:

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

This work so "=" is correct. In menuentry "Windows" i add spaces and in legacy and efi ony sets win_legacy.cfg. I will use your solution. Thank you.



#5 alacran

alacran

    Platinum Member

  • .script developer
  • 2704 posts
  •  
    Mexico

Posted 28 June 2022 - 03:44 AM

JFYI

 

About A1ive's grub2, I will add here some info that may be interesting for some readers.

 

A1ive's grub2  topic on reboot forum  Where you can find some experiments and English translation of the manual/guide.

 

Link on GitHub  with a brief explanation and download links.

 

In no way I'm an expert in creating A1ive's grub2 config files, all my limited knowledge and experience comes from read, modify and add new entries in the grub.cfg file used by our fellow wimb in his USB_FORMAT and  UEFI_MULTI , and also  VHD_WIMBOOT  programs, (links on GitHub).

 

I will attach it here because I consider it a very good guide, as it is has a lot of real life examples that can be adapted for almost any possible multiboot case.

 

In fact during my experiments with Linux Portable Distros, I was able to create the menuentry "Portable Linux Distro Menu - /grub/grub_distro.cfg", and its respective config file, (also included in attachment), that latter wimb included in his programs.

 

Attached you will find A1ive_grub_cfg_samples.7z    password = alacran

 

alacran

Attached Files






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users