def main(): args = parseArguments() device = get_blockdev(args.disk[0]) gpt = GPT(device) primary_header = gpt.get_gpt_header() secondary_header = gpt.get_gpt_header(True) gpt_entries = gpt.get_table() block_size = device.get_block_count() print 'Determined block_size of %d blocks' % block_size secondary_header_offset = block_size - 1 secondary_table_offset = block_size - 33 last_usable_lba = block_size - 34 print 'Secondary header will be moved to sector %d' % secondary_header_offset primary_header.last_usable_lba = last_usable_lba secondary_header.last_usable_lba = last_usable_lba primary_header.other_offset = secondary_header_offset secondary_header.own_offset = secondary_header_offset secondary_header.table_start_lba = secondary_table_offset gpt.write_gpt(primary_header, gpt_entries) gpt.write_gpt(secondary_header, gpt_entries) device.close()
def main(): args = parseArguments() device = get_blockdev(args.disk[0]) gpt = GPT(device) primary_header = gpt.get_gpt_header() secondary_header = gpt.get_gpt_header(True) gpt_entries = gpt.get_table() block_size = device.get_block_count() print "Determined block_size of %d blocks" % block_size secondary_header_offset = block_size - 1 secondary_table_offset = block_size - 33 last_usable_lba = block_size - 34 print "Secondary header will be moved to sector %d" % secondary_header_offset primary_header.last_usable_lba = last_usable_lba secondary_header.last_usable_lba = last_usable_lba primary_header.other_offset = secondary_header_offset secondary_header.own_offset = secondary_header_offset secondary_header.table_start_lba = secondary_table_offset gpt.write_gpt(primary_header, gpt_entries) gpt.write_gpt(secondary_header, gpt_entries) device.close()
def main(): args = parseArguments() device = BlockDev(args.disk[0]) gpt = GPT(device) primary_header = gpt.get_gpt_header() secondary_header = gpt.get_gpt_header(True) primary_table_entries = gpt.get_table() secondary_table_entries = gpt.get_table(True) primary_header_checksum = gpt._calc_header_crc32(primary_header.serialize(), primary_header.header_size) secondary_header_checksum = gpt._calc_header_crc32(secondary_header.serialize(), secondary_header.header_size) primary_table_checksum = gpt._calc_table_crc32(gpt_entries=primary_table_entries) secondary_table_checksum = gpt._calc_table_crc32(gpt_entries=secondary_table_entries) if primary_header.header_checksum != primary_header_checksum: print '[WARNING] Checksum mismatch for primary header:' print '\t Expected: %.8x'%primary_header.header_checksum print '\t Calculated: %.8x'%primary_header_checksum if secondary_header.header_checksum != secondary_header_checksum: print '[WARNING] Checksum mismatch for secondary header' print '\t Expected: %.8x'%secondary_header.header_checksum print '\t Calculated: %.8x'%secondary_header_checksum if primary_header.table_checksum != primary_table_checksum: print '[WARNING] Checksum mismatch for primary table' print '\t Expected: %.8x'%primary_header.table_checksum print '\t Calculated: %.8x'%primary_table_checksum if secondary_header.table_checksum != secondary_table_checksum: print '[WARNING] Checksum mismatch for secondary table' print '\t Expected: %.8x'%secondary_header.table_checksum print '\t Calculated: %.8x'%secondary_table_checksum print 'Start of primary table: %d'%primary_header.table_start_lba print 'Position of secondary header: %d'%primary_header.other_offset for entry in primary_table_entries: print '[PARTITION] Name: %s'%entry.name print '\t Start LBA: %d'%entry.first_lba print '\t Size: %d'%(entry.last_lba - entry.first_lba)