summaryrefslogtreecommitdiffstats
path: root/src/partition/repart.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-06-17 12:57:26 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-06-18 07:34:01 +0200
commitff0771bfc86c647a7e8fd1bb25ad80df68e582db (patch)
tree28bb7bbdb4297837c045f606ac9730c0cad357e2 /src/partition/repart.c
parentpath-util: make path_equal() an inline wrapper around path_compare() (diff)
downloadsystemd-ff0771bfc86c647a7e8fd1bb25ad80df68e582db.tar.xz
systemd-ff0771bfc86c647a7e8fd1bb25ad80df68e582db.zip
repart: make No-Auto GPT partition flag configurable too
This is useful for provisioning initially empty secondary A/B root file systems. We don't want those to ever be considered for automatic mounting, for example in "systemd-nspawn --image=", hence we should create them with the No-Auto flag turned on. Once a file system image is dropped into the partition the flag may be turned off by the updater tool, so that it is considered from then on. Thew new option for this is called NoAuto. I dislike negated options like this, but this is taken from the naming in the spec, which in turn inherited the name from the same flag for Microsoft Data Partitions. To minimize confusion, let's stick to the name hence.
Diffstat (limited to 'src/partition/repart.c')
-rw-r--r--src/partition/repart.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index fdb376060e..1e4a10d37f 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -169,6 +169,7 @@ struct Partition {
EncryptMode encrypt;
uint64_t gpt_flags;
+ int no_auto;
int read_only;
int growfs;
@@ -243,6 +244,7 @@ static Partition *partition_new(void) {
.offset = UINT64_MAX,
.copy_blocks_fd = -1,
.copy_blocks_size = UINT64_MAX,
+ .no_auto = -1,
.read_only = -1,
.growfs = -1,
};
@@ -1312,6 +1314,7 @@ static int partition_read_definition(Partition *p, const char *path) {
{ "Partition", "Encrypt", config_parse_encrypt, 0, &p->encrypt },
{ "Partition", "Flags", config_parse_gpt_flags, 0, &p->gpt_flags },
{ "Partition", "ReadOnly", config_parse_tristate, 0, &p->read_only },
+ { "Partition", "NoAuto", config_parse_tristate, 0, &p->no_auto },
{ "Partition", "GrowFileSystem", config_parse_tristate, 0, &p->growfs },
{}
};
@@ -3269,6 +3272,17 @@ static uint64_t partition_merge_flags(Partition *p) {
f = p->gpt_flags;
+ if (p->no_auto >= 0) {
+ if (gpt_partition_type_knows_no_auto(p->type_uuid))
+ SET_FLAG(f, GPT_FLAG_NO_AUTO, p->no_auto);
+ else {
+ char buffer[ID128_UUID_STRING_MAX];
+ log_warning("Configured NoAuto=%s for partition type '%s' that doesn't support it, ignoring.",
+ yes_no(p->no_auto),
+ gpt_partition_type_uuid_to_string_harder(p->type_uuid, buffer));
+ }
+ }
+
if (p->read_only >= 0) {
if (gpt_partition_type_knows_read_only(p->type_uuid))
SET_FLAG(f, GPT_FLAG_READ_ONLY, p->read_only);
@@ -3409,7 +3423,7 @@ static int context_mangle_partitions(Context *context) {
if (r < 0)
return log_error_errno(r, "Failed to set partition label: %m");
- /* Merge the read only + growfs setting with the literal flags, and set them for the partition */
+ /* Merge the no auto + read only + growfs setting with the literal flags, and set them for the partition */
r = set_gpt_flags(q, partition_merge_flags(p));
if (r < 0)
return log_error_errno(r, "Failed to set GPT partition flags: %m");