12

Btrfs calculates a crc32c checksum for each file. Is there a way I can view what checksum is stored (as opposed to just reading the file and recalculating it)?

3

Btrfs calculates a crc32c checksum for each file.

This is not correct. Both of the open-source checksumming file-systems (ZFS and BTRFS) calculate a checksum for each logical block (the unnamed source Awe used is correct). This is a checksum of the on-disk data.

If the file-system has compression enabled (an increasingly common setting), this checksum is of the data after compression. This means that, even if the file fits in one logical block, it's possible (and increasingly likely) that the file-system's checksum data will be useless to you.

If you need a file checksum, the best way to get it would be to calculate it.

1

From a similar answer at superuser:

I don't believe it is possible to extract the block level checksums from a ZFS filesystem, but since the checksums are at the block level, not the file level, it probably wouldn't help you anyway.

Meaning. Checksums are not created per file by btrfs. It is mentioned @superuser there is a patch to add a functionality to the inspect-internal subcommand: btrfs inspect-internal dump-csums this dumps - for all blocks being occupied by a given file - the block checksums. Plural, unless the file fits into one block.

  • 1
    Please link to the answer you are quoting from, and name its author. – Scott Oct 7 '17 at 4:19
  • what for? It is NOT an answer to the actual question. The quote rather explains why it is technically not possible due to wrong assumptions while posing the question. That's not a repetition of an answer. – Awe Oct 25 '17 at 4:51
  • 1
    Because (1) quoting somebody else’s words without identifying the author is plagiarism, and (2) if you quote somebody else’s words without identifying the author, you give the reader no way to assess the credibility of the statement. – Scott Oct 25 '17 at 5:10
  • superuser.com/a/1030443/669977 – yeti Dec 16 '17 at 19:11
0

I think this isn't possible via btrfs CLI, but here there is a source code that, I hope, could help you to read chechsum for a single block in a btrfs filesystem. Needs root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.