Skip to content

Commit 07d7f93

Browse files
committed
btrfs-progs: docs: document SOURCE_DATE_EPOCH and DETERMINISTIC_SEED
Add an ENVIRONMENT section to mkfs.btrfs(8) for the two environment variables that make image creation reproducible: SOURCE_DATE_EPOCH (timestamps) and DETERMINISTIC_SEED (UUID derivation, requires -U). It covers the empty-is-unset and invalid-is-an-error handling, the minimal recipe, and that normalizing ownership (chown -R 0:0) of a -r tree is left to the caller. Signed-off-by: Leo Martins <loemra.dev@gmail.com>
1 parent 4103bb8 commit 07d7f93

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Documentation/mkfs.btrfs.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,51 @@ by large metadata blocks and space reservation strategy that allocates more
708708
than can fit into the filesystem.
709709

710710

711+
ENVIRONMENT
712+
-----------
713+
714+
:command:`mkfs.btrfs` honors two environment variables that make image
715+
creation reproducible, so that the same inputs produce a byte-for-byte
716+
identical image.
717+
718+
SOURCE_DATE_EPOCH
719+
A decimal count of seconds since the Unix epoch
720+
(`reproducible-builds.org <https://reproducible-builds.org>`_),
721+
used in place of the current time for the timestamps written into
722+
the image: the root-item and inode times of the created trees.
723+
With *--rootdir*, each copied file's *ctime* is set to this value
724+
(ctime cannot be set after the fact, so mkfs is the only place to
725+
normalize it), and its *mtime* and *atime* are taken from the
726+
source but clamped to it, so nothing in the image is newer than
727+
the source date.
728+
729+
An empty value is treated as unset. A value that is not a
730+
non-negative integer fitting in the platform time type is a hard
731+
error.
732+
733+
DETERMINISTIC_SEED
734+
When set to *1*, the internal UUIDs that are otherwise random (the
735+
chunk-tree UUID, each device UUID and each subvolume UUID) are
736+
instead derived deterministically from the filesystem UUID. A fixed
737+
filesystem UUID must be supplied with *-U*; without it
738+
:command:`mkfs.btrfs` exits with an error rather than emit a random
739+
image. Any value other than *1* leaves UUID generation random.
740+
741+
To create a reproducible image, pin the filesystem UUID and both
742+
variables, and normalize ownership of the source tree yourself (the one
743+
image attribute left to the caller, a single :command:`chown`):
744+
745+
.. code-block:: bash
746+
747+
$ chown -R 0:0 ./rootdir
748+
$ SOURCE_DATE_EPOCH=1700000000 DETERMINISTIC_SEED=1 \
749+
mkfs.btrfs -U <uuid> --rootdir ./rootdir image.btrfs
750+
751+
The target image must be freshly created (e.g. with :command:`truncate`);
752+
like other mkfs tools :command:`mkfs.btrfs` does not zero space it does
753+
not write.
754+
755+
711756
AVAILABILITY
712757
------------
713758

0 commit comments

Comments
 (0)