site  contact  subhomenews

getfattr linked statically with musl

September 04, 2025 — BarryK

Binary utility 'getfattr' is for reading extended attributes of files and folders. It is part of the 'attr' package. I want to use it in the initrd, where all the binary executables are statically-linked. That is, there are no shared libraries.

I'm posting this as a reminder to myself, how I did it...

Inside the "devx" container, downloaded the source and applied the Debian patches, from here:

https://packages.debian.org/trixie/attr

# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --disable-nls --disable-shared --enable-static
# make

...which creates shared-linked-with-glibc 'getfattr', which I deleted. Then via PKGget, installed 'musl', 'musl-dev' and 'musl-tools', then:

# musl-gcc -static tools/getfattr.o .libs/libattr.a .libs/libmisc.a -o getfattr

...created statically-linked 'getfattr', stripped it, and size is 110KB.    

Tags: easy