Run grub-install without and with --force option.
authorUlrich Dangel <uli@spamt.net>
Mon, 20 Sep 2010 12:56:49 +0000 (14:56 +0200)
committerUlrich Dangel <uli@spamt.net>
Mon, 20 Sep 2010 12:56:49 +0000 (14:56 +0200)
grml2usb

index 89c1f22..161aae0 100755 (executable)
--- a/grml2usb
+++ b/grml2usb
@@ -650,12 +650,16 @@ def install_grub(device):
                     grub_device = device
 
                 logging.info("Installing grub as bootloader")
-                logging.debug("grub-install --recheck --force --no-floppy --root-directory=%s %s",
-                              device_mountpoint, grub_device)
-                proc = subprocess.Popen(["grub-install", "--recheck", "--force", "--no-floppy",
-                                         "--root-directory=%s" % device_mountpoint, grub_device],
-                                        stdout=file(os.devnull, "r+"))
-                proc.wait()
+                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 "