On one system, GRUB4DOS is installed on the second logical partition of the second hard drive (hd1,5). Given a menu entry such as this:
title SystemRescueCD
set ISO=/iso/systemrescue-8.03-amd64.iso
find --set-root %ISO%
parttype (hd0,3) | set check=
set check=%check:~-5,4%
if %check%==0x00 partnew (hd0,3) 0x00 %ISO%
if not %check%==0x00 echo ERROR: Partition Table entry 4 already exists! && pause --wait=3 && configfile /grub/menu.lst
map %ISO% (0xff)
map --hook
root (0xff)
chainloader (0xff)
when the menu entry uses:
parttype (hd0,3) | set check=
and
partnew (hd0,3) 0x00 filename
the error message is that the file must be on the same drive.
Using:
parttype (hd1,3) | set check=
and
partnew (hd1,3) 0x00 filename
succeeds.
The question is: rather than hard-coding the drive number, how can G4D determine the current drive and use it in those two commands, so that the same menu entry can succeed when booted from different drive numbers (eg. on one system, G4D is on hd0, on another system G4D is on hd1, on another system it may booted from a USB which may be hd2, etc.)?