X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=1aa39bad4fdb204ec4af2b1de4e52e0d319a08f4;hp=dc1a323abcc2778f70a23b2b97ec9ea4e665efcb;hb=b2e01dffb74a3870b3c54528ec01389cb1b9f6bb;hpb=de8c6b28f805ba4a1c27848aab2336165175f25f diff --git a/grml2usb b/grml2usb index dc1a323..1aa39ba 100755 --- a/grml2usb +++ b/grml2usb @@ -49,6 +49,8 @@ parser.add_option("--fat16", dest="fat16", action="store_true", help="format specified partition with FAT16") parser.add_option("--force", dest="force", action="store_true", help="force any actions requiring manual interaction") +parser.add_option("--grub-mbr", dest="grubmbr", action="store_true", + help="install grub into MBR instead of (default) PBR") #parser.add_option("--initrd", dest="initrd", action="store", type="string", # help="install specified initrd instead of the default [TODO - not implemented yet]") #parser.add_option("--kernel", dest="kernel", action="store", type="string", @@ -630,13 +632,26 @@ def install_grub(device): try: try: mount(device, device_mountpoint, "") - logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) + + # If using --grub-mbr then make sure we install grub in MBR instead of PBR + # Thanks to grub2. NOT. + if options.grubmbr: + logging.debug("Using option --grub-mbr ...") + if device[-1:].isdigit(): + grub_device = re.match(r'(.*?)\d*$', device).group(1) + else: + grub_device = device + else: + grub_device = device + + logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, grub_device) proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", - "--root-directory=%s" % device_mountpoint, device], stdout=file(os.devnull, "r+")) + "--root-directory=%s" % device_mountpoint, grub_device], stdout=file(os.devnull, "r+")) proc.wait() if proc.returncode != 0: # raise Exception("error executing grub-install") logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ or use --syslinux)") + logging.critical("Note: if using grub2 consider using the --grub-mbr option because grub2's PBR feature is broken.") cleanup() sys.exit(1) except CriticalException, error: