From c975a8578cf58ffe8fe0fac2ba0afe49b2e6c823 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 26 Feb 2024 18:41:51 +0100 Subject: [PATCH] installer: Add code to correctly write the fstab when installing on BTRFS Signed-off-by: Stefan Schantl --- src/installer/hw.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index b5b853e92..26c473e9c 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1260,6 +1260,7 @@ int hw_write_fstab(struct hw_destination* dest) { return -1; char* uuid = NULL; + char mount_options[STRING_SIZE]; // boot if (*dest->part_boot) { @@ -1295,7 +1296,16 @@ int hw_write_fstab(struct hw_destination* dest) { // root uuid = hw_get_uuid(dest->part_root); if (uuid) { - fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + if(dest->filesystem == HW_FS_BTRFS) { + // Loop through the array of known BTRFS subvolumes + for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) { + snprintf(mount_options, sizeof(mount_options), "defaults,%s,subvol=%s", BTRFS_MOUNT_OPTIONS, btrfs_subvolumes[i][0]); + fprintf(f, FSTAB_FMT, uuid, btrfs_subvolumes[i][1], "btrfs", mount_options, 1, 1); + } + } else { + fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + } + free(uuid); } -- 2.39.5