Topic: UEFI Bootable  (Read 33488 times)

0 Members and 1 Guest are viewing this topic.

UEFI Bootable
« on: February 25, 2013, 11:57:48 AM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Just wondering if the Win8PE SE iso that is created is UEFI compatible? With this new secure boot crap on OEM Windows 8 machines, what would be the best way to boot the newly created Win8PE SE on secure boot machines? Is there something in the Winbuilder that would format a USB drive for UEFI boot?
« Last Edit: February 25, 2013, 12:50:46 PM by laddanator »

Re: UEFI Bootable
« Reply #1 on: February 25, 2013, 05:46:21 PM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Hi Laddanator

This is already discussed in the topic http://theoven.org/index.php?topic=457.0

Zanaffer is able to boot Win8PE  via UEFI. You should build a 64 bit Win8PE for that. 32 Bit won't supported in UEFI.

Re: UEFI Bootable
« Reply #2 on: February 26, 2013, 01:40:23 AM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Hi Laddanator

This is already discussed in the topic http://theoven.org/index.php?topic=457.0

Zanaffer is able to boot Win8PE  via UEFI. You should build a 64 bit Win8PE for that. 32 Bit won't supported in UEFI.

Thanks! I made a search before I posted this topic. I seem to have over looked the topic you posted. Thanks for the help, anshad.  :great:

Re: UEFI Bootable
« Reply #3 on: February 27, 2013, 02:09:17 AM »

ChrisR

  • Moderator, Win7PE SE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 2809
Maybe not to bad to have a topic on EFI.

Just a tip, if you want to test EFI but lack the hardware, with Vmware you can open up the vmx file with notepad and add
firmware= "efi" to the second line.   Voila, it thinks its an efi bios.
It is my case, I do not have the hardware to test EFI, so I tried this morning in VMware, with success  :thumbsup:.

Here is my test, I changed the bcd path:
Code: [Select]
bcdedit /store E:\_Win8PE_SE_x64\ISO\WIM\Boot\bcd /set {default} path \EFI\Microsoft\Boot\bootmgfw.efi

bcdedit /store E:\_Win8PE_SE_Dev_x64\ISO\WIM\Boot\bcd /enum
Code: [Select]
Gestionnaire de démarrage Windows
---------------------------------
identificateur          {bootmgr}
description             Windows Boot Manager
locale                  fr-fr
inherit                 {globalsettings}
default                 {default}
displayorder            {default}
toolsdisplayorder       {memdiag}
timeout                 30

Chargeur de démarrage Windows
-----------------------------
identificateur          {default}
device                  ramdisk=[boot]\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Setup
locale                  fr-fr
inherit                 {bootloadersettings}
osdevice                ramdisk=[boot]\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot              \windows
custom:250000c2         0
detecthal               Yes
winpe                   Yes
ems                     No

I created a new ISO with oscdimg in tools folder:
Code: [Select]
oscdimg.exe -b"E:\_Win8PE_SE_Dev_x64\ISO\WIM\efi\microsoft\boot\efisys.bin" -pEF -m -n -l"Win8PESE" "E:\_Win8PE_SE_Dev_x64\ISO\WIM" "E:\_Win8PE_SE_Dev_x64\ISO\Win8PE_x64.ISO"

And Edit the vmx file for VMWare, with notepad for ex: and add at the second line
firmware= "efi"
Then, just use Win8PE x64 ISO.
To get the Setup if needed "Menu/VM/Power/Power On to Bios"

ila_rendered

I no longer have the display progress bar "windows is loading" (bootmenupolicy legacy).

There is a trick to add g4d to the BCD so when you boot to your UEFI USB drive, it will list two options, Win8PE SE and Grub4Dos (or whatever you name this option) and you highlight which to boot to. I have not successfully tested this method. Just got my hands on an Win 8 Asus with secure boot last night and I will be running test today. Will report back with more info.
With the trick to add g4d to the BCD, once you do it with success, a little tutorial from your experience would be nice :great:.


Edit: With the trick, added previously in w7pese
Code: [Select]
Copy the \efi\microsoft\boot directory up 1 level to \efi\boot and copy bootmgfw.efi from Windows\Boot\EFI to \efi\boot then rename it bootx64.efi.EFI should also worked with Win7PESE
« Last Edit: February 27, 2013, 02:16:32 AM by ChrisR »

Re: UEFI Bootable
« Reply #4 on: February 27, 2013, 02:35:31 AM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
I have an Asus Windows 8 with secure boot I am testing on. From what I understand, only 64bit version will boot from UEFI. I got Win8PE SE x64 booting from my fat32 UEFI USB drive just fine under secure boot but the problem is, I need the 32bit version to boot as well. Is there no work around to get 32bit stuff to boot under UEFI secure boot?

Quote
With the trick to add g4d to the BCD, once you do it with success, a little tutorial from your experience would be nice

No problem, still working on it. When you use UEFI mode, the bcd that is used is not from the root-boot folder. Only in Bios mode will that bcd be used. The UEFI bcd that is used is from this folder on the root of the USB efi\microsoft\boot\BCD. The bcd for UEFI is the one I am having issues with to add menu options but still working on it.  :frusty:

Re: UEFI Bootable
« Reply #5 on: February 27, 2013, 02:52:36 AM »

ChrisR

  • Moderator, Win7PE SE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 2809
The previous test is the first for me, I believe that x64 x86 is not possible without the compatibility mode.
but I do not know much, I read some small stuff, that's all  :wink:

Good test  :smile:

Edit x64 --> x86
« Last Edit: February 27, 2013, 06:08:49 AM by ChrisR »

Re: UEFI Bootable
« Reply #6 on: February 27, 2013, 03:06:42 AM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Hi Laddanator

From what i understand 32 bit won't support UEFI booting and it requires a UEFI CSM mode (a compatibility mode to boot legacy OS).

From Microsoft's UEFI white paper : "The 32-bit editions of Windows don't support UEFI features. Only 64-bit editions of Windows can take advantage of the features that 64-bit UEFI firmware enables. Fortunately, the CSM in current UEFI implementations enables 32-bit operating systems and other operating systems that don't support UEFI to boot on hardware that has UEFI firmware. But, operating systems that require a CSM to boot can't use UEFI-specific features because the CSM emulatesearlier BIOS."

Original source : http://msdn.microsoft.com/en-us/windows/hardware/gg463149.aspx

 Actually they could implement a 32 version but they decided to promote 64 bit instead.

" "Given the advent of mainstream 64-bit computing and the platform costs previously discussed, Microsoft determined that vendors would not have any interest in producing native UEFI 32-bit firmware. Microsoft has therefore chosen to not ship support for 32-bit UEFI implementations."

Source : http://setiathome.berkeley.edu/forum_thread.php?id=62057
« Last Edit: February 27, 2013, 03:12:03 AM by anshad »

Re: UEFI Bootable
« Reply #7 on: February 27, 2013, 12:39:18 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Someone much smarter than me will soon come out with a "fix" that 32 bit will run under UEFI Bios. All the Asus I have got my hands on have the csm option but most Acer tablets are UEFI only. Will 32 bit programs run under Win8PE SE 64bit? Never used a 64bit PE so never tested this.

Re: UEFI Bootable
« Reply #8 on: February 27, 2013, 01:31:46 PM »

ChrisR

  • Moderator, Win7PE SE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 2809
Will 32 bit programs run under Win8PE SE 64bit? Never used a 64bit PE so never tested this.
Yes, with the Great JFX's WoW64 plugin  :thumbsup:  It is compatible with XP, 2k3, Vista, 7 and 8 now :great:
WoW64 (Windows on Windows64) provides support for running 32bit programs in a 64bit environment.

Re: UEFI Bootable
« Reply #9 on: February 27, 2013, 02:03:13 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Thanks for the fast reply, ChrisR and thank you for this Win8 project.  :you_rock:

Re: UEFI Bootable
« Reply #10 on: February 27, 2013, 02:44:33 PM »

ChrisR

  • Moderator, Win7PE SE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 2809
Thank you very much  :thumbsup:
I'm going to sleep on these nice words.
for Wow64, full credit is to JFX, i am a lucky guy to have met him for this and more.

Re: UEFI Bootable
« Reply #11 on: March 04, 2013, 11:10:34 AM »

RogerVador

  • Jr. Chef
  • **
  • Date Registered: Dec 2012
  • Posts: 15
You need to format your USB key with fat32 only because NTFS isn't supported by Microsoft with UEFI for booting. I think it should be said with the module to format the usb key which recommend NTFS File system.

Re: UEFI Bootable
« Reply #12 on: March 08, 2013, 03:53:55 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
So I have an Acer Windows 8 Tablet and you can't disable secure boot. I made a 64bit Win8SE PE and boots fine on UEFI enabled machines but I guess secure boot is a different monkey all together and will Win8SE PE not pass secure boot check?

Never mind, just realized the Acer Tablet is 32bit
« Last Edit: March 08, 2013, 05:01:38 PM by laddanator »

Re: UEFI Bootable
« Reply #13 on: March 08, 2013, 05:51:48 PM »

anshad

  • Chef
  • ***
  • Date Registered: Apr 2012
  • Posts: 323
