diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 6396789e4a2..65d28e6bfa6 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -552,3 +552,6 @@ SYSTEMD_HOME_DEBUG_SUFFIX=foo \ * `$SYSTEMD_REPART_MKFS_OPTIONS_` – configure additional arguments to use for `mkfs` when formatting partition file systems. There's one variable for each of the supported file systems. + +* `$SYSTEMD_REPART_OVERRIDE_FSTYPE` – if set the value will override the file + system type specified in Format= lines in partition definition files. diff --git a/src/partition/repart.c b/src/partition/repart.c index 51706c839a3..3d4baac2950 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1378,9 +1378,18 @@ static int config_parse_fstype( void *userdata) { char **fstype = ASSERT_PTR(data); + const char *e; assert(rvalue); + /* Let's provide an easy way to override the chosen fstype for file system partitions */ + e = secure_getenv("SYSTEMD_REPART_OVERRIDE_FSTYPE"); + if (e && !streq(rvalue, e)) { + log_syntax(unit, LOG_NOTICE, filename, line, 0, + "Overriding defined file system type '%s' with '%s'.", rvalue, e); + rvalue = e; + } + if (!filename_is_valid(rvalue)) return log_syntax(unit, LOG_ERR, filename, line, 0, "File system type is not valid, refusing: %s", rvalue);