X-Git-Url: http://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=1aa39bad4fdb204ec4af2b1de4e52e0d319a08f4;hp=33d574c41ce41f553e77b60a564c7a78ac94bd9a;hb=656f5a714c1751f946f238e24bb81d4c1109c960;hpb=c37fb0c21162ba680e83c858e2a4a806806c298b diff --git a/grml2usb b/grml2usb index 33d574c..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", @@ -225,7 +227,6 @@ def mkfs_fat16(device): @device: partition that should be formated""" - # syslinux -d boot/isolinux /dev/sdb1 if options.dryrun: logging.info("Would execute mkfs.vfat -F 16 %s now.", device) return 0 @@ -631,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: @@ -666,7 +680,7 @@ def install_syslinux(device): proc = subprocess.Popen(["syslinux", "-d", "boot/syslinux", device]) proc.wait() if proc.returncode != 0: - raise CriticalException("Error executing syslinux (either try --fat16 or --grub?)") + raise CriticalException("Error executing syslinux (either try --fat16 or use grub?)") def install_bootloader(device):