Skip to content

Instantly share code, notes, and snippets.

@b2ag
Last active February 21, 2018 23:11
Show Gist options
  • Save b2ag/058aee336bec57e06cb849528f4a3355 to your computer and use it in GitHub Desktop.
Save b2ag/058aee336bec57e06cb849528f4a3355 to your computer and use it in GitHub Desktop.
Calculates CRC32C checksum to repair a borked checksum in a except from that unimpaired Btrfs superblock
i=32; sudo dd if=/dev/sdb1 of=/dev/stdout bs=1 skip=$(expr 65536 + $i ) count=$(expr 4096 - $i)|python -c "import crcmod; import sys; import struct; crc32c = crcmod.predefined.Crc('crc-32c'); crc32c.update(sys.stdin.buffer.read()); final_value=struct.unpack('<I', struct.pack('>I', crc32c.crcValue))[0]; print('0x{:08x}'.format(final_value));"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment