- # If using --grub-mbr then make sure we install grub in MBR instead of PBR
- if options.grubmbr:
- logging.debug("Using option --grub-mbr ...")
- grub_device, x = get_device_from_partition(device)
- else:
- grub_device = device
-
- logging.info("Installing grub as bootloader")
- for opt in ["", "--force"]:
- logging.debug("grub-install --recheck %s --no-floppy --root-directory=%s %s",
- opt, device_mountpoint, grub_device)
- proc = subprocess.Popen(["grub-install", "--recheck", opt, "--no-floppy",
- "--root-directory=%s" % device_mountpoint, grub_device],
- stdout=file(os.devnull, "r+"))
- proc.wait()
- if proc.returncode == 0:
- break
-
- if proc.returncode != 0:
- # raise Exception("error executing grub-install")
- logging.critical("Fatal: error executing grub-install "
- + "(please check the grml2usb FAQ or drop the --grub option)")
- logging.critical("Note: if using grub2 consider using "
- + "the --grub-mbr option as grub considers PBR problematic.")
- cleanup()
- sys.exit(1)
- except CriticalException, error:
- logging.critical("Fatal: %s", error)
+ set_rw(device)
+ mount(device, device_mountpoint, "")
+
+ logging.info("Installing grub as bootloader")
+ for opt in ["--", "--force"]:
+ set_rw(device)
+ set_rw(grub_device)
+ logging.debug("%s --recheck --no-floppy --target=i386-pc --root-directory=%s %s %s",
+ GRUB_INSTALL, device_mountpoint, opt, grub_device)
+ proc = subprocess.Popen([GRUB_INSTALL, "--recheck",
+ "--no-floppy", "--target=i386-pc",
+ "--root-directory=%s" % device_mountpoint,
+ opt, grub_device],
+ stdout=file(os.devnull, "r+"))
+ proc.wait()
+ if proc.returncode == 0:
+ break
+
+ if proc.returncode != 0:
+ # raise Exception("error executing grub-install")
+ logging.critical("Fatal: error executing grub-install " +
+ "(please check the grml2usb FAQ or drop the --grub option)")
+ logging.critical("Note: if using grub2 consider using " +
+ "the --grub-mbr option as grub considers PBR problematic.")