Menu

Help for adding optional GRUB bypass.

2018-03-19
2018-03-21
  • Shreyas Kulkarni

    Hey Dave,
    Need your little help... I want to add a HDD detection and bypass to the GRUB. I have 2 HDD setup in laptop, and the 2nd HDD is in the ODD slot using a caddy and I've added a little switch there to manually on/off the power to the disk (Yes there is SATA hotplug enabled.). I power it on when needed as it drains battery power when it is not needed. There is Windows 7 and RemixOS on it. I have succesfully dual booted both UEFI windows boot managers with your guidence last time. The first hard drive has windows 10 on it.

    What I actually want to do:
    1) Detect 2nd HDD and if it is present, show GRUB menu.
    2) If it is absent, bypass the GRUB menu and directly boot windows 10 bootmgr from the main HDD (i.e. EFIWIN10 partition).

    The second hdd has a unique EFIWIN7 partition on it so I think we can use the "getbootpartition label EFIWIN7" to detect the 2nd HDD... I have attached the working GRUB config (Although GRUB2Win.exe doesnt open due to some config format error :/ )

    The GRUB menu is like this:-
    1. Windows 10. EFI partition on gpt0 and partlabel EFIWIN10.
    2. Windows 7. EFI partition on gpt1 and partlabel EFIWIN7.
    3. RemixOS
    4. Kali Linux. Its booted from the external USB drive with persistance with partlabel UUI.

    Thank you,
    Regards Shreyas.

    #
    #  Menu Entry         Windows 10 Pro
    #
    menuentry   'Windows  10 Pro                                        Hotkey="W"'    --hotkey=w   --class other   --class icon-windows   --class custom_005  {
    #
         set efibootmgr=/efi/Microsoft/Boot/bootmgfw.efi
         getbootpartition  label EFIWIN10
         if [ $reviewpause -gt 0 ] ; then
             chainloader $efibootmgr
         fi  
    # end-custom-code
    savelast 0 'Windows 10 Pro'
    }
    
    #
    #  Menu Entry 1       Windows 7 Ultimate
    #
    menuentry   'Windows 7 Ultimate                                     Hotkey="7"'   --hotkey=7    --class other   --class icon-windows   --class custom_005  {
         set gfxpayload=1366x768
    #
    # start-custom-code
            set efibootmgr=/efi/Microsoft/Boot/bootmgfw.efi
            getbootpartition  label EFIWIN7
            if [ $reviewpause -gt 0 ] ; then
                    chainloader $efibootmgr
            fi
    # end-custom-code
    savelast 1 'Windows 7 Ultimate'
    }
    
    #
    #  Menu Entry 2       RemixOS System RW
    #
    menuentry   'RemixOS System RW                                      Hotkey="R"'   --hotkey=r    --class remix   --class icon-remix  {
         set gfxpayload=1366x768
         set bootfile=/RemixOS/kernel
         getbootpartition  file   $bootfile
         linux  /RemixOS/kernel     root=/dev/ram0 verbose androidboot.hardware=remix_x86_64 androidboot.selinux=permissive REMOUNT_RW=1 DATA= SRC=RemixOS CREATE_DATA_IMG=1
         initrd /RemixOS/initrd.img    
    savelast 2 'RemixOS System RW'
    }
    
    #
    #  Menu Entry 3       Kali Linux
    #
    menuentry   'Kali Linux Persistence                                 Hotkey="K"'   --hotkey=k    --class debian   --class icon-unknown   --class custom_003  {
         set gfxpayload=1366x768
    #
    # start-custom-code
    set partlabel=UUI
    getbootpartition  label  $partlabel
    linux /live/vmlinuz-4.9.0-kali3-amd64 noconfig=sudo noprompt root=LABEL=$partlabel  cdrom-detect/try-usb=true  boot=live components splash username=root hostname=kali persistence
    initrd /live/initrd.img-4.9.0-kali3-amd64
    # end-custom-code
    savelast 3 'Kali Linux'
    }
    
    #
    #  Menu Entry 4       Shutdown Your System
    #
    menuentry   'Shutdown Your System                                   Hotkey="S"'   --hotkey=s    --class shutdown   --class icon-shutdown  {
         set gfxpayload=1366x768
         clear
         set pager=1
         echo
         echo Grub is shutting down your machine
         echo
         if [ ! -z $reviewpause ] ; then sleep -v -i $reviewpause ; echo ; fi
         halt
         # If halt fails, display an error message
         g2werror 'Grub Shutdown is not supported by your firmware'
    }
    
    #
    #  Menu Entry 5       Reboot Your System
    #
    menuentry   'Reboot Your System                                     Hotkey="Delete"'     --hotkey=delete  --class reboot   --class icon-reboot  {
         set gfxpayload=1366x768
         clear
         set pager=1
         echo
         echo Grub is now rebooting your machine
         echo
         if [ ! -z $reviewpause ] ; then sleep -v -i $reviewpause ; echo ; fi 
         reboot 
         # If reboot fails, display an error message
         g2werror 'Grub Reboot is not supported by your firmware'
    }
    
    #
    #  Menu Entry 6       Boot to your EFI firmware
    #
    menuentry   'Boot to your EFI firmware                              Hotkey="Tab"'   --hotkey=tab    --class bootfirmware   --class icon-bootfirmware  {
         set gfxpayload=1366x768
         clear
         set pager=1
         echo
         echo Grub is now booting to your machine"'"s EFI firmware setup
         echo
         if [ ! -z $reviewpause ] ; then sleep -v -i $reviewpause ; echo ; fi
         fwsetup
         # If fwsetup fails, display an error message
         g2werror 'Grub Firmware Setup is not supported by your machine'
    }
    #
    
     

    Last edit: Shreyas Kulkarni 2018-03-19
  • Drummer

    Drummer - 2018-03-19

    Hi Shreyas,

    I think this is possible, but I need some more info on your configuration.

    Please run the Grub2Win diagnostics, zip up the C:\grub2\diagnose directory and send it to me.

    I've tested a solution and it works on my system, but I need the configuration info to customize it for your system.

    Also, please give me text of the error you receive when you run grub2win.exe

    Thanks,

    Dave

     
    • Shreyas Kulkarni

      Here you go ;)

      EDIT:- FYI, I have replaced the grub.cfg in the zip which I use and works.

       

      Last edit: Shreyas Kulkarni 2018-03-20
  • Drummer

    Drummer - 2018-03-21

    Hi Shreyas,

    I fixed the error you encountered. The new Grub2Win version 1.0.3.9 was just uploaded.

    There were some other syntax errors in your grub.cfg file, but I cleaned them up. Here's a link to the updated file.

    https://www.dropbox.com/s/q27a266mo0z6xs8/grub.cfg?dl=0

    I also added the bypass code you requested to your grub.cfg file. You will find it in the user section at the end of the file. It's a function I named checkwin7.

    Please let me know if this works for you.

    Thanks,

    Dave

     

    Last edit: Drummer 2018-03-21
    • Shreyas Kulkarni

      Thank you so much! It worked perfectly just as I inteded it to be :D

      PS: The grub2win installer is triggering Windows defender and other AV programs as a trojan (Yes I know its a false positive for sure but other prople may be concerned about it) since last few updates... It wasnt worth making seperate thread about it so posting here :P

       
  • Drummer

    Drummer - 2018-03-21

    Hey Shreyas,

    Glad the file worked for you.

    I've had problems in the past with false positives on virus scans. The program is flagged because it does low level system operations. I recently began SSL signing the code, which helps.

    Now it seems they flag the code as too new or too few users. Not much I can do about that.

    I have contacted Symantic and some of the others, but this still crops up every few months.

    Thanks for your interest and posts.

    Dave

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.