24

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)?

2

3 Answers 3

10

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.

3

From a similar answer by jlp at Server Fault:

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 by lakshmipathi in a question on Super User that there is a patch to add a functionality to the inspect-internal subcommand:

btrfs inspect-internal dump-csum

This dumps – for all blocks being occupied by a given file – the block checksums.  Plural, unless the file fits into one block.

0
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .