grub: Add support for detecting btrfs subvolumes

This commit is contained in:
William A. Kennington III 2014-04-29 22:53:11 -05:00
parent fba9f641a8
commit a6e6c85f06
2 changed files with 8 additions and 1 deletions

View File

@ -28,7 +28,7 @@ let
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout
default devices fsIdentifier;
path = (makeSearchPath "bin" [
pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils
pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfsProgs
]) + ":" + (makeSearchPath "sbin" [
pkgs.mdadm pkgs.utillinux
]);

View File

@ -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;