Btrfs/Statically built btrfs-progs

From Forza's ramblings
Black and white photograph depicting an old radio transmitter.
A rotary spark gap radio transmitter, a type of radio transmitter used during the wireless telegraphy era, circa 1900-1920.

Statically built btrfs-progs

It can be important to use the latest btrfs-progs when trying to recover data with btrfs check or avoid bugs, etc. However, if you are on a long-term support (LTS) release of a Linux distribution, it may be that newer btrfs progs are not backported at all. For example, Debian 11 (at this time of writing) only have btrfs-progs-5.10.1 while btrfs-progs-6.5.1 is the latest upstream version.

Compiling

If it is not possible to build the latest btrfs progs on your local system, you can build a btrfs progs statically linked binary on another system, and then copy the file over.

The build instructions are available at https://github.com/kdave/btrfs-progs/blob/master/INSTALL

It should be as simple a running the following:

./autogen.sh
./configure --disable-shared --disable-documentation --enable-experimental
make static

The resulting files are

btrfs-convert.static
btrfs-corrupt-block.static
btrfs-find-root.static
btrfs-image.static
btrfs-map-logical.static
btrfs-select-super.static
btrfs.static
btrfsck.static
btrfstune.static
mkfs.btrfs.static
Note: --enable-experimental is needed if you need to test new features, such as --csum conversion.

Prebuilt binaries

One caveat is that compiling btrfs-progs statically also needs external libraries also statically built (e2fsprogs, libuuid, libzstd, libgzip, etc...). This may not be possible without a dedicated build-environment.

To make it easier, I have made statically built binaries available. These are built with CFLAGS="-O2 -march=x86-64" and should work on most 64bit AMD and Intel systems.

https://mirrors.tnonline.net/btrfs/btrfs-progs/

sha256sum of the btrfs-progs-6.5.1 release
SHA256 (btrfs-progs-6.5.1-sources.tar.gz) = 8ea63fe3361dbfb38676e82f69a49a6f23043cc0b7347a46c5c19513d032b8ee
SHA256 (btrfs-progs-6.5.1-static.tar) = d827a19556eebbe66d4242e4517e457e5bb8eae0d3a8748390f6ba681f8e93fd
SHA256 (btrfs-progs-6.5.1-static.tar.bz2) = c3cb8fe552b802c7185f72e5cf011f4f81ac5f93018277f2d1a185f2845dd690
SHA256 (btrfs-progs-6.5.1-static.tar.gz) = 9301c2d0c2850893954221c012073b9946c2d8f136cc943a65a02e8f42f67021
SHA256 (btrfs-progs-6.5.1-static.tar.xz) = b97537da2d5471ad3f78ac980bde3316d3c7674093c081e414008c55e9864dbe
SHA256 (btrfs-progs-6.5.1-static.tar.zst) = d1518a118ce725240ea45c7acf258e33918ed29aadd7725f47f6b4ed2aad9d87

DISCLAIMER!

These binaries are not officially supported!

I provide these pre-built binaries as-is with NO WARRANTY. Although I have tested these on my own system, there are no guarantees they work on any other system. They may be broken, cause data corruption, or other severe issues. Always use officially provided btrfs-progs from your Linux distribution when in doubt!

Since btrfs-progs v6.3, statically built versions are directly provided on the official GitHub page.