Hi Laddanator

Secureboot configuration is depends upon the OEM manufacturer. Some OEMs allows UEFI based CD or DVD or booting while some others (like Samsung) won't allow external medias- you could only boot from internal HDD when secureboot enabled.

Re: UEFI Bootable
« Reply #14 on: March 08, 2013, 08:58:04 PM »

RogerVador

  • Jr. Chef
  • **
  • Date Registered: Dec 2012
  • Posts: 15
With a WIN8PESE build with a Windows 8 64 bits OEM on a fat 32 usb key, I can boot on every Windows 8 OEM machine without searching in the UEFI options for the Secure BOOT, which is not always understandable .

Re: UEFI Bootable
« Reply #15 on: March 09, 2013, 02:10:00 AM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Actually got that Acer in secure boot mode to boot my Win8PE SE x86 build on a USB stick. I have my USB formatted in fat32 of course and I extracted my x86 Win8SE PE to my USB drive and copied my efi folder to root of USB and it had to have this file in that folder

efi\boot\bootia32.efi


Without that file in that folder, the USB will not even show up as a boot option.


Re: UEFI Bootable
« Reply #16 on: March 11, 2013, 02:17:59 PM »

halikus

  • Jr. Chef
  • **
  • Date Registered: Feb 2013
  • Posts: 28
A few things i learned about efi...

x86 efi is primarily for Mac (wich relies on efi) and older original incarnations of efi firmware. 

efi boots from fat32 only, and looks for efi\boot\bootx64.efi or bootia32.efi, or include both.  efi\microsoft\boot\efisys.bin is the file used to boot cd\dvds, and has the same files as efi\boot.  To author a dvd that boots legacy (mbr) and efi, decided by your bios, i use:
oscdimg -lWIN -u1 -h -m -k -oc -bootdata:2#p0,e,b.\boot\etfsboot.com#pEF,e,b.\efi\microsoft\boot\Efisys.bin .\ .\Win_BCD.iso

You can change the size of Efisys.bin (to add more files) by using ultraiso and selecting actions, change image format, and selecting a new image size and saving it.  From here on, i will only reference usb booting methods, but the same can be used by adding files to the bin for dvd.

You can add more efi boot options by using a grub2 based boot manager like refind http://sourceforge.net/projects/refind/ or grub2 or clover.
Replace the files in efi\boot\ with the refind files.  It will search for (depending on the config file) linux, mac and windows boot files on cd, dvd, usb and hdd.  It will even boot legacy (mbr) windows in efi.  Optionally, add more efi files to the config file, such as :

Code: [Select]

menuentry "Windows EFI" {
icon \efi\boot\icons\os_win.icns
loader \efi\boot\8bootx64.efi
#disabled
}

menuentry "Windows 7 x64 EFI" {
icon \efi\boot\icons\os_win.icns
loader \efi\boot\7bootx64.efi
#disabled
}

menuentry "Grub2 EFI x64" {
icon /efi/boot/icons/os_linux.icns
loader /efi/boot/grubx64.efi
#disabled
}

menuentry "CLOVER" {
loader /efi/boot/CLOVERX64.efi
icon /efi/boot/icons/os_ubuntu.icns
#disabled
}

menuentry "Ubuntu" {
loader /efi/ubuntu/BOOTx64.efi
icon /efi/boot/icons/os_ubuntu.icns
disabled
}



Efi only boots from fat32.  I prefer ntfs for the speed and the fact the file system has no size limitations.   To get around this on usb sticks, i make 2 partitions using acronis dd or easus.  The first is ntfs, and the second is a 500 meg fat32 partition.  As windows can only see one partition at a time, i use bootice http://bbs.ipauly.com/viewtopic.php?f=2&t=2 and select the usb.  Then parts manage, select the fat32 partition, and select "assign drive letter".  This will hide the ntfs partition and show the fat32 one.   Then add the efi dir, a boot.wim in sources, make it bootable with /nt60, and revert back to the ntfs partition.  Set this up as normal and make bootable with whatever you want (grub, syslinux, bootmngr, etc...).  If you have efi enableed in bios, it will boot from the hidden fat32 partition in efi, and if you use the setup files in x:\sources\setup.exe it will find and use the install.wim on the ntfs partition.  The boot.wim boots into ram, but the PE only sees the ntfs partition as its set active.  If you use ntfs, syslinux 5.01 and grub4dos 0.4.5c-2013-03-03 both work with ntfs.



For BCD booting in general, you can use the same trick EasyBCD does, but with more control.  For booting things like isos, it simply uses a custom grldr from grub4dos.   Get a grldr from grub4dos, and open it with bootice, utilities, start menu editor, and replace the entries with something like the following.

Code: [Select]
title    Boot ISO (Disk)\n  This will list ISOs in the directory ISO and allow you to boot them
ls /ISO/
set /p MYISO=Which ISO do you want to boot?
ls /ISO/%MYISO% || echo ISO %MYISO% NOT FOUND! && configfile /boot/grub4dos/menu.lst
map /ISO/%MYISO%.iso (0xff)
#map /ISO/%MYISO%.iso (hd32)
map --hook
chainloader (0xff)
#chainloader (hd32)
boot

and then add an entry to the bcd like this (i renamed grldr to boot\ISO_DISK):

Code: [Select]

echo BCD_ISO_DISK
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Boot ISO (Disk)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device boot
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_ISO_DISK
%BCDEDIT% %STORE% /displayorder %guid% /addlast


Here is a script i made that will make a custom BCD File from scratch, or add to the systems bcd.  It works for both efi and mbr.  Just rem out the things you want or dont want in  :DVDMBR, :HDDMBR, :DVDEFI, and :HDDEFI and change any paths that differ.

Code: [Select]
@echo off
rem http://diddy.boot-land.net/bcdedit/files/examples1.htm#winpe
rem for VMWARE   firmware= "efi"
title Windows V 7 8 install.wim boot.wim and BCD manipulation
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getprivileges
if '%1'=='ELEV' (shift & goto gotPrivileges) 
setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B
:gotPrivileges

:STARTBCD

REM :::Choose variables here and below for :DVDMBR, :HDDMBR, :DVDEFI, and :HDDEFI
set BCD=%~dp0BCD
Set BCDEDIT=%SYSTEMROOT%\System32\BCDEDIT.exe
REM partition letter is the drive where your files you want to boot are.  For DVD, "boot" is used.
set PartitionLetter=D:

title Choose desired BCD
cls
echo.
echo.
echo        Choose BCD type...
echo.         
echo.
echo   1 = DVD MBR (%BCD%) (Make custom BCD file)
echo.
echo   2 = HDD MBR (System) (Add entries to your system BCD)
echo.
echo   3 = DVD EFI (%BCD%) (Make custom BCD file)
echo.
echo   4 = HDD EFI (System) (Add entries to your system BCD)
echo.
echo   5 = DELETE Entry
echo   6 = RENAME BCD
echo   7 = Change ORDER of BCD
echo   8 = Add Specific Entry to BCD
echo   9 = Add Win8 Safemode to system BCD (Must be logged in to Win8)
echo   10 = Boot Legacy (Win7)
echo   11 = Boot Standard (Win8)
echo   12 = Choose Deafult boot entry
echo.
echo   ** HDD Wim and VHD files Partition = %PartitionLetter%
echo.
echo.
SET /P IM=Input number :
SET DD=
If "%IM%"=="1" goto :DVDMBR
If "%IM%"=="2" goto :HDDMBR
If "%IM%"=="3" goto :DVDEFI
If "%IM%"=="4" goto :HDDEFI
If "%IM%"=="5" goto :DeleteBCD
If "%IM%"=="6" goto :RenameBCD
If "%IM%"=="7" goto :OrderBCD
If "%IM%"=="8" goto :AddBCD
If "%IM%"=="9" goto :Win8Safemode
If "%IM%"=="10" goto :BootLegacy
If "%IM%"=="11" goto :BootStandard
If "%IM%"=="12" goto :DefaultBCD
If "%DD%"=="" echo INVALID NUMBER
If "%DD%"=="" goto :STARTBCD


:DVDMBR
rem echo f | xcopy ISO_2 bcd
rem set BCD=%~dp0BCD
set STORE=/store %BCD%
rem %BCDEDIT% /createstore %BCD%
set PartitionLetter=boot
set Partition=boot
set Path=[boot]\sources
set PathXPWIM=[boot]\boot
REM choice is for efi, leave blank for mbr
set choice=
set applicationpath=\Windows\system32\boot\winload.exe
set applicationpathHDD=\Windows\system32\winload.exe
set VHDname=VHD.vhd
rem set ramdisksdipath=\boot\boot.sdi
set bootmenupolicy=standard
set DisplayBootMenu=%BCDEDIT% %STORE% /set {bootmgr} DisplayBootMenu True
set memtest=\boot\memtest.exe
goto :CREATECUSTOMDVD%choice%


