# INSTRUCTIONS: Create a \android-rw ext2 file on the root of your E2B USB drive using RMPrepUSB - Create ext2 FS button (any volume name and size)
#               Place android ISO file and this .mnu file in \_ISO\MAINMENU\MNU or \_ISO\LINUX\MNU folder
#               Ensure the name of the ISO is set in line 2 below

title Android (Persistent)\n Boot Android with persistence

set ISO=$HOME$/android-x86-4.4-RC2.iso
set PER=/android-rw

debug 1
parttype (hd0,3) | set check=
set check=%check:~-5,4%
# make empty table entry in 3rd position in ptn table
if not "%check%"=="0x00" set /p A=Partition 4 in use! && configfile (md)0xa000+0x50


if not exist %ISO% pause ERROR: %ISO% does not exist!   && configfile (md)0xa000+0x50
if not exist %PER% pause ERROR: %PER% does not exist!   && configfile (md)0xa000+0x50
debug 1
parttype (hd0,2) | set check=
set check=%check:~-5,4%
# make empty table entry in 3rd position in ptn table
if "%check%"=="0x00" partnew (hd0,2) 0 0 0 > nul
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE! && pause  && configfile (md)0xa000+0x50
if not exist %PER% echo ERROR: persistence file %PER% not found! && pause && configfile (md)0xa000+0x50

find > (md)0x300+1
cat --locate=hd0, (md)0x300+1 > nul && set PDRV=sda
cat --locate=hd1, (md)0x300+1 > nul && set PDRV=sdb
cat --locate=hd2, (md)0x300+1 > nul && set PDRV=sdc
cat --locate=hd3, (md)0x300+1 > nul && set PDRV=sdd
cat --locate=hd4, (md)0x300+1 > nul && set PDRV=sde
cat --locate=hd5, (md)0x300+1 > nul && set PDRV=sdf
cat --locate=hd6, (md)0x300+1 > nul && set PDRV=sdg
cat --locate=hd7, (md)0x300+1 > nul && set PDRV=sdh
cat --locate=hd8, (md)0x300+1 > nul && set PDRV=sdi
cat --locate=hd9, (md)0x300+1 > nul && set PDRV=sdj
echo PERSISTENCE PARTITION IS ESTIMATED AS %PDRV%3
set ask=
echo
echo For persistence, we need to set the linux Easy2Boot drive name correctly
echo Tip: To override, enter the letter of the Easy2Boot drive name under linux (e.g. e = sde)
echo
set /l /p:3 ask=Press Q to Quit or enter an alternate drive letter (e.g. e) : 
if /i "%ask%"=="q" configfile (md)0xa000+0x50
if not "%ask%"=="" set PDRV=sd%ask%
clear
echo PERSISTENCE PARTITION = %PDRV%3
set /p:3 ask= 
partnew (hd0,2) 0x0 %PER% > nul || pause ERROR: %PER% not contiguous or corrupt!  && configfile (md)0xa000+0x50
partnew (hd0,3) 0x0 %ISO% (0xff) > nul || pause ERROR: %ISO% not contiguous or corrupt!  && configfile (md)0xa000+0x50
map %ISO% (0xff) > nul
map --hook > nul
root (0xff)
# add nomodeset if display problems
kernel /kernel root=/dev/ram0 androidboot.hardware=android_x86 video=-16 quiet  SRC= DATA=%PDRV%3
initrd /initrd.img
boot
