From c0fd54ed8049b7a6b6bf3bdf346c02f19990818a Mon Sep 17 00:00:00 2001 From: Ulrich Dangel Date: Mon, 20 Sep 2010 14:56:49 +0200 Subject: [PATCH] Run grub-install without and with --force option. --- grml2usb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/grml2usb b/grml2usb index 89c1f22..161aae0 100755 --- 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 " -- 2.1.4