From: Michael Prokop Date: Wed, 9 Jan 2013 00:40:44 +0000 (+0100) Subject: Do not use partition for bootflag check but disk itself X-Git-Tag: v0.13.4~2 X-Git-Url: http://git.grml.org/?p=grml2usb.git;a=commitdiff_plain;h=14e017caaec6e9e875023faf1b821ba232e6c35d;hp=aff3fa9d73bacb546ae45b2c2822b369cad40a02 Do not use partition for bootflag check but disk itself A device like /dev/sdX1 won't have a bootflag enabled, so instead look for the bootflag on the corresponding /dev/sdX device instead. Tested-by: Markus Rekkenbeil --- diff --git a/grml2usb b/grml2usb index 16b53cd..6e74786 100755 --- a/grml2usb +++ b/grml2usb @@ -312,7 +312,12 @@ def check_uid_root(): def check_boot_flag(device): - with open(device, 'r') as image: + if device[-1:].isdigit(): + boot_dev = re.match(r'(.*?)\d*$', device).group(1) + else: + boot_dev = device + + with open(boot_dev, 'r') as image: data = image.read(512) bootcode = data[440:] if bootcode[6] == '\x80': @@ -320,7 +325,7 @@ def check_boot_flag(device): else: logging.debug("bootflag is NOT enabled") raise VerifyException("Device %s does not have the bootflag set. " - "Please enable it to be able to boot." % device) + "Please enable it to be able to boot." % boot_dev) def mkfs_fat16(device):