Monday, 26 January 2015

Booting Macpup iso files on E2B and patching ISO files using grub4dos

Unfortunatley, the Macpup_550.iso file does not 'just work' with E2B because the menu.lst file that is used inside the ISO has specified (cd) in the file paths:

default 0
timeout 20
gfxmenu (cd)/boot/grub/message
color cyan/blue white/blue

title Macpup 550 
kernel (cd)/vmlinuz root=/dev/ram0 pmedia=idecd 
initrd (cd)/initrd.gz 

title Macpup 550 - RAM
kernel (cd)/vmlinuz root=/dev/ram0 pfix=ram pmedia=idecd
initrd (cd)/initrd.gz 

We can manually alter this by booting to the ISO in E2B as normal, allow it to fail to boot, and then manually edit each line by pressing e for edit in it's grub menu and removing the (cd) characters by editing both lines in the menu. This also means we can add extra parameters to the kernel line if we want to.

However, did you know that grub4dos can permanently modify ISO files?

So we can do this:

1. Boot to the E2B main menu and press p to enter the password (default=easy2boot).

2. Press c to get to the grub4dos command shell

3. Now we need to modify the \boot\grub\menu.lst file by typing this  (debug 1 and the last cat line is just so we can see if it worked):

debug 1
map /_ISO/MAINMENU/macpup_550.iso (0xff)
map --hook
cat --locate=(cd) --replace=\x20\x20\x20\x20 (0xff)/boot/grub/menu.lst
cat (0xff)/boot/grub/menu.lst

Notice that we must replace the four (cd) characters with exactly four spaces because we can only change bytes in the ISO, we cannot add or delete bytes. In E2B v1.62, if the ISO has a file extension of .isomacpup then this patch will automatically be applied.

If you don't want to be able to modify (even accidentally) the ISO file in a grub4dos menu, you must use:

map --read-only  /_ISO/MAINMENU/macpup_550.iso (0xff)

Macpup with Save Sessions

In E2B v1.62 I have included a sample Macpup_550_Save.mnu file which also allows you to load and save Macpup sessions as well as gets round this (cd) boot iso issue without altering the ISO file). Here is a simplified version of it (note that it uses partnew and you MUST have an unused 4th partition entry on your USB drive):

iftitle [if exist /Macpup_550.iso] Macpup\n Macpup boot from ISO (save on shutdown)

set ISO=/Macpup_550.iso

partnew (hd0,3) 0x00 %ISO% 
map %ISO% (0xff) 
map --hook 
root (0xff) 

kernel /vmlinuz root=/dev/ram0 pmedia=idecd psavemark=1 fix=fsck
initrd /initrd.gz

Patching an XP ISO file

In a similar way, we can permanently rename files in a boot file list or rename file names inside an ISO. For instance:

map /XPSP3Inst.iso (0xff)
map --hook
cat --locate=BINBOOTFIX.BIN --number=1 --replace=BINXXX (0xff)+0x1000

this renames the file name in the boot sectors (first 0x1000 cd sectors) inside a bootable XP Install ISO so that the BOOTFIX.BIN text is renamed to XXXTFIX.BIN. This will cause the XP bootloader to not find the file in the ISO and thus not prompt the user to 'Press a key to boot from CD' every time we boot from it - neat eh?