]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
installer: Add code to correctly write the fstab when installing on BTRFS
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 26 Feb 2024 17:41:51 +0000 (18:41 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 26 Feb 2024 17:41:51 +0000 (18:41 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/installer/hw.c

index b5b853e92daceb000683328029941c8de7d1ca43..26c473e9c42a3941f9a293f49c3ee5f5083ba418 100644 (file)
@@ -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);
        }