]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
makefs: also set uuid/label for ext2/ext3
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 8 Nov 2021 11:18:30 +0000 (12:18 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Nov 2021 08:12:01 +0000 (09:12 +0100)
We were only "supporting" ext4. Let's add "support", i.e. pass our optimization
options and uuid/label for the other two fses in the same family.

Nowadays there is separate code in the kernel, all three fs types are handled
by ext4 code. ext2 in particular is useful for in-memory devices: the journal
is just a waste of space there. ext3 is added for completeness mostly, since
ext4 should probably be used instead. But people might use it for testing or
for compatibility with older systems and I don't see much reason to not add
"support" here.

src/shared/mkfs-util.c

index b9c2f147bc1d597716f93f7a72ed1208d98d77bc..1056de1bec200acb389a80b1d9879c604a17dafd 100644 (file)
@@ -68,7 +68,16 @@ int make_filesystem(
                 return r;
         if (r == 0) {
                 /* Child */
-                if (streq(fstype, "ext4"))
+                if (streq(fstype, "ext2"))
+                        (void) execlp(mkfs, mkfs,
+                                      "-L", label,
+                                      "-U", ID128_TO_UUID_STRING(uuid),
+                                      "-I", "256",
+                                      "-m", "0",
+                                      "-E", discard ? "discard,lazy_itable_init=1" : "nodiscard,lazy_itable_init=1",
+                                      node, NULL);
+
+                else if (STR_IN_SET(fstype, "ext3", "ext4"))
                         (void) execlp(mkfs, mkfs,
                                       "-L", label,
                                       "-U", ID128_TO_UUID_STRING(uuid),