:HDDMBR
set STORE=
rem set PartitionLetter=d:
set Partition=Partition=%PartitionLetter%
set Path=[%PartitionLetter%]\sources
REM choice is for efi, leave blank for mbr
set choice=
set applicationpath=\Windows\system32\winload.exe
set applicationpathHDD=\Windows\system32\winload.exe
set VHDname=VHD.vhd
rem ?
rem set ramdisksdipath=\Windows\system32\boot.sdi
set DisplayBootMenu=%BCDEDIT% %STORE% /set {bootmgr} DisplayBootMenu False
set memtest=\Windows\Boot\PCAT\memtest.exe
%BCDEDIT% /set {current} bootmenupolicy standard
goto :CREATECUSTOMHDD%choice%



:DVDEFI
set STORE=/store %BCD%
set PartitionLetter=boot
set Partition=boot
set Path=[boot]\sources
REM choice is for efi, leave blank for mbr
set choice=EFI
set applicationpath=\Windows\system32\boot\winload.efi
set applicationpathHDD=\Windows\system32\winload.efi
set VHDname=VHD.vhd
set bootmenupolicy=standard
rem set ramdisksdipath=\boot\boot.sdi
set DisplayBootMenu=%BCDEDIT% %STORE% /set {bootmgr} DisplayBootMenu True
set memtest=\efi\microsoft\boot\memtest.efi
goto :CREATECUSTOMDVD%choice%



:HDDEFI
set STORE=
rem set PartitionLetter=d:
set Partition=Partition=%PartitionLetter%
set Path=[%PartitionLetter%]\sources
REM choice is for efi, leave blank for mbr
set choice=EFI
set applicationpath=\Windows\system32\winload.efi
set applicationpathHDD=\Windows\system32\winload.efi
set VHDname=VHD.vhd
rem ?
rem set ramdisksdipath=\Windows\system32\boot.sdi
set DisplayBootMenu=%BCDEDIT% %STORE% /set {bootmgr} DisplayBootMenu False
set memtest=\Windows\Boot\EFI\memtest.efi
%BCDEDIT% /set {current} bootmenupolicy standard
goto :CREATECUSTOMHDD%choice%





:CREATECUSTOMDVD
call :CREATEBCD
call :Ramdisk
call :BootCdriveMBRDVD
call :WIM_bootwim
call :GRUB4DOS
call :GRUB2
rem call :GRUB24DOS
call :SYSLINUX
call :ISOLINUX
call :BCD_ISO_DISK
call :BCD_ISO_MEM
call :BCD_IMG
call :BCD_GZ
rem call :ISO_Gena_WIM
rem call :XPWIM
rem call :WIM_w7x86
rem call :WIM_w7x64
rem call :WIM_w8x86
rem call :WIM_w8x64
call :WIM_DART_w7x86
call :WIM_DART_w7x64
call :WIM_DART_w8x86
call :WIM_DART_w8x64
rem call :WIM_DART_wVx86
rem call :WIM_DART_wVx64
call :XPntldrHDD
call :XPNORMAL
rem call :XPADMIN
rem call :XPES
rem call :ISO_Mac
rem call :Plop
rem call :BootC
rem call :BootD
rem call :BootE
rem call :BootF
rem call :BootG
rem call :BootH
rem call :W2Go
rem call :VHDDVD
rem call :VHDHDD
rem call :VHDXDVD
rem call :VHDXHDD
rem call :pxeWindows
call :pxelinux
call :EFI_BootBIN
rem call :MEMTEST
%BCDEDIT% %STORE% /timeout 10
rem %BCDEDIT% %STORE% /enum
rem pause
goto :ORDERBCD
goto :StartBCD



:CREATECUSTOMHDD
rem bcdboot C:\Windows
rem call :CREATEBCD
rem call :BootC
call :Ramdisk
rem call :VHDHDDw7x86
rem call :VHDHDDw7x64
call :VHDHDDw8x86
rem call :VHDHDDw8x64
rem call :XPPE
call :WIM_w8x64
rem call :WIM_w8x86
rem call :WIM_w7x64
rem call :WIM_w7x86
rem call :WIM_DART_w7x86
rem call :WIM_DART_w7x64
rem call :WIM_DART_w8x86
rem call :WIM_DART_w8x64
rem call :WIM_DART_wVx86
rem call :WIM_DART_wVx64
rem call :XPntldrHDD
rem call :XPNORMAL
rem call :XPADMIN
rem call :XPES
rem call :BootD
rem call :BootE
rem call :BootF
rem call :BootG
rem call :BootH
rem call :W2Go
rem call :VHDDVD
rem call :VHDHDD
rem call :VHDXDVD
rem call :VHDXHDD
rem call :WIM_bootwim
call :GRUB4DOS
call :SYSLINUX
%BCDEDIT% %STORE% /default {current}
%BCDEDIT% %STORE% /timeout 10
rem %BCDEDIT% %STORE% /enum
rem pause
goto :ORDERBCD
goto :StartBCD



:CREATECUSTOMDVDEFI
call :CREATEBCD
call :Ramdisk
call :WIM_bootwim
rem call :GRUB4DOS
rem call :SYSLINUX
rem call :ISOLINUX
rem call :XPPE
rem call :WIM_w7x86
rem call :WIM_w7x64
rem call :WIM_w8x86
rem call :WIM_w8x64
rem call :WIM_DART_w7x86
call :WIM_DART_w8x64
rem call :WIM_DART_w8x86
call :WIM_DART_w7x64
rem call :WIM_DART_w8x86
rem call :WIM_DART_wVx86
rem call :WIM_DART_wVx64
rem call :XPntldrHDD
rem call :XPNORMAL
rem call :XPADMIN
rem call :XPES
rem call :BootC
rem call :BootD
rem call :BootE
rem call :BootF
rem call :BootG
rem call :BootH
rem call :W2Go
rem call :VHDDVD
rem call :VHDHDD
rem call :VHDXDVD
rem call :VHDXHDD
rem call :GRUB2EFI
rem call :BootC
rem call :BootCdriveMBRDVD
rem call :GRUB4DOS
call :BootCdriveEFIDVD
%BCDEDIT% %STORE% /timeout 10
rem %BCDEDIT% %STORE% /enum
rem pause
goto :ORDERBCD
goto :StartBCD





:CREATECUSTOMHDDEFI
rem bcdboot C:\Windows
rem call :CREATEBCD
call :Ramdisk
rem call :WIM_bootwim
rem call :BootC
rem call :GRUB4DOS
rem call :SYSLINUX
rem call :ISOLINUX
rem call :XPPE
rem call :WIM_w7x86
call :WIM_w7x64
rem call :WIM_w8x86
call :WIM_w8x64
rem call :WIM_DART_w7x86
rem call :WIM_DART_w7x64
rem call :WIM_DART_w8x86
rem call :WIM_DART_w8x64
rem call :WIM_DART_wVx86
rem call :WIM_DART_wVx64
rem call :XPntldrHDD
rem call :XPNORMAL
rem call :XPADMIN
rem call :XPES
rem call :BootD
rem call :BootE
rem call :BootF
rem call :BootG
rem call :BootH
rem call :W2Go
rem call :VHDDVD
rem call :VHDHDD
rem call :VHDXDVD
rem call :VHDXHDD
%BCDEDIT% %STORE% /default {current}
%BCDEDIT% %STORE% /timeout 10
rem %BCDEDIT% %STORE% /enum
rem pause
goto :ORDERBCD
goto :StartBCD





:DELETEBCD
echo.
echo   1 = DVD (%BCD%)
echo.
echo   2 = HDD (System)
echo.
echo.
SET /P IM=Input number :
SET DD=
If "%IM%"=="1" goto :DVD
If "%IM%"=="2" goto :HDD
If "%DD%"=="" echo INVALID NUMBER
If "%DD%"=="" goto :STARTBCD

:DVD
set STORE=/store %BCD%
goto :DELETEBCD1

:HDD
set STORE=
goto :DELETEBCD1

