diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-06-29 15:27:02 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-06-29 16:11:34 +0200 |
commit | 03c9e88fb7eb8973477c33aa63dc6bcf0cab52c9 (patch) | |
tree | 08d953db9e0bc74b49e265f5f3b298fdc2918cc6 /src/shared | |
parent | repart: Don't set filesystem sector size to 512 (diff) | |
download | systemd-03c9e88fb7eb8973477c33aa63dc6bcf0cab52c9.tar.xz systemd-03c9e88fb7eb8973477c33aa63dc6bcf0cab52c9.zip |
mkfs-util: Set sector size for btrfs as well
btrfs used to default the sector size to the page size and didn't
support anything else. Since 6.7, it defaults to 4K and using 4K
makes the filesystem compatible with all page sizes. So let's make
sure we use minimum 4K as well (lower causes failures on systems with
a 4K page size) but still allow larger sector sizes if specified by
the user.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/mkfs-util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index 4d440127e5..14bf82b564 100644 --- a/src/shared/mkfs-util.c +++ b/src/shared/mkfs-util.c @@ -461,6 +461,15 @@ int make_filesystem( if (quiet) stdio_fds[1] = -EBADF; + if (sector_size > 0) { + if (strv_extend(&argv, "--sectorsize") < 0) + return log_oom(); + + /* mkfs.btrfs expects a sector size of at least 4k bytes. */ + if (strv_extendf(&argv, "%"PRIu64, MAX(sector_size, 4 * U64_KB)) < 0) + return log_oom(); + } + } else if (streq(fstype, "f2fs")) { argv = strv_new(mkfs, "-g", /* "default options" */ |