Mageia Bugzilla – Attachment 11436 Details for
Bug 25924
Mageia-7.1-Live-Xfce-i586.iso hangs on some BIOS computers when booting from USB stick
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Python3 program to fix Mageia-7.1 hybrid ISO MBR (2nd edition)
mageia-iso-fix.py (text/plain), 1.46 KB, created by
Ihar Areshchankau
on 2019-12-29 10:42:58 CET
(
hide
)
Description:
Python3 program to fix Mageia-7.1 hybrid ISO MBR (2nd edition)
Filename:
MIME Type:
Creator:
Ihar Areshchankau
Created:
2019-12-29 10:42:58 CET
Size:
1.46 KB
patch
obsolete
>#mageia-iso-swap.py >import sys, os >def PrintMbrPartitionsTable (mbr, offset): > for i in range (0,4): > print (i+1, mbr[offset: offset + 0x10]) > offset += 0x10 >if len (sys.argv) != 2: > print (" Mageia hybrid ISO image MBR patching utility.") > print (" Usage:") > print ("python3 mageia-iso-fix.py Mageia-...-i586.iso") >else: > IsoFileName = sys.argv[1] > MbrPartitionsTableOffset = 0x1BE > MbrSignatureOffset = 510 > if not os.path.isfile (IsoFileName): > print ("Error:", IsoFileName, "isn't a file name.") > else: > f = open (IsoFileName, "r+b") > sector = bytearray (f.read (512)) > if sector[MbrSignatureOffset] != 0x55 or sector[MbrSignatureOffset + 1] != 0xAA: > print ("Error:", IsoFileName, "doesn't have MBR.") > else: > if sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] == bytearray ([0]*16): > print (IsoFileName, "doesn't need to be patched.") > else: > print ("Patching MBR partition table:") > print ("Partitions table before:") > PrintMbrPartitionsTable (sector, MbrPartitionsTableOffset) > sector[MbrPartitionsTableOffset:MbrPartitionsTableOffset + 16] = sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] > sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] = bytearray ([0] * 16) > print ("Partitions table after:") > PrintMbrPartitionsTable (sector, MbrPartitionsTableOffset) > f.seek (0) > f.write (sector) > print (IsoFileName, "is patched now.") > f.close ()
#mageia-iso-swap.py import sys, os def PrintMbrPartitionsTable (mbr, offset): for i in range (0,4): print (i+1, mbr[offset: offset + 0x10]) offset += 0x10 if len (sys.argv) != 2: print (" Mageia hybrid ISO image MBR patching utility.") print (" Usage:") print ("python3 mageia-iso-fix.py Mageia-...-i586.iso") else: IsoFileName = sys.argv[1] MbrPartitionsTableOffset = 0x1BE MbrSignatureOffset = 510 if not os.path.isfile (IsoFileName): print ("Error:", IsoFileName, "isn't a file name.") else: f = open (IsoFileName, "r+b") sector = bytearray (f.read (512)) if sector[MbrSignatureOffset] != 0x55 or sector[MbrSignatureOffset + 1] != 0xAA: print ("Error:", IsoFileName, "doesn't have MBR.") else: if sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] == bytearray ([0]*16): print (IsoFileName, "doesn't need to be patched.") else: print ("Patching MBR partition table:") print ("Partitions table before:") PrintMbrPartitionsTable (sector, MbrPartitionsTableOffset) sector[MbrPartitionsTableOffset:MbrPartitionsTableOffset + 16] = sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] sector[MbrPartitionsTableOffset + 16:MbrPartitionsTableOffset + 32] = bytearray ([0] * 16) print ("Partitions table after:") PrintMbrPartitionsTable (sector, MbrPartitionsTableOffset) f.seek (0) f.write (sector) print (IsoFileName, "is patched now.") f.close ()
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25924
:
11418
|
11424
|
11425
| 11436