From 021b0ff4050dd3bbb55ebc8f4a8a97cc5c03e258 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 22 Sep 2023 13:47:14 +0200 Subject: [PATCH] repart: Don't fail on boot if we can't find the root block device When booting from virtiofs, we won't be able to find a root block device. Let's gracefully handle this similar to how we don't fail if we can't find a GPT partition table. --- src/partition/repart.c | 3 +++ units/systemd-repart.service.in | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/partition/repart.c b/src/partition/repart.c index 6cadc5f6683..2cc4881ada2 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -7344,6 +7344,9 @@ static int run(int argc, char *argv[]) { return r; r = find_root(context); + if (r == -ENODEV) + return 76; /* Special return value which means "Root block device not found, so not doing + * anything". This isn't really an error when called at boot. */ if (r < 0) return r; diff --git a/units/systemd-repart.service.in b/units/systemd-repart.service.in index b1322a159be..2b57b93ca87 100644 --- a/units/systemd-repart.service.in +++ b/units/systemd-repart.service.in @@ -31,5 +31,7 @@ Type=oneshot RemainAfterExit=yes ExecStart={{BINDIR}}/systemd-repart --dry-run=no +# The tool returns 76 if it can't find the root block device +SuccessExitStatus=76 # The tool returns 77 if there's no existing GPT partition table SuccessExitStatus=77 -- 2.47.3