Grub2Win Experiences

Hi there,
I recently switched to EndeavorOS and have the following question.
Until now I used a software called grub2win, which allows MultiBoot with Windows and Linux, without modifying the Windows MBR explicitly.

Now I have the following problem. Since grub2win does not natively support Endeavor, you have to manually import the grub.cfg file and follow their wiki instruction, but when starting it it does not seem to find the kernel.

My question is: Does anybody have experience with grub2win and do I even need g2w?

Kind regards,
Max

I am afraid I don’t have any experience with this piece of software.

Not really if you don’t mind to use EnOS’ Grub to boot both of your systems.

Please note that installing EnOS’ Grub will overwrite your disk’s MBR therefore it is a good measure to make a Recovery Disk from within your Windows system if you ever would need to restore its bootloader.

If you could post the content of the grub.cfg and link to the wiki instructions, forum members will have a chance to look into the details.

Thank you for the info!

Ok yeah the grub installed by EnOS’ seems to work fine, I was just curious.

Grub2win does not have a wiki, I just realized that they install the documentation locally…



My grub.cfg looks like this:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

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
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root a48a57d2-a92c-4798-b51d-df20b1723472
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root a48a57d2-a92c-4798-b51d-df20b1723472
insmod png
background_image -m stretch /usr/share/endeavouros/splash.png
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'EndeavourOS Linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-a48a57d2-a92c-4798-b51d-df20b1723472' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root a48a57d2-a92c-4798-b51d-df20b1723472
	echo	'Loading Linux linux ...'
	linux	/boot/vmlinuz-linux root=UUID=a48a57d2-a92c-4798-b51d-df20b1723472 rw  nowatchdog nvme_load=YES loglevel=3
	echo	'Loading initial ramdisk ...'
	initrd	/boot/intel-ucode.img /boot/initramfs-linux.img
}
submenu 'Advanced options for EndeavourOS Linux' $menuentry_id_option 'gnulinux-advanced-a48a57d2-a92c-4798-b51d-df20b1723472' {
	menuentry 'EndeavourOS Linux, with Linux linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-a48a57d2-a92c-4798-b51d-df20b1723472' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod ext2
		search --no-floppy --fs-uuid --set=root a48a57d2-a92c-4798-b51d-df20b1723472
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=a48a57d2-a92c-4798-b51d-df20b1723472 rw  nowatchdog nvme_load=YES loglevel=3
		echo	'Loading initial ramdisk ...'
		initrd	/boot/intel-ucode.img /boot/initramfs-linux.img
	}
	menuentry 'EndeavourOS Linux, with Linux linux (fallback initramfs)' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-a48a57d2-a92c-4798-b51d-df20b1723472' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod ext2
		search --no-floppy --fs-uuid --set=root a48a57d2-a92c-4798-b51d-df20b1723472
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=a48a57d2-a92c-4798-b51d-df20b1723472 rw  nowatchdog nvme_load=YES loglevel=3
		echo	'Loading initial ramdisk ...'
		initrd	/boot/intel-ucode.img /boot/initramfs-linux-fallback.img
	}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
  insmod bli
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
if [ "$grub_platform" = "efi" ]; then
	fwsetup --is-supported
	if [ "$?" = 0 ]; then
		menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
			fwsetup
		}
	fi
fi
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/35_fwupd ###
### END /etc/grub.d/35_fwupd ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/45_eos_windows ###

menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-7EDA-023C' {
	insmod part_gpt
	insmod fat
	search --no-floppy --fs-uuid --set=root 7EDA-023C
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/45_eos_windows ###

Inside g2w it gets converted to this:

     getpartition  uuid  a48a57d2-a92c-4798-b51d-df20b1723472  root
     g2wsetprefix
     linux        $pathprefix/boot/vmlinuz-linux root=UUID=a48a57d2-a92c-4798-b51d-df20b1723472 rw  nowatchdog nvme_load=YES loglevel=3
     initrd        $pathprefix/boot/intel-ucode.img $pathprefix/boot/initramfs-linux.img
1 Like

