# Make a \casper-rw ext2 file in the root of the drive (MUST be made as casper-rw)
# e.g. dd if=/dev/zero of=casper-rw bs=1M count=512
# format ext2: mkfs.ext2 casper-rw -L casper-rw
# Rename the file to \mint17-rw (i.e. File Name=mint17-rw  Volume Name=casper-rw)
# Place this .mnu file and the Mint ISO in (_ISO\xxx\MNU), e.g. \_ISO\MainMenu\MNU or \_ISO\Linux\MNU
# This menu will work even on an NTFS USB boot drive
# IMPORTANT: you MUST defrag the file system
# e.g. sudo perl defragfs /media/Multiboot/ -f
# defragfs: http://defragfs.sourceforge.net/  or \_ISO\docs\linux_utils folder

iftitle [if exist %MFOLDER%/linuxmint-17.1-cinnamon-32bit.iso] Mint 17 PERSISTENT\n Boot using .mnu file with persistence
set ISO=%MFOLDER%/linuxmint-17.1-cinnamon-32bit.iso
set PF=/mint17-rw
# language - e.g. de, es, us, ch, fr, en
set LNG=de

if exist CD echo WARNING: Cannot use partnew command! && pause && configfile (bd)/menu.lst

#enable parttype output
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


# make empty table entry in 3rd position in ptn table
parttype (hd0,2) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (hd0,2) 0 0 0
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE - PERSISTENCE MAY NOT WORK! && pause
debug 1
if not exist %PF% echo WARNING: %PF% persistence file not found! && pause
errorcheck off
if "%check%"=="0x00" partnew (hd0,2) 0x0 %PF%
errorcheck on
#map ptn 4 to ISO
partnew (hd0,3) 0x0 %ISO%
map %ISO% (0xff)
map --hook
root (0xff)

kernel /casper/vmlinuz  boot=casper persistent noeject noprompt quiet splash debian-installer/language=%LNG% console-setup/layoutcode?=%LNG% --
initrd /casper/initrd.lz
