Here is a grub4dos batch file (could be used in a menu instead) for experimentation.
I used a USB drive containing an XP VHD and booted using VirtualBox+DavidB's VMUB (USB attached as an IDE drive).
The idea here is that we make a partition #3 table which points into the VHD file at the point where the partition starts. We can then boot directly from partition #3 of the USB disk.
- The ISO must be contiguous.
- The VHD must contain a single-partition which holds the boot files+OS.
- Partition #3 of the USB drive is overwritten in this process.
- The ISO may also be modified by grub4dos (boot.ini)
- Your VM needs to be read/write (use VBox+VMUB so volume is dismounted and so is truly write-enabled - don't just use a .vmdk for the USB drive).
- If booting from a real system, your VHD must support USB-booting.
!BAT set ISO=()/FullXPVHD.vhd # get start of first ptn inside VHD dd if=%ISO% of=(md)0x300+1 > nul read 0x601c6 > nul set /a P=%@retval% > nul echo Partition starts at %P% # find start of file on USB disk blocklist %ISO% > (md)0x300+1 cat --locate=+ --replace=\x00 (md)0x300+1 > nul cat --locate=) (md)0x300+1 > nul set /a x=%?%+1 > nul cat --skip=%x% (md)0x300+1 | set /a ST= > nul echo ST=%ST% #find length of file blocklist %ISO% > (md)0x301+1 cat --locate=\x0a --replace=\x00 (md)0x301+1 > nul cat --locate=+ (md)0x301+1 > nul set /a x=%?%+1 > nul cat --skip=%x% (md)0x301+1 | set /a L= > nul echo L=%L% # Adjust start position to point to first partition set /a ST=%ST%+%P% > nul #set /a L=%L%-%P% > nul echo -n was blocklist %ISO% echo Now %ST%+%L% echo partnew (hd0,2) 7 (hd0,0)%ST%+%L% ls (hd0,2)/ echo root (hd0,2) echo # if XP adjust boot partition - this modifies the ISO file! cat --locate=tition(1) --replace=tition(3) (hd0,2)/boot.ini cat (hd0,2)/boot.ini echo chainloader /ntldr || chainloader /bootmgr pause boot
I have not tested this using a Win7/8/10 VHD - I am not sure if the BCD would work or not, but the partition UUID would be unaltered....