Also for Manjaro this script must be run each time the Kernel changes. So it could be that this is also needed for other Arch systems:

#!/usr/bin/perl
print "\n";
$checktime = eval {require    Time::localtime;1;};
$checkfile = eval {require    File::stat;1;};
$scriptpath = abs_path($0);

if ( $< == 0 )
  {
	print "The kernset.sh script is being run with root privileges.\n\n";
  } 
  else
  {
        system ("clear");
	print "Your username is - " . (getpwuid($<))[0] .  "\n\n";
	print "You must be logged in as root or use sudo to run this script.\n\n";
	print "Do you want to continue kernset.sh via sudo?  <y n>\n";
	chomp ($response = <>);
	if ($response ne "y")
	    {print "\n\n";
    	     print "Run of kernset.sh was aborted by request\n\n";
             exit;}
        print "\n\n";
	use Cwd qw(abs_path);
	
        system ("sudo $scriptpath");
        exit;
  }

if (!@ARGV) {sourcerun ()};
  
$parmkernelname   = "vmlinuz";
$parminitrdname   = "initramfs.img";
$parminitprefix   = "initramfs";
$dirtarget        = "/boot/";
$dirsource        = "/boot/";

#####################################################################

$vmlinuz_release  = 0;
$vmlinuz_filename = "";
$initrd_release   = 0; 
$initrd_filename  = "";

print "\n";
print "Running the  - Linux -  link setup using source directory   " . $dirsource . ".\n";
print "                                    The target directory is  " . $dirtarget . ".\n";
print "\n";

opendir(IMD, $dirsource) || die("Cannot open directory");
@filearray = readdir(IMD);
@filearray = sort @filearray;
closedir(IMD);
$kernelfound = "no";
$initrdfound = "no";

foreach $filename (@filearray) {
    if (index($filename, 'rescue') != -1) {next}
    if (index($filename, 'dump')   != -1) {next}
    $first6 = substr($filename, 0, 6);
    $first7 = substr($filename, 0, 7);
    $first9 = substr($filename, 0, 9);
    $last4  = substr($filename, -4);
    $last6  = substr($filename, -6);
    $last12 = substr($filename, -12);
    if ($last12 eq "fallback.img") {next}
    if ($first6 eq "initrd")
       {$parminitrdname   = "initrd.img";
        $parminitprefix   = "initrd";}
    if (($filename eq $parmkernelname) or ($filename eq $parminitrdname)) {next}
    if (($first7 ne $parmkernelname) and ($first9 ne $parminitprefix) and ($first6 ne $parminitprefix)) {next}
    #	print "Processing  $filename\n\n";

    $relstring = $filename;
    $relstring =~ s/vmlinuz-//;
    $relstring =~ s/-amd64//;
    $relstring =~ s/.x86_64//;
    $relstring =~ s/initrd-//;
    $relstring =~ s/initrd//;
    $relstring =~ s/initramfs-//;
    $relstring =~ s/initramfs//;
    $relstring =~ s/.img-//;
    $relstring =~ s/.img//;

    $relstring =~ s/-/./;

    # print "Relstring $filename     $relstring\n\n";
    
    $rawrel    = "." . $relstring . ".";
    $rawrel    =~ tr/./ /;

    # print "Rawrel-B $rawrel\n\n";

    my ($rel1, $rel2, $rel3, $rel4) = split " ", $rawrel;
    my $rel1 = sprintf "%05d", $rel1;
    my $rel2 = sprintf "%05d", $rel2;
    my $rel3 = sprintf "%05d", $rel3;
    my $rel4 = sprintf "%05d", $rel4;
    my $release = $rel1 . $rel2 . $rel3 . $rel4;

    # print "Rel1 $rel1 Rel2 $rel2 Rel3 $rel3 Rel4 $rel4 Filled $filled Release $release\n\n";
   
                  
    $fullfile       = ($dirsource . $filename);
    
         $fullfile_printtime = ctime(stat($fullfile)->mtime);
  	if ($first7 eq $parmkernelname) {
    	     $kernelfound = "yes";
    	     print "The modify date for $fullfile         is $fullfile_printtime\n\n";
    	     if ($release > $vmlinuz_release) {
	          $vmlinuz_release   = $release;
    		  $vmlinuz_filename  = $filename;
             }
        }
  
  	if (($first9 eq $parminitprefix) && ($last4 eq ".img")) {
    	     $initrdfound = "yes";
     	     print "The modify date for $fullfile   is $fullfile_printtime\n\n";
     	     if ($release > $initrd_release) {
	          $initrd_release   = $release;
	          $initrd_filename  = $filename;
             }
        }
        if (($first6 eq $parminitprefix) && ($last6 eq "-amd64")) {
    	     $initrdfound = "yes";
     	     print "The modify date for $fullfile   is $fullfile_printtime\n\n";
     	     if ($release > $initrd_release) {
	          $initrd_release   = $release;
	          $initrd_filename  = $filename;
             }
        }
}

