Reproducible XFS Filesystems Builds for VMs

Luca DiMaio luca.dimaio at chainguard.dev
Fri Apr 11 14:47:24 UTC 2025


Hello list,

I am a Software Engineer at Chainguard working on reproducible builds
for VMs, and we're happy to say that we've successfully implemented
reproducible disk images with EFI+EXT4 partitions using the following
methods:

- For FAT32 partitions: `mkfs.vfat --invarian -i $EFI_UUID` with
`$SOURCE_DATE_EPOCH` and populating via mtools
- For EXT4 partitions: `mkfs.ext4 -E hash_seed=$EXT4_HASH_SEED -U
$ROOTFS_UUID` with `$SOURCE_DATE_EPOCH` plus the `-d
/path/to/rootfs.tar.gz` to populate it

We're interested in also supplying XFS rootfs, which seems to not be
rb-friendly.
I had some success on having reproducible empty XFS partitions by
using a combination of `libfaketime`
to enforce `$SOURCE_DATE_EPOCH` and a custom library that overwrites
the libc's `getrandom()`:

```
~$ export LD_PRELOAD="./deterministic_rng.so /usr/lib/faketime/libfaketime.so.1"
~$ mkfs.xfs \
-b size=4096 \
-d agcount=4 \
-d noalign \
-i attr=2 \
-i projid32bit=1 \
-i size=512 \
-l size=67108864 \
-l su=4096 \
-l version=2 \
-m crc=1 \
-m finobt=1 \
-m uuid=$ROOTFS_UUID \
-n size=16384 \
-n version=2 disk1.img
~$ mkfs.xfs \
-b size=4096 \
-d agcount=4 \
-d noalign \
-i attr=2 \
-i projid32bit=1 \
-i size=512 \
-l size=67108864 \
-l su=4096 \
-l version=2 \
-m crc=1 \
-m finobt=1 \
-m uuid=$ROOTFS_UUID \
-n size=16384 \
-n version=2 disk2.img
~$ md5sum disk*
c68c202163dcb862762fc01970f6c8b4  disk1.img
c68c202163dcb862762fc01970f6c8b4  disk2.img
```

But this all becomes aleatory when we try to populate the filesystem,
by using mount + untar the source tar.gz

Right now I've opened a thread on the XFS Mailing list, to ask about how to
proceed about this, and if they're interested in making XFS
reproducible-friendly
Here: https://lore.kernel.org/linux-xfs/CAKBQhKVi6FWNWJH2PWUA4Ue=aSrvVcR_r2aJOUh45Nd0YdnxVA@mail.gmail.com/T/#u


I'd like to hear your inputs on the approach here, or also showing
interest in the
XFS thread if anyone else is interested in this.

Regards,
L.


More information about the rb-general mailing list