How do I see what hash algorithm a given btrfs filesystem is using?

I’m setting up storage on a new system, and recently learned that there are different options for checksum hash algorithms on btrfs. It appears that xxhash is generally faster than the default crc32c on AMD Ryzen systems, and is 64-bit instead of 32-bit. So, I created my new filesystem with that. I can’t see, though, how to see that I have in fact done this correctly. It seems like probably something in the btrfs command will tell me, but I can’t find it.

2 Likes
 $ dmesg | grep -i btrf
 [    2.687578] Btrfs loaded, crc32c=crc32c-generic

Looks like dmesg could show you. I see only 1 line so I’m not sure it is per filesystem.

3 Likes

Also found this
cat /sys/fs/btrfs/$(blkid info -o value -s UUID $DEVICE)/checksum
but does not work here.
I have only one btrfs volume at the moment.

2 Likes

This works for me. Did you set DEVICE to the desired value? And blkid will want to be root. On a Fedora system, you should be able to get the UUID out of /etc/fstab instead of using blkid, if you like. There different ways to approach this — sudo btrfs filesystem show would also work.

On my system, once I have UUID set to the device of interest, it works fine. Or you can do

cat /sys/fs/btrfs/*/checksum

with a wildcard to see all filesystems.

1 Like

Got it, that works.
Got output crc32c (crc32c-intel) which differs from the dmesg output.

2 Likes

On mine it’s xxhash64 (xxhash64-generic), which is good because that’s what I’d intended to use. For backup drives, I might use sha256 even though it’s slow.

Anyway thanks for your help ­— I wouldn’t have thought to look there!

Now I’m curious, what do you see after dmesg |grep Btrfs?

Same Btrfs loaded, crc32c=crc32c-generic. But I haven’t rebooted since I created the xxhash filesystem, so I’m curious to see what will happen!

Btrfs loaded, crc32c=crc32c-generic

This just lets us know which crcr32c code is being used, because there’s more than one.

$DEVICE needs to be replaced with the device node you’re inquiring about. And also sudo is needed for the blkid command. e.g.

sudo cat /sys/fs/btrfs/$(blkid info -o value -s UUID /dev/nvme0n1p7)/checksum

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.