if (($kernelfound eq "no") || ($initrdfound eq "no"))
   {print "The Linux kernel files were not found in the /boot directory\n\n";
   print  "      kernset.sh was aborted\n\n";
   exit;
}

$vmlinuz_link     = $dirsource . $parmkernelname;
$initrd_link      = $dirsource . $parminitrdname; 

system ("rm   -f        " . $vmlinuz_link);
system ("rm   -f        " . $initrd_link);

$vmlinuz_target = $dirtarget . $vmlinuz_filename;
# print   $vmlinuz_target . "    " . $vmlinuz_link . "  Linker \n";
link $vmlinuz_target , $vmlinuz_link||die "vmlinuz link failed";
$initrd_target  = $dirtarget . $initrd_filename;
link $initrd_target , $initrd_link||die   "initrd link failed";

$vmlinuz_printtime = ctime(stat($dirsource . $vmlinuz_filename)->mtime);
$initrd_printtime  = ctime(stat($dirsource . $initrd_filename)->mtime);
print "\n";
print "\n";
print "\n";
print "The most recent kernel filename is  $vmlinuz_filename          It was modified  $vmlinuz_printtime\n";
print "The kernel release string is        $vmlinuz_release\n\n";
print "The most recent initrd filename is  $initrd_filename    It was modified  $initrd_printtime\n";
print "The initrd release string is        $initrd_release\n\n";
print "\n";
print "\n";
print "   kernset.sh kernel link setup successfully completed\n";
print "\n";

sub sourcerun {
    system ("clear");
    print "\nStart SourceRun\n";
    
    if (($checktime ne 1) or ($checkfile ne 1)) {
       print "\n\n  The full Perl language package is requred and must be installed to Linux.";
       print "\n\n  kernset.sh failed!!\n\n";
       exit (0)} 
         
    $tempscript = "/tmp/kernset.temp.sh";  
    
    open(INHANDLE,  '<', "$scriptpath") or die $!;
    open(OUTHANDLE, '>', "$tempscript") or die $!;
    
    while(<INHANDLE>){
       my $filerec = $_;
       $filerec = $filerec =~ s/require   /use   /r;
       print OUTHANDLE $filerec;
    }   

    close (INHANDLE);
    close (OUTHANDLE);
     
    system ("chmod 777 $tempscript");  
    print "\nEnd SourceRun\n\n";
    system ("$tempscript targetrun");  
    system ("rm -f $tempscript");
    exit (0);
} 

So looking at all this, it might be wiser to just costimize the Endeavor Grub :wink:

So out of curiosity I experimented a little bit and I am almost certain, that grub2win or the grub2 inside it does not recognize the ext4 file system of endeavour. This leads to grub not recognizing the label and uuid and then it can not boot the vmlinuz and initrd. Shouldnt grub natively work with ext4?

I have grub and ext4 on a few machines and they work very well together.
So I assume the problem is something different.

Never used grub2win.

Edit: Are you sure grub2win is internally compatible with grub2? Looks more like compatible with grub1…

Edit2: you can run commands

sudo grub-mkconfig
sudo os-prober

to see their output. These commands will not overwrite anything.
Run them on the USB live session if you will.
And please show the output here.