python3 -c " CHUNK = 128*512 LV_START = 5120000*512 BSIZE = 4096 BPG = 32768 NUM_GROUPS = 35728 GDT_ENTRY = 64 # Check which GDT entries fall in metadata chunks # for BOTH primary and backup GDT locations print('Primary GDT (virtual byte 4096):') prim_bad = [] for g in range(NUM_GROUPS): byte_abs = BSIZE + g * GDT_ENTRY in_group = byte_abs % (5*CHUNK) chunk_idx = in_group // CHUNK if chunk_idx == 4: prim_bad.append(g) print(f' Groups in metadata chunks: {len(prim_bad)}') print(f' First few: {prim_bad[:10]}') print(f' Last few: {prim_bad[-5:]}') print() print('Backup GDT (virtual byte (BPG+1)*BSIZE):') backup_start = (BPG+1) * BSIZE backup_bad = [] for g in range(NUM_GROUPS): byte_abs = backup_start + g * GDT_ENTRY in_group = byte_abs % (5*CHUNK) chunk_idx = in_group // CHUNK if chunk_idx == 4: backup_bad.append(g) print(f' Groups in metadata chunks: {len(backup_bad)}') print(f' First few: {backup_bad[:10]}') print(f' Last few: {backup_bad[-5:]}') # Check if bad groups overlap overlap = set(prim_bad) & set(backup_bad) print(f' Overlap with primary bad: {len(overlap)}') # Find a backup GDT location with NO metadata chunk conflicts print() print('Searching for backup GDT with no metadata chunk conflicts...') # Backup GDTs exist at groups: 1,3,5,7,9,25,27,49,81,125,243,343... def has_backup(g): if g <= 1: return True for base in [3,5,7]: n = base while n < g: n *= base if n == g: return True return False backup_groups = [g for g in range(1000) if has_backup(g) and g > 0] for bg in backup_groups[:20]: start = (bg * BPG + 1) * BSIZE bad = [] for g in range(NUM_GROUPS): byte_abs = start + g * GDT_ENTRY in_group = byte_abs % (5*CHUNK) chunk_idx = in_group // CHUNK if chunk_idx == 4: bad.append(g) print(f' Backup at group {bg}: {len(bad)} bad entries ' f'({\"CLEAN\" if len(bad)==0 else bad[:3]})') if len(bad) == 0: print(f' *** PERFECT BACKUP GDT at group {bg} ***') print(f' Virtual byte: {start}') break "