From: Sven Joachim Date: Wed, 30 Oct 2019 16:35:03 +0000 (+0100) Subject: check_boot_flag(): Open device in binary mode X-Git-Tag: v0.17.0~5^2 X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=commitdiff_plain;h=c2e742a6dc8a594f71fb7cf0b3233f31f48935de check_boot_flag(): Open device in binary mode By default open() reads in text which is not going to fly for a boot sector. Fatal: 'utf-8' codec can't decode byte 0x90 in position 6: invalid start byte Exception: Traceback (most recent call last): File "/usr/sbin/grml2usb", line 1913, in main install(iso, device) File "/usr/sbin/grml2usb", line 1626, in install install_grml(iso_mountpoint, device) File "/usr/sbin/grml2usb", line 1653, in install_grml check_boot_flag(device) File "/usr/sbin/grml2usb", line 393, in check_boot_flag data = image.read(520) File "/usr/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 6: invalid start byte --- diff --git a/grml2usb b/grml2usb index eaeba08..75fcd3e 100755 --- a/grml2usb +++ b/grml2usb @@ -389,7 +389,7 @@ def check_boot_flag(device): except ImportError as e: logging.debug("could not import parted, falling back to old bootflag detection") - with open(boot_dev, 'r') as image: + with open(boot_dev, 'rb') as image: data = image.read(520) bootcode = data[440:] gpt_data = bootcode[70:80]