import struct, binascii # We need to recompute the GDT checksum for group 0 # after modifying its flags # # ext4 GDT checksum = crc32c(uuid + group_num_le16 + gdt_entry_with_csum_zeroed) # The checksum seed is stored in the superblock at offset 408 with open('/dev/nbd0','rb') as f: f.seek(1024) sb = f.read(1024) uuid = sb[104:120] csum_seed = struct.unpack_from('