X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=b0ee2b15307f20dec6166fdf37b5553351b333a6;hp=b18853913bad5f84cfdfcc56ff4d490cec6d59e0;hb=463068976531bda91d3fe79246bd58bc3f88031d;hpb=97f73b06b524cb390c315102fa290156a54f693e diff --git a/grml2usb b/grml2usb index b188539..b0ee2b1 100755 --- a/grml2usb +++ b/grml2usb @@ -103,6 +103,8 @@ parser.add_option("--quiet", dest="quiet", action="store_true", help="do not output anything but just errors on console") parser.add_option("--remove-bootoption", dest="removeoption", action="append", help="regex for removing existing bootoptions") +parser.add_option("--rw-blockdev", dest="rwblockdev", action="store_true", + help="enforce read-write mode on involved block devices") parser.add_option("--skip-addons", dest="skipaddons", action="store_true", help="do not install /boot/addons/ files") parser.add_option("--skip-bootflag", dest="skipbootflag", action="store_true", @@ -252,6 +254,17 @@ def get_function_name(obj): return obj.__module__ + '.' + obj.__name__ +def set_rw(device): + if not options.rwblockdev: + return + + logging.debug("executing: blockdev --setrw %s", device) + proc = subprocess.Popen(["blockdev", "--setrw", device]) + proc.wait() + if proc.returncode != 0: + raise Exception("error executing blockdev on %s" % device) + + def execute(f, *exec_arguments): """Wrapper for executing a command. Either really executes the command (default) or when using --dry-run commandline option @@ -500,6 +513,8 @@ def install_grub(device): logging.info("Installing grub as bootloader") for opt in ["", "--force"]: + set_rw(device) + set_rw(grub_device) logging.debug("grub-install --recheck %s --no-floppy --root-directory=%s %s", opt, device_mountpoint, grub_device) proc = subprocess.Popen([GRUB_INSTALL, "--recheck", opt, @@ -537,6 +552,8 @@ def install_syslinux(device): logging.info("Would install syslinux as bootloader on %s", device) return 0 + set_rw(device) + # syslinux -d boot/isolinux /dev/sdb1 logging.info("Installing syslinux as bootloader") logging.debug("syslinux -d boot/syslinux %s", device) @@ -647,6 +664,8 @@ def install_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): tmpf.file.write(mbrcode) tmpf.file.close() + set_rw(device) + logging.debug("executing: dd if='%s' of='%s' bs=512 count=1 conv=notrunc", tmpf.name, device) proc = subprocess.Popen(["dd", "if=%s" % tmpf.name, "of=%s" % device, "bs=512", "count=1", "conv=notrunc"], stderr=file(os.devnull, "r+")) @@ -659,6 +678,8 @@ def install_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): proc = subprocess.Popen(["sync"]) proc.wait() + set_rw(device) + def is_writeable(device): """Check if the device is writeable for the current user @@ -1816,8 +1837,7 @@ def main(): if not os.path.isdir(device): if device[-1:].isdigit(): if int(device[-1:]) > 4 or device[-2:].isdigit(): - logging.critical("Fatal: installation on partition number >4 not supported. (BIOS won't support it.)") - sys.exit(1) + logging.warn("Warning: installing on partition number >4, booting *might* fail depending on your system.") # provide upgrade path handle_compat_warning(device)