:DELETEBCD1
set _count=1
for /f "tokens=1* usebackq skip=1" %%a in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "identifier""`) do (call :DELETEBCD2 %_count%)
:DELETEBCD2
if "%1" neq "" (set /a _count+=1 &for /f "tokens=1* usebackq skip=%_count%" %%c in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "description""`) do (echo            %_count%. %%d &goto :eof))
set _choice=
echo.
echo.
set /p _choice=Enter a number (Q to quit):
echo.
echo.
if "%_choice%" equ "" goto :STARTBCD
if "%_choice%" gtr "0" if %_choice% lss %_count% for /f "tokens=2 usebackq skip=%_choice%" %%a in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "identifier""`) do (%BCDEDIT% %STORE% /delete %%a /f &goto :DELETEBCD1)
goto :STARTBCD









:Win8Safemode
 %BCDEDIT% /copy {current} /d "Windows 8 (Safe Mode)"
 %BCDEDIT% /timeout 10
 cls
  echo.
  echo.
  echo   Activate Win8 Safe Mode
  echo.
  echo.
set _count=1
for /f "tokens=1* usebackq skip=1" %%a in (`"%BCDEDIT% | c:\windows\system32\find "identifier""`) do (call :safemode %_count%)
:safemode 
if "%1" neq "" (set /a _count+=1 &for /f "tokens=1* usebackq skip=%_count%" %%c in (`"%BCDEDIT% | c:\windows\system32\find "description""`) do (echo            %_count%. %%d &goto :eof))
set _choice=
echo.
echo.
set /p _choice=Enter a number (Q to quit):
echo.
echo.
if "%_choice%" equ "" goto :eof
if "%_choice%" gtr "0" if %_choice% lss %_count% for /f "tokens=2 usebackq skip=%_choice%" %%a in (`"%BCDEDIT% | c:\windows\system32\find "identifier""`) do (%BCDEDIT% /set %%a safeboot minimal &goto :safemode2)
:safemode2
cd c:\windows\system32
reagentc /enable
 %BCDEDIT% /set {current} bootmenupolicy standard
 %BCDEDIT%
pause
goto :StartBCD













:CREATEBCD
Echo Create BCD
%BCDEDIT% /createstore %BCD%

Echo Create BootManager
%BCDEDIT% %STORE% /create {bootmgr}
%BCDEDIT% %STORE% /set {bootmgr} description "Windows Boot Manager"
%BCDEDIT% %STORE% /set {bootmgr} device %partition%
%BCDEDIT% %STORE% /set {bootmgr} locale en-US
%BCDEDIT% %STORE% /set {bootmgr} nointegritychecks YES
rem ***displaybootmenu disables win8 menu***
rem %BCDEDIT% %STORE% /set {bootmgr} DisplayBootMenu True
%DisplayBootMenu%
%BCDEDIT% %STORE% /timeout 10
Echo Bad memory
%BCDEDIT% %STORE% /create {badmemory}
Echo EMS
%BCDEDIT% %STORE% /create {emssettings}
rem text
rem %BCDEDIT% %STORE% /set {emssettings} bootems "Yes"
rem UI
%BCDEDIT% %STORE% /set {emssettings} bootems "No"
Echo Debug
%BCDEDIT% %STORE% /create {dbgsettings}
%BCDEDIT% %STORE% /dbgsettings SERIAL DEBUGPORT:1 BAUDRATE:115200
Echo Hypervisor
%BCDEDIT% %STORE% /create {hypervisorsettings}
%BCDEDIT% %STORE% /hypervisorsettings SERIAL DEBUGPORT:1 BAUDRATE:115200
Echo Global settings
%BCDEDIT% %STORE% /create {globalsettings}
%BCDEDIT% %STORE% /set {globalsettings} INHERIT {dbgsettings} {emssettings} {badmemory}
%BCDEDIT% %STORE% /set {bootmgr} INHERIT {globalsettings}
Echo Bootloader settings
%BCDEDIT% %STORE% /create {bootloadersettings}
%BCDEDIT% %STORE% /set {bootloadersettings} INHERIT {globalsettings} {hypervisorsettings}
Echo Resume
REM %BCDEDIT% %STORE% /create {resumeloadersettings}
REM %BCDEDIT% %STORE% /set {resumeloadersettings} INHERIT {globalsettings}
Echo Memtest
%BCDEDIT% %STORE% /create {memdiag}
%BCDEDIT% %STORE% /set {memdiag} description "Windows Memory Diagnostic"
rem %BCDEDIT% %STORE% /set {memdiag} device partition=\Device\HarddiskVolume1
%BCDEDIT% %STORE% /set {memdiag} device %partition%
%BCDEDIT% %STORE% /set {memdiag} path %memtest%
%BCDEDIT% %STORE% /set {memdiag} locale en-US
%BCDEDIT% %STORE% /set {memdiag} inherit {globalsettings}
REM %BCDEDIT% %STORE% /set {memdiag} badmemoryaccess Yes
%BCDEDIT% %STORE% /toolsdisplayorder {memdiag}
goto :eof



:Ramdisk
Echo Ramdisk settings
%BCDEDIT% %STORE% /create {ramdiskoptions}
%BCDEDIT% %STORE% /set {ramdiskoptions} ramdisksdidevice %partition%
rem %BCDEDIT% %STORE% /set {ramdiskoptions} ramdisksdipath %ramdisksdipath%
%BCDEDIT% %STORE% /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
goto :eof


:MEMTEST
echo MEMTEST
%BCDEDIT% %STORE% /create {memdiag}
%BCDEDIT% %STORE% /set {memdiag} description "Windows Memory Diagnostic"
rem %BCDEDIT% %STORE% /set {memdiag} device partition=\Device\HarddiskVolume1
%BCDEDIT% %STORE% /set {memdiag} device %partition%
%BCDEDIT% %STORE% /set {memdiag} path %memtest%
rem %BCDEDIT% %STORE% /set {memdiag} locale en-US
rem %BCDEDIT% %STORE% /set {memdiag} inherit {globalsettings}
REM %BCDEDIT% %STORE% /set {memdiag} badmemoryaccess Yes
%BCDEDIT% %STORE% /toolsdisplayorder {memdiag}
%BCDEDIT% %STORE% /displayorder {memdiag} /addlast
goto :eof



:BCD_ISO_DISK
echo BCD_ISO_DISK
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Boot ISO (Disk)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_ISO_DISK
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:BCD_ISO_MEM
echo BCD_ISO_MEM
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Boot ISO (Memory)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_ISO_MEM
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:BCD_IMG
echo BCD_IMG
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Boot IMG (Floppy Image)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_IMG
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:BCD_GZ
echo BCD_GZ
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Boot GZ Zip file (Memdisk)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_GZ
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:BCD_ISO_Mac
echo BCD_ISO_Mac
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Mac OSX Boot Loader (Chameleon)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_ISO_Mac
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:Plop
echo Plop
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Plop" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCD_ISO_Plop
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:GRUB4DOS
echo GRUB4DOS
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Grub4dos" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\grub4dos\grldr
rem %BCDEDIT% %STORE% /set %guid% path \grldr.mbr
rem %BCDEDIT% %STORE% /set %guid% path \boot\grub\grldr.mbr
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:GRUB2
echo GRUB2
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Grub2" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\grub\g2ldr
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:GRUB2EFI
echo GRUB2
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Grub2 %choice%" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \efi\boot\grubx64.efi
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:BURG
echo BURG
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Burg" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\burg\g2ldr
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:SYSLINUX
echo SYSLINUX
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Syslinux (USB)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\syslinux\syslinux.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:ISOLINUX
echo ISOLINUX
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "Isolinux (CD\DVD)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\syslinux\isolinux.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:EFI_BootBIN
echo SYSLINUX
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "EFI Boot" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \efi\microsoft\boot\Grub.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof




:XPPE
echo XP PE
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "WinXP Mini PE" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\SETUPLDR.BIN
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:ISO_Gena_WIM
echo Gena_WIM
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "GenaXP LiveCD" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\BCDs\ISO_Gena_WIM
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:XPntldrHDD
echo XP HDD
%BCDEDIT% %STORE% /create {ntldr} /d "WinXP {ntldr}"
%BCDEDIT% %STORE% /set {ntldr} device %partition%
%BCDEDIT% %STORE% /set {ntldr} path \ntldr
%BCDEDIT% %STORE% /displayorder {ntldr} /addlast
goto :eof
:XPNORMAL
echo XP normal
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "WinXP (SETUPLDR.bin) (CD\DVD)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \I386\SETUPLDR.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof
:XPADMIN
echo XP admin
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "WinXP Admin (i386\SETUPLDU.bin) (CD\DVD)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \I386\SETUPLDU.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof
:XPES
echo XP Enter settings
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "WinXP Enter Settings (i386\SETUPLDE.bin) (CD\DVD)" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \I386\SETUPLDE.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:W2Go
echo Windows to go
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "Windows to Go [boot] (Win8 Enterprise)"
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% osdevice %partition%
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDDVD
echo VHDDVD
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\%VHDname%
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\%VHDname%
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "VHD (%Path%\%VHDname%)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDHDD
echo VHDHDD
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\%VHDname%
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\%VHDname%
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "VHD (%Path%\%VHDname%)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof

:VHDXDVD
echo VHDDVD
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\%VHDname%x
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\%VHDname%x
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "VHDX (%Path%\%VHDname%x)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDXHDD
echo VHDHDD
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\%VHDname%x
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\%VHDname%x
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "VHDX (%Path%\%VHDname%)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDHDDw7x86
echo VHDHDDw7x86
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\w7x86.vhd
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\w7x86.vhd
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "w7x86 VHD (%Path%\w7x86.vhd)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDHDDw7x64
echo VHDHDDw7x64
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\w7x64.vhd
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\w7x64.vhd
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "w7x64 VHD (%Path%\w7x64.vhd)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDHDDw8x86
echo VHDHDDw8x86
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\w8x86.vhd
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\w8x86.vhd
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "w8x86 VHD (%Path%\w8x86.vhd)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:VHDHDDw8x64
echo VHDHDDw8x64
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device vhd=%Path%\w8x64.vhd
%BCDEDIT% %STORE% /set %guid% path %applicationpath%
%BCDEDIT% %STORE% /set %guid% osdevice vhd=%Path%\w8x64.vhd
rem %BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "w8x64 VHD (%Path%\w8x64.vhd)"
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof


:pxelinux
echo pxelinux
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "pxelinux" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
%BCDEDIT% %STORE% /set %guid% path \boot\syslinux\pxelinux.bin
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:pxeWindows
echo pxeWindows
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /d "pxeboot.n12" /application bootsector') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device %partition%
REM %BCDEDIT% %STORE% /set %guid% path \boot\bootpxe\grldr
%BCDEDIT% %STORE% /set %guid% path \boot\bootpxe\pxeboot.n12
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof




:BootCdriveMBRDVD
echo BootCdriveMBRDVD
set Drive=c:
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device partition=%Drive%
%BCDEDIT% %STORE% /set %guid% path \Windows\system32\winload.exe
%BCDEDIT% %STORE% /set %guid% osdevice partition=%Drive%
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "Windows %Drive%"
%BCDEDIT% %STORE% /set %guid% bootmenupolicy %bootmenupolicy%
rem %BCDEDIT% %STORE% /set %guid% detecthal yes
%BCDEDIT% %STORE% /set %guid% nx optin
%BCDEDIT% %STORE% /set %guid% locale en-us
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:BootCdriveEFIDVD
echo BootCdriveMBRDVD
set Drive=c:
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device partition=%Drive%
%BCDEDIT% %STORE% /set %guid% path \Windows\system32\winload.efi
%BCDEDIT% %STORE% /set %guid% osdevice partition=%Drive%
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "Windows %Drive%"
%BCDEDIT% %STORE% /set %guid% bootmenupolicy %bootmenupolicy%
rem %BCDEDIT% %STORE% /set %guid% detecthal yes
%BCDEDIT% %STORE% /set %guid% nx optin
%BCDEDIT% %STORE% /set %guid% locale en-us
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof




:BootC
echo Windows c:
set Drive=C:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootD
echo Windows D:
set Drive=D:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootE
echo Windows E:
set Drive=E:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootF
echo Windows F:
set Drive=F:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootG
echo Windows G:
set Drive=G:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootH
echo Windows H:
set Drive=H:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootI
echo Windows I:
set Drive=I:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootJ
echo Windows J:
set Drive=J:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BootK
echo Windows K:
set Drive=K:
set bootmenupolicy=standard
rem set bootmenupolicy=legacy
goto :BOOT
:BOOT
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% device partition=%Drive%
%BCDEDIT% %STORE% /set %guid% path %applicationpathHDD%
%BCDEDIT% %STORE% /set %guid% osdevice partition=%Drive%
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% description "Windows %choice% %Drive%"
rem %BCDEDIT% %STORE% /set %guid% bootmenupolicy %bootmenupolicy%
%BCDEDIT% %STORE% /set %guid% detecthal yes
%BCDEDIT% %STORE% /set %guid% nx optin
rem %BCDEDIT% %STORE% /set %guid% locale en-US
rem for bitlocker library_custom:0x17000077 set to 3   BcdLibraryIntegerList_AllowedInMemorySettings, i dunno...
rem %BCDEDIT% %STORE% /set %guid%  ems "yes"
rem %BCDEDIT% %STORE% /ems %guid% on
rem %BCDEDIT% %STORE% /set %guid2%  RecoveryOs true
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof



:WIM_bootwim
Echo boot.wim
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set guid=%%A
%BCDEDIT% %STORE% /set %guid% systemroot \windows
%BCDEDIT% %STORE% /set %guid% detecthal yes
%BCDEDIT% %STORE% /set %guid% winpe yes
%BCDEDIT% %STORE% /set %guid% OSDEVICE ramdisk=%path%\boot.wim,{ramdiskoptions}
%BCDEDIT% %STORE% /set %guid% DEVICE ramdisk=%path%\boot.wim,{ramdiskoptions}
%BCDEDIT% %STORE% /set %guid% description "Windows Setup %choice% (%path%\boot.wim)"
rem %BCDEDIT% %STORE% /set %guid% path %applicationpath%
rem %BCDEDIT% %STORE% /set %guid% locale en-US
rem %BCDEDIT% %STORE% /set %guid% INHERIT {bootloadersettings}
rem %BCDEDIT% %STORE% /set %guid% bootmenupolicy legacy
rem %BCDEDIT% %STORE% /set %guid% bootmenupolicy standard
rem %BCDEDIT% %STORE% /set %guid%  nx optin
rem %BCDEDIT% %STORE% /set %guid%  ems "no"
rem %BCDEDIT% %STORE% /ems %guid% on
rem %BCDEDIT% %STORE% /bootems %guid% on
%BCDEDIT% %STORE% /default %guid% 
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof




:WIM_DART_w7x86
echo Win DART 7 %choice% x86
set pename="Win7 %choice% Setup\DART x86 (%path%\w7x86\boot.wim)"
set filena=%Path%\w7x86\boot.wim
goto :WIMAll
:WIM_DART_w7x64
echo Win DART 7 %choice% x64
set pename="Win7 %choice% Setup\DART x64 (%path%\w7x64\boot.wim)"
set filena=%Path%\w7x64\boot.wim
goto :WIMAll
:WIM_DART_w8x86
echo Win DART 8 %choice% x86
set pename="Win8 %choice% Setup\DART x86 (%path%\w8x86\boot.wim)"
set filena=%Path%\w8x86\boot.wim
goto :WIMAll
:WIM_DART_w8x64
echo Win DART 8 %choice% x64
set pename="Win8 %choice% Setup\DART x64 (%path%\w8x64\boot.wim)"
set filena=%Path%\w8x64\boot.wim
goto :WIMAll
:WIM_DART_wVx86
echo Win DART Vista %choice% x86
set pename="Vista %choice% Setup\DART x86 (%path%\wVx86\boot.wim)"
set filena=%Path%\wVx86\boot.wim
goto :WIMAll
:WIM_DART_wVx64
echo Win DART Vista x64
set pename="Vista %choice% Setup\DART x64 (%path%\wVx64\boot.wim)"
set filena=%Path%\wVx64\boot.wim
goto :WIMAll
:WIM_w7x86
echo WinPE 7 %choice%
set pename="WinPE 7 %choice% x86 (%path%\w7x86.wim)"
set filena=%Path%\w7x86.wim
goto :WIMAll
:WIM_w7x64
echo WinPE 7 %choice% x64
set pename="WinPE 7 %choice% x64 (%path%\w7x64.wim)"
set filena=%Path%\w7x64.wim
goto :WIMAll
:WIM_w8x86
echo WinPE 8 %choice%
set pename="WinPE 8 %choice% x86 (%path%\w8x86.wim)"
set filena=%Path%\w8x86.wim
goto :WIMAll
:WIM_w8x64
echo WinPE 8 %choice% x64
set pename="WinPE 8 %choice% x64 (%path%\w8x64.wim)"
set filena=%Path%\w8x64.wim
goto :WIMAll

:WIMALL
rem create a new ramdisk where you can specify a different boot.sdi.  last entry here http://diddy.boot-land.net/bcdedit/files/examples1.htm#winpe
for /f "tokens=3" %%A in ('%BCDEDIT% %STORE% /create /device') do set ramdisk=%%A
%BCDEDIT% %STORE% /set %ramdisk% ramdisksdidevice %partition%
%BCDEDIT% %STORE% /set %ramdisk% ramdisksdipath \boot\boot.sdi
for /f "Tokens=3" %%A in ('%BCDEDIT% %STORE% /create /application osloader') do set GUID=%%A
%BCDEDIT% %STORE% /set %guid% systemroot \Windows
%BCDEDIT% %STORE% /set %guid% detecthal Yes
%BCDEDIT% %STORE% /set %guid% winpe Yes
%BCDEDIT% %STORE% /set %guid% osdevice ramdisk=%filena%,%ramdisk%
%BCDEDIT% %STORE% /set %guid% device ramdisk=%filena%,%ramdisk%
rem %BCDEDIT% %STORE% /set %guid% osdevice ramdisk=[C:]\Sources\boot.wim,%ramdisk%
rem %BCDEDIT% %STORE% /set %guid% device ramdisk=[C:]\Sources\boot.wim,%ramdisk%
rem %BCDEDIT% %STORE% /set %guid% path %applicationpath%
rem %BCDEDIT% %STORE% /set %guid% locale en-US
rem %BCDEDIT% %STORE% /set %guid% INHERIT {bootloadersettings}
rem %BCDEDIT% %STORE% /set %guid% bootmenupolicy legacy
rem %BCDEDIT% %STORE% /set %guid% bootmenupolicy standard
rem %BCDEDIT% %STORE% /set %guid%  nx optin
rem %BCDEDIT% %STORE% /set %guid%  ems "no"
rem %BCDEDIT% %STORE% /ems %guid% on
rem %BCDEDIT% %STORE% /bootems %guid% on
rem %BCDEDIT% %STORE% /default %guid% 
%BCDEDIT% %STORE% /set %guid% description %pename%
%BCDEDIT% %STORE% /displayorder %guid% /addlast
goto :eof







:ORDERBCD
title Choose Order or quit
cls
%BCDEDIT% %STORE%
echo. 
echo   Ordering of items on the Boot Menu   
echo.       
set _count=1
for /f "tokens=1* usebackq skip=1" %%a in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "identifier""`) do (call :ORDERBCD1 %_count%)
:ORDERBCD1
if "%1" neq "" (set /a _count+=1 &for /f "tokens=1* usebackq skip=%_count%" %%c in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "description""`) do (echo            %_count%. %%d &goto :eof))
echo.
echo   Choose one you want to put into the first slot or exit
echo.
set _choice=
set /p _choice=Enter a number (Q to quit):
if "%_choice%" equ "" goto :ORDERBCD
if "%_choice%" equ "q" goto :STARTbcd
if "%_choice%" gtr "0" if %_choice% lss %_count% for /f "tokens=2 usebackq skip=%_choice%" %%a in (`"%BCDEDIT% %STORE% | c:\windows\system32\find "identifier""`) do (%BCDEDIT% %STORE% /displayorder %%a /addfirst &goto :STARTbcd)
%BCDEDIT% %STORE%
pause
goto :eof


:eof




Re: UEFI Bootable
« Reply #17 on: March 11, 2013, 03:43:13 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
WOW, halikus, you are very knowledgeable on (U)EFI booting. Great post. I know gurb2 will boot some iso like g4d but not sure how to do so. Are you saying that with the codes in your post, a secure boot (U)EFI Windows 8 can boot g4d? I can boot g4d in Bios mode fine but most tablets do not have an option to "turn off" secure boot.

Re: UEFI Bootable
« Reply #18 on: March 11, 2013, 04:31:02 PM »

halikus

  • Jr. Chef
  • **
  • Date Registered: Feb 2013
  • Posts: 28
Most of my efi knowledge comes from me chasing my tail trying to efi boot on an asus "hybrid efi" bios.  They have since upgraded their bios to support real efi, but before they did, it was a nightmare.  Because of this, im not 100% sure if my bios is a 100% efi one, or if it is simply patched to fool software.   So, im not sure if my results are what are considered normal.  I have this http://www.gigabyte.com/products/product-page.aspx?pid=4015#bios

That being said, i have never (knowingly) used secure boot, but googled it and read a bit about it just now.  From what i have read, im not 100% sure if it is something you have to activate, or if it is in the bios firmware by default.  Assuming its in the bios, and my bios has it, i have been able to install linux, windows, grub4dos and syslinux under mbr legacy mode, and windows in efi.   When booting from an efi file, in my case refinds bootx64.efi, it will boot (chainload?) any efi file i direct the refinf.conf to.   My whole config file looks like this, and it may explain a few of its capabilities better than i can.  Chameleon efi bootloader for macs may also help do things outside the box.

Code: [Select]
#
# refind.conf
# Configuration file for the rEFInd boot menu
#

# Timeout in seconds for the main menu screen. Setting the timeout to 0
# disables automatic booting (i.e., no timeout).
#
timeout 20

# Hide user interface elements for personal preference or to increase
# security:
#  banner      - the rEFInd title banner (built-in or loaded via "banner")
#  label       - boot option text label in the menu
#  singleuser  - remove the submenu options to boot Mac OS X in single-user
#                or verbose modes; affects ONLY MacOS X
#  safemode    - remove the submenu option to boot Mac OS X in "safe mode"
#  hwtest      - the submenu option to run Apple's hardware test
#  arrows      - scroll arrows on the OS selection tag line
#  hints       - brief command summary in the menu
#  editor      - the options editor (+, F2, or Insert on boot options menu)
#  all         - all of the above
# Default is none of these (all elements active)
#
#hideui singleuser
#hideui all

# Set the name of a subdirectory in which icons are stored. Icons must
# have the same names they have in the standard directory. The directory
# name is specified relative to the main rEFInd binary's directory. If
# an icon can't be found in the specified directory, an attempt is made
# to load it from the default directory; thus, you can replace just some
# icons in your own directory and rely on the default for others.
# Default is "icons".
#
#icons_dir myicons
#icons_dir icons,EFI/boot/icons

# Use a custom title banner instead of the rEFInd icon and name. The file
# path is relative to the directory where refind.efi is located. The color
# in the top left corner of the image is used as the background color
# for the menu screens. Currently uncompressed BMP images with color
# depths of 24, 8, 4 or 1 bits are supported, as well as PNG images.
#
#banner hostname.bmp
#banner mybanner.png
#banner splash.bmp

# Custom images for the selection background. There is a big one (144 x 144)
# for the OS icons, and a small one (64 x 64) for the function icons in the
# second row. If only a small image is given, that one is also used for
# the big icons by stretching it in the middle. If only a big one is given,
# the built-in default will be used for the small icons.
#
# Like the banner option above, these options take a filename of an
# uncompressed BMP image file with a color depth of 24, 8, 4, or 1 bits,
# or a PNG image. The PNG format is required if you need transparency
# support (to let you "see through" to a full-screen banner).
#
#selection_big   selection-big.bmp
#selection_small selection-small.bmp

# Set the font to be used for all textual displays in graphics mode.
# The font must be a PNG file with alpha channel transparency. It must
# contain ASCII characters 32-126 (space through tilde), inclusive, plus
# a glyph to be displayed in place of characters outside of this range,
# for a total of 96 glyphs. Only monospaced fonts are supported. Fonts
# may be of any size, although large fonts can produce display
# irregularities.
# The default is rEFInd's built-in font, Luxi Mono Regular 12 point.
#
#font myfont.png

# Use text mode only. When enabled, this option forces rEFInd into text mode.
# Passing this option a "0" value causes graphics mode to be used. Pasing
# it no value or any non-0 value causes text mode to be used.
# Default is to use graphics mode.
#
#textonly

# Set the EFI text mode to be used for textual displays. This option
# takes a single digit that refers to a mode number. Mode 0 is normally
# 80x25, 1 is sometimes 80x50, and higher numbers are system-specific
# modes. Mode 1024 is a special code that tells rEFInd to not set the
# text mode; it uses whatever was in use when the program was launched.
# If you specify an invalid mode, rEFInd pauses during boot to inform
# you of valid modes.
# CAUTION: On VirtualBox, and perhaps on some real computers, specifying
# a text mode and uncommenting the "textonly" option while NOT specifying
# a resolution can result in an unusable display in the booted OS.
# Default is 1024 (no change)
#
#textmode 2

# Set the screen's video resolution. Pass this option either:
#  * two values, corresponding to the X and Y resolutions
#  * one value, corresponding to a GOP (UEFI) video mode
# Note that not all resolutions are supported. On UEFI systems, passing
# an incorrect value results in a message being shown on the screen to
# that effect, along with a list of supported modes. On EFI 1.x systems
# (e.g., Macintoshes), setting an incorrect mode silently fails. On both
# types of systems, setting an incorrect resolution results in the default
# resolution being used. A resolution of 1024x768 usually works, but higher
# values often don't.
# Default is "0 0" (use the system default resolution, usually 800x600).
#
#resolution 1024 768
#resolution 3

# Launch specified OSes in graphics mode. By default, rEFInd switches
# to text mode and displays basic pre-launch information when launching
# all OSes except OS X. Using graphics mode can produce a more seamless
# transition, but displays no information, which can make matters
# difficult if you must debug a problem. Also, on at least one known
# computer, using graphics mode prevents a crash when using the Linux
# kernel's EFI stub loader. You can specify an empty list to boot all
# OSes in text mode.
# Valid options:
#   osx     - Mac OS X
#   linux   - A Linux kernel with EFI stub loader
#   elilo   - The ELILO boot loader
#   grub    - The GRUB (Legacy or 2) boot loader
#   windows - Microsoft Windows
# Default value: osx
#
#use_graphics_for osx,linux
use_graphics_for osx,linux,elilo,grub,windows

# Which non-bootloader tools to show on the tools line, and in what
# order to display them:
#  shell           - the EFI shell (requires external program; see rEFInd
#                    documentation for details)
#  gptsync         - the (dangerous) gptsync.efi utility (requires external
#                    program; see rEFInd documentation for details)
#  apple_recovery  - boots the Apple Recovery HD partition, if present
#  mok_tool        - makes available the Machine Owner Key (MOK) maintenance
#                    tool, MokManager.efi, used on Secure Boot systems
#  about           - an "about this program" option
#  exit            - a tag to exit from rEFInd
#  shutdown        - shuts down the computer (a bug causes this to reboot
#                    EFI systems)
#  reboot          - a tag to reboot the computer
# Default is shell,apple_recovery,mok_tool,about,shutdown,reboot
#
#showtools shell, mok_tool, about, reboot, exit
#showtools shell,apple_recovery,mok_tool,about,shutdown,reboot
showtools shell,reboot,Exit

# Directories in which to search for EFI drivers. These drivers can
# provide filesystem support, give access to hard disks on plug-in
# controllers, etc. In most cases none are needed, but if you add
# EFI drivers and you want rEFInd to automatically load them, you
# should specify one or more paths here. rEFInd always scans the
# "drivers" and "drivers_{arch}" subdirectories of its own installation
# directory (where "{arch}" is your architecture code); this option
# specifies ADDITIONAL directories to scan.
# Default is to scan no additional directories for EFI drivers
#
#scan_driver_dirs EFI/tools/drivers,drivers
#scan_driver_dirs drivers,efi/refind/drivers_x64,efi/boot/drivers_x64

# Which types of boot loaders to search, and in what order to display them:
#  internal      - internal EFI disk-based boot loaders
#  external      - external EFI disk-based boot loaders
#  optical       - EFI optical discs (CD, DVD, etc.)
#  hdbios        - BIOS disk-based boot loaders
#  biosexternal  - BIOS external boot loaders (USB, eSATA, etc.)
#  cd            - BIOS optical-disc boot loaders
#  manual        - use stanzas later in this configuration file
# Note that the legacy BIOS options require firmware support, which is
# not present on all computers.
# On UEFI PCs, default is internal,external,optical,manual
# On Macs, default is internal,hdbios,external,biosexternal,optical,cd,manual
#
#scanfor internal,external,optical,manual
#scanfor manual,hdbios,biosexternal,cd,internal,external,optical
scanfor manual,hdbios,biosexternal,internal

# Delay for the specified number of seconds before scanning disks.
# This can help some users who find that some of their disks
# (usually external or optical discs) aren't detected initially,
# but are detected after pressing Esc.
# The default is 0.
#
#scan_delay 5

# When scanning volumes for EFI boot loaders, rEFInd always looks for
# Mac OS X's and Microsoft Windows' boot loaders in their normal locations,
# and scans the root directory and every subdirectory of the /EFI directory
# for additional boot loaders, but it doesn't recurse into these directories.
# The also_scan_dirs token adds more directories to the scan list.
# Directories are specified relative to the volume's root directory. This
# option applies to ALL the volumes that rEFInd scans UNLESS you include
# a volume name and colon before the directory name, as in "myvol:/somedir"
# to scan the somedir directory only on the filesystem named myvol. If a
# specified directory doesn't exist, it's ignored (no error condition
# results). The default is to scan the "boot" directory in addition to
# various hard-coded directories.
#
also_scan_dirs boot,ESP2:EFI/linux/kernels

# Partitions to omit from scans. You must specify a volume by its
# label, which you can obtain in an EFI shell by typing "vol", from
# Linux by typing "blkid /dev/{devicename}", or by examining the
# disk's label in various OSes' file browsers.
# The default is "Recovery HD".
#
#dont_scan_volumes "Recovery HD"

# Directories that should NOT be scanned for boot loaders. By default,
# rEFInd doesn't scan its own directory or the EFI/tools directory.
# You can "blacklist" additional directories with this option, which
# takes a list of directory names as options. You might do this to
# keep EFI/boot/bootx64.efi out of the menu if that's a duplicate of
# another boot loader or to exclude a directory that holds drivers
# or non-bootloader utilities provided by a hardware manufacturer. If
# a directory is listed both here and in also_scan_dirs, dont_scan_dirs
# takes precedence. Note that this blacklist applies to ALL the
# filesystems that rEFInd scans, not just the ESP, unless you precede
# the directory name by a filesystem name, as in "myvol:EFI/somedir"
# to exclude EFI/somedir from the scan on the myvol volume but not on
# other volumes.
#
#dont_scan_dirs ESP:/EFI/boot,EFI/Dell

# Files that should NOT be included as EFI boot loaders (on the
# first line of the display). If you're using a boot loader that
# relies on support programs or drivers that are installed alongside
# the main binary or if you want to "blacklist" certain loaders by
# name rather than location, use this option. Note that this will
# NOT prevent certain binaries from showing up in the second-row
# set of tools. Most notably, MokManager.efi is in this blacklist,
# but will show up as a tool if present in certain directories. You
# can control the tools row with the showtools token.
# The default is shim.efi,TextMode.efi,ebounce.efi,GraphicsConsole.efi,MokManager.efi,HashTool.efi,HashTool-signed.efi
#
#dont_scan_files shim.efi,MokManager.efi

# Scan for Linux kernels that lack a ".efi" filename extension. This is
# useful for better integration with Linux distributions that provide
# kernels with EFI stub loaders but that don't give those kernels filenames
# that end in ".efi", particularly if the kernels are stored on a
# filesystem that the EFI can read. When uncommented, this option causes
# all files in scanned directories with names that begin with "vmlinuz"
# or "bzImage" to be included as loaders, even if they lack ".efi"
# extensions. The drawback to this option is that it can pick up kernels
# that lack EFI stub loader support and other files. Passing this option
# a "0" value causes kernels without ".efi" extensions to NOT be scanned;
# passing it alone or with any other value causes all kernels to be scanned.
# Default is to NOT scan for kernels without ".efi" extensions.
#
scan_all_linux_kernels

# Set the maximum number of tags that can be displayed on the screen at
# any time. If more loaders are discovered than this value, rEFInd shows
# a subset in a scrolling list. If this value is set too high for the
# screen to handle, it's reduced to the value that the screen can manage.
# If this value is set to 0 (the default), it's adjusted to the number
# that the screen can handle.
#
#max_tags 0

# Set the default menu selection.  The available arguments match the
# keyboard accelerators available within rEFInd.  You may select the
# default loader using:
#  - A digit between 1 and 9, in which case the Nth loader in the menu
#    will be the default.
#  - Any substring that corresponds to a portion of the loader's title
#    (usually the OS's name or boot loader's path).
#
#default_selection 1

# Include a secondary configuration file within this one. This secondary
# file is loaded as if its options appeared at the point of the "include"
# token itself, so if you want to override a setting in the main file,
# the secondary file must be referenced AFTER the setting you want to
# override. Note that the secondary file may NOT load a tertiary file.
#
#include manual.conf

# Sample manual configuration stanzas. Each begins with the "menuentry"
# keyword followed by a name that's to appear in the menu (use quotes
# if you want the name to contain a space) and an open curly brace
# ("{"). Each entry ends with a close curly brace ("}"). Common
# keywords within each stanza include:
#
#  volume    - identifies the filesystem from which subsequent files
#              are loaded. You can specify the volume by label or by
#              a number followed by a colon (as in "0:" for the first
#              filesystem or "1:" for the second).
#  loader    - identifies the boot loader file
#  initrd    - Specifies an initial RAM disk file
#  icon      - specifies a custom boot loader icon
#  ostype    - OS type code to determine boot options available by
#              pressing Insert. Valid values are "MacOS", "Linux",
#              "Windows", and "XOM". Case-sensitive.
#  graphics  - set to "on" to enable graphics-mode boot (useful
#              mainly for MacOS) or "off" for text-mode boot.
#              Default is auto-detected from loader filename.
#  options   - sets options to be passed to the boot loader; use
#              quotes if more than one option should be passed or
#              if any options use characters that might be changed
#              by rEFInd parsing procedures (=, /, #, or tab).
#  disabled  - use alone or set to "yes" to disable this entry.
#
# Note that you can use either DOS/Windows/EFI-style backslashes (\)
# or Unix-style forward slashes (/) as directory separators. Either
# way, all file references are on the ESP from which rEFInd was
# launched.
# Use of quotes around parameters causes them to be interpreted as
# one keyword, and for parsing of special characters (spaces, =, /,
# and #) to be disabled. This is useful mainly with the "options"
# keyword. Use of quotes around parameters that specify filenames is
# permissible, but you must then use backslashes instead of slashes,
# except when you must pass a forward slash to the loader, as when
# passing a root= option to a Linux kernel.

# Below are several sample boot stanzas. All are disabled by default.
# Find one similar to what you need, copy it, remove the "disabled" line,
# and adjust the entries to suit your needs.



menuentry "Windows EFI" {
icon \efi\boot\icons\os_win.icns
loader \efi\boot\8bootx64.efi
#disabled
}

menuentry "Windows 7 x64 EFI" {
icon \efi\boot\icons\os_win.icns
loader \efi\boot\7bootx64.efi
disabled
}


menuentry "Windows Vista x64 EFI" {
icon \efi\boot\icons\os_win.icns
loader \efi\boot\Vbootx64.efi
disabled
}


menuentry "Grub2 EFI x64" {
icon /efi/boot/icons/os_linux.icns
loader /efi/boot/grubx64.efi
#disabled
}

menuentry "CLOVER" {
loader /efi/boot/CLOVERX64.efi
icon /efi/boot/icons/os_ubuntu.icns
#disabled
}


menuentry "Ubuntu" {
loader /efi/ubuntu/BOOTx64.efi
icon /efi/boot/icons/os_ubuntu.icns
disabled
}


# A sample entry for a Linux 3.3 kernel with its new EFI boot stub
# support on a filesystem called "KERNELS". This entry includes
# Linux-specific boot options and specification of an initial RAM disk.
# Note uses of Linux-style forward slashes, even in the initrd
# specification. Also note that a leading slash is optional in file
# specifications.
menuentry Linux {
    icon \efi\boot\icons\os_linux.icns
volume KERNELS
loader bzImage-3.3.0-rc7
initrd initrd-3.3.0.img
options "ro root=UUID=5f96cafa-e0a7-4057-b18f-fa709db5b837"
disabled
}

# A sample entry for loading Ubuntu using its standard name for
# its GRUB 2 boot loader. Note uses of Linux-style forward slashes
menuentry Ubuntu {
loader /EFI/ubuntu/grubx64.efi
icon \efi\boot\icons\os_linux.icns
disabled
}

# A minimal ELILO entry, which probably offers nothing that
# auto-detection can't accomplish.
menuentry "ELILO" {
loader \EFI\elilo\elilo.efi
icon \efi\boot\icons\os_linux.icns
disabled
}

# Like the ELILO entry, this one offers nothing that auto-detection
# can't do; but you might use it if you want to disable auto-detection
# but still boot Windows....
menuentry "Windows 7" {
loader \EFI\Microsoft\Boot\bootmgfw.efi
icon \efi\boot\icons\os_linux.icns
disabled
}

# EFI shells are programs just like boot loaders, and can be
# launched in the same way. You can pass a shell the name of a
# script that it's to run on the "options" line. The script
# could initialize hardware and then launch an OS, or it could
# do something entirely different.
menuentry "Windows via shell script" {
icon \efi\boot\icons\os_win.icns
loader \EFI\tools\shell.efi
options "fs0:\EFI\tools\launch_windows.nsh"
disabled
}

# Mac OS is normally detected and run automatically; however,
# if you want to do something unusual, a manual boot stanza may
# be the way to do it. This one does nothing very unusual, but
# it may serve as a starting point. Note that you'll almost
# certainly need to change the "volume" line for this example
# to work.
menuentry "My Mac OS X" {
icon \efi\boot\icons\os_mac.icns
volume "OS X boot"
loader \System\Library\CoreServices\boot.efi
disabled
}


My understanding is that in efi mode, grub2 is more suited for efi than grub4dos.  I can chainload grub2 from refind, and in grub2 i try to chainload grub4dos by using this...
Code: [Select]
menuentry "GRUB4DOS MBR" {
linux /boot/grub4dos/grub.exe --config-file=/boot/grub4dos/menu.lst
}


The grub2 i use is taken from the newest ubuntu.  It does load grub4dos, but it doesn't find the menu.lst, it only loads the grub4dos command line.  I think this is a problem with me using boot\grub4dos as a path (i edit the grldr), and the grub.exe is hardcoded to look for menu.lst in the root, in boot, and boot\grub.  My grub2 entry won't find it.  As for booting ISOs with grub2, i havent gotten that far exploring grub2.  I have trouble mapping the file properly from USB and cd. 

With my particular bios, when i boot from usb refind in efi, if i select "exit refind" it closes and loads the mbr bcd on the ntfs partition.   From there i can do whatever an mbr bcd can do.

Now, assuming secureboot loads in the bios, it would take effect before the bcd initiates.  Im wondering though if a switch i use in the bcd, "integrity checks off", could fool it.  Its a setting primarily to allow for unsigned drivers to work under x64, but im wondering if its allowing me some flexability in efi mode.  These tricks are all trial and error, and any online MS documentation is seriously lacking indepth information.   Ill send you my boot and efi directory i use from usb if you want to carry on experimenting what i have put together.   Placing grub4dos in the efi\boot dir may help, ill goof around with some paths.

Googling "bypass secure boot", i came across this.  Im wondering if it helps.
Code: [Select]
Well, while fiddling around with VMs for a while I got tired of them taking forever. This made me very upset today and out of frustration I looked for a way to bypass the secure boot of win 8 so I could install Fedora. It honestly took about five minutes and I'm really mad at myself for not thinking of this earlier. Please note, it took me into the BIOS. I have a Lenovo Ideapad P500 and I am unsure of whether this will work exactly the same way on all computers. Here is the process, step by step:

CTRL + C

Settings > Change PC Settings > General > Advanced Startup - reboot

Troubleshoot > Advanced Options > UEFI Firmware Settings - reboot

    WELCOME TO THE BIOS *

Security > Secure Boot > Disabled

Boot > Boot Mode > [Legacy Support]

Boot > Boot Mode > [Legacy First]

REBOOT

You will now be able to boot from the CD/DVD drive. Find your favorite linux LiveCD, or burn one and throw it in, reboot and enjoy. :)

Hope this helped for any of those who want to install linux alongside of Windows 8.

Last but not least, and backwards to what you want to do, is booting efi from mbr on a non efi system.  What use is this?  Im not sure, besides being able to work with gpt, and tricking the "hybrid efi" bios to boot efi.
For this, i use tinacore boot duet, loaded via grub4dos and an img file.
For Tianocore DUET installer download https://gitorious.org/tianocore_uefi_duet_builds/tianocore_uefi_duet_installer/archive-tarball/master .
For Tianocore DUET compiled floppy memdisk download https://gitorious.org/tianocore_uefi_duet_builds/tianocore_uefi_duet_memdisk_compiled/archive-tarball/master .

i boot it like this.  Unfortunatly, it must be on a fat32 usb to work.
Code: [Select]
iftitle [if exist /boot/EXTRA/EFI_DUET.gz]    Tianocore UEFI UDK DUET x86_64 (fat32 USB)\n  Loads Tinacore Boot Duet so that you can force EFI loading on a pesky Bios.      Must be fat32 if USB.
find --set-root --ignore-floppies /boot/EXTRA/EFI_DUET.gz
kernel /boot/grub4dos/memdisk raw
initrd /boot/EXTRA/EFI_DUET.gz


These are a few ways to boot various things from grub4dos.  Maybe they can be translated over to grub2.  Also, im wondering if booting from the efi hdd bcd would have any added benefits to booting into mbr that we cant do from usb\cd.

Code: [Select]

title    Boot ISO (Disk)\n  This will list ISOs in the directory ISO and allow you to boot them
ls /ISO/
set /p MYISO=Which ISO do you want to boot?
ls /ISO/%MYISO% || echo ISO %MYISO% NOT FOUND! && configfile /boot/grub4dos/menu.lst
map /ISO/%MYISO%.iso (0xff)
#map /ISO/%MYISO%.iso (hd32)
map --hook
chainloader (0xff)
#chainloader (hd32)
boot


title    Boot ISO (Memory)\n  This will list ISOs in the directory ISO and allow you to boot them
Echo    Boot ISO (Memory)
ls /ISO/
set /p MYISO=Which ISO do you want to boot?
ls /ISO/%MYISO% || echo ISO %MYISO% NOT FOUND! && configfile /boot/grub4dos/menu.lst
map --mem /ISO/%MYISO%.iso (0xff)
#map --mem /ISO/%MYISO%.iso (hd32)
map --hook
chainloader (0xff)
#chainloader (hd32)
boot


title    Boot IMG (Floppy Image)\n  This will list IMGs in the directory ISO and allow you to boot them
Echo    Boot IMG (Floppy Image)
ls /ISO/
set /p MYIMG=Which IMG do you want to boot?
ls /ISO/%MYIMG% || echo IMG %MYIMG% NOT FOUND! && configfile /boot/grub4dos/menu.lst
map --mem /ISO/%MYIMG%.IMG (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)


title    Boot GZ zipped file
Echo    Boot GZ zipped file
ls /boot/EXTRA/
set /p MYGZ=Which GZ zipped file do you want to boot?
ls /boot/EXTRA/%MYGZ% || echo GZ %MYGZ% NOT FOUND! && configfile /boot/grub4dos/menu.lst
kernel /boot/grub4dos/memdisk
initrd /boot/EXTRA/%MYGZ%.gz





Re: UEFI Bootable
« Reply #19 on: March 11, 2013, 04:46:46 PM »

laddanator

  • Chef
  • ***
  • Location: Virgina
  • Date Registered: Oct 2012
  • Posts: 258
Quote
That being said, i have never (knowingly) used secure boot, but googled it and read a bit about it just now.  From what i have read, im not 100% sure if it is something you have to activate, or if it is in the bios firmware by default.  Assuming its in the bios, and my bios has it, i have been able to install linux, windows, grub4dos and syslinux under mbr legacy mode, and windows in efi.   When booting from an efi file, in my case refinds bootx64.efi, it will boot (chainload?) any efi file i direct the refinf.conf to.   My whole config file looks like this, and it may explain a few of its capabilities better than i can.  Chameleon efi bootloader for macs may also help do things outside the box.

Secure boot is in the bios firmware by default on all Windows 8 Acer tablets (can't be "turned off"), just worked on two of them today. On an Asus laptop, you can enable CSM and then you can boot to g4d fine but with CSM disabled (default), it's in pure secure boot mode. This is a tricky devil. I use g4d daily and it's sickens me, g4d has been crippled by Windows 8 secure boot. I hope this will be fixed soon but until then, I will need to learn how to boot iso's from grub2. I have an Asus motherboard in my custom built PC with (U)EFI bios but it isn't "secure boot". It still allows me to test my newly created UEFI USB stuff.

halikus, you have given me great info here and I am trying some of your tips now. Thank you so much and I will reply with my new findings.

Quote
Ill send you my boot and efi directory i use from usb if you want to carry on experimenting what i have put together.   Placing grub4dos in the efi\boot dir may help, ill goof around with some paths.

Yes, please do. Thanks  :great:
« Last Edit: March 11, 2013, 04:48:54 PM by laddanator »

 

Powered by EzPortal