diff --git a/man/repart.d.xml b/man/repart.d.xml
index 5cdf2b0f346..66faa8c057a 100644
--- a/man/repart.d.xml
+++ b/man/repart.d.xml
@@ -884,7 +884,9 @@
Note that this setting is only taken into account when
- is specified on the systemd-repart command line.
+ is specified on the systemd-repart command line. As the crypttab with the expected
+ hashes can only be generated after LUKS volumes are formatted, the crypttab itself cannot be put to
+ the generated volume.
diff --git a/src/repart/repart.c b/src/repart/repart.c
index a3e17cc294b..b3ecb62e93e 100644
--- a/src/repart/repart.c
+++ b/src/repart/repart.c
@@ -8501,7 +8501,7 @@ static bool need_crypttab(Context *context) {
return false;
}
-static int context_crypttab(Context *context) {
+static int context_crypttab(Context *context, bool late) {
_cleanup_(unlink_and_freep) char *t = NULL;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *path = NULL;
@@ -8544,7 +8544,7 @@ static int context_crypttab(Context *context) {
strempty(p->encrypted_volume->options));
}
- r = flink_tmpfile(f, t, path, 0);
+ r = flink_tmpfile(f, t, path, late ? LINK_TMPFILE_REPLACE : 0);
if (r < 0)
return log_error_errno(r, "Failed to link temporary file to %s: %m", path);
@@ -10755,6 +10755,14 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return r;
+ r = context_fstab(context);
+ if (r < 0)
+ return r;
+
+ r = context_crypttab(context, /* late= */ false);
+ if (r < 0)
+ return r;
+
r = context_update_verity_size(context);
if (r < 0)
return r;
@@ -10810,11 +10818,7 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return r;
- r = context_fstab(context);
- if (r < 0)
- return r;
-
- r = context_crypttab(context);
+ r = context_crypttab(context, /* late= */ true);
if (r < 0)
return r;