summary refs log tree commit diff
path: root/nixos/modules/system/boot/loader/grub/install-grub.pl
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/system/boot/loader/grub/install-grub.pl')
-rw-r--r--nixos/modules/system/boot/loader/grub/install-grub.pl7
1 files changed, 7 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl
index 2615bc3ae11e..814ae7e05f7c 100644
--- a/nixos/modules/system/boot/loader/grub/install-grub.pl
+++ b/nixos/modules/system/boot/loader/grub/install-grub.pl
@@ -111,6 +111,13 @@ sub GrubFs {
                     die "invalid fs identifier type\n";
                 }
             }
+            if ($fs->type eq "btrfs") {
+                $subvol = `mount | sed -n 's,^$fs->device on .*subvol=\([^,)]*\).*$,\1,p'`
+                if ($subvol eq "") {
+                    $subvol = `btrfs subvol get-default $fs->mount | sed -n 's,^.*path \([^ ]*\) .*$,\1,p'`
+                }
+                $path = "/$subvol";
+            }
         }
         if (not $search eq "") {
             $search = "search --set=drive$driveid " . $search;