Tuesday, 20 September 2016

RMPrepUSB v2.1.733 (Beta status) available - with grub2 USB drive installer

RMPrepUSB v2.1.733 changes are:

  • Latest grub4dos 0.4.6a 2016-09-20 (grldr)
  • Can install grub2 to MBR via BootLoaders tab
  • FAT32 partitions now start at LBA 2048 instead of LBA63 (RMPartUSB v2.1.733)
You can now install grub2 boot code onto the first sectors of a USB drive.

MBR booting for grub2 first boots to the code in the MBR (LBA0) which then loads in the rest of the code at LBA1-LBA62. The default boot code (core.img) only recognises MBR (not GPT) partitions, and only FAT, exFAT and NTFS partitions. It looks for a config menu file at \boot\grub\grub.cfg. You cannot install grub2 to a partition, only a disk.

The boot.img and core.img files used just fit into 63 sectors and it is the same code used by Rufus and compiled by akeo (the author of Rufus).
  • boot.img - should be 512 bytes and contains the boot code from bytes 0-0x1b7
  • core.img - usually 30K or larger and contains the core grub2 kernel

You can write your own grub2 boot files, instead of the default ones included with RMPrepUSB.

core.img needs to fit between the MBR (first sector) and the beginning of the first partition.
RMPrepUSB will check that there is enough room first.

Because many versions of core.img (especially ones that include support for GPT disks) are larger than 32K, I have tweaked RMPrepUSB so that when you format a drive as FAT32, it now leaves 2048 sectors before the start of the first partition instead of 63. This allows you to install larger grub2 core.img files if you wish.

If you want to know more details about how grub2 boots - see the excellent detailed slides here.

Note that UEFI-booting to grub2 uses an entirely different mechanism (it loads \EFI\boot\grubx64.efi from a FAT32 partition - no sector-based boot code is used - just files).

RMPrepUSB v2.1.733 is available from www.rmprepusb.com or the E2B Alternate Downloads area.

Note: Installing grub2 on an E2B drive (!!!) can cause problems after you re-install grub4dos. E2B assumes that sectors 30 and 60 on the USB drive are blank or contain a valid MBR. If grub2 or some other bootloader has been installed, these sectors will contain code and .imgPTN files will not work even if it boots to E2B. To restore full functionality, use RMPrepUSB - Ctrl+D (Disk Doctor) to clear sectors 30 and 60 (Tip: read the MBR sector LBA0, and then write it to LBA30 and LBA60). Then immediately use the Install grub4dos - MBR to re-install grub4dos.