mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
nixos/grub: Grub detection is much simpler using subvol show
This commit is contained in:
parent
429f785135
commit
87d5e457fe
1 changed files with 7 additions and 21 deletions
|
@ -135,35 +135,21 @@ sub GrubFs {
|
||||||
|
|
||||||
# BTRFS is a special case in that we need to fix the referrenced path based on subvolumes
|
# BTRFS is a special case in that we need to fix the referrenced path based on subvolumes
|
||||||
if ($fs->type eq 'btrfs') {
|
if ($fs->type eq 'btrfs') {
|
||||||
my $subvol = "";
|
my ($status, @info) = runCommand("btrfs subvol show @{[$fs->device]}");
|
||||||
|
|
||||||
my ($status, @mounts) = runCommand('mount');
|
|
||||||
if ($status != 0) {
|
if ($status != 0) {
|
||||||
die "Failed to retreive mount info";
|
die "Failed to retreive subvolume info for @{[$fs->device]}";
|
||||||
}
|
}
|
||||||
my @subvols = join("", @mounts) =~ m/@{[$fs->device]} on [^\n]*subvol=([^,)]*)/;
|
my @subvols = join("", @info) =~ m/Name:[ \t\n]([^ \t\n]*)/;
|
||||||
if ($#subvols > 0) {
|
if ($#subvols > 0) {
|
||||||
die "Btrfs device @{[$fs->device]} listed multiple times in mount\n"
|
die "Btrfs subvol name for @{[$fs->device]} listed multiple times in mount\n"
|
||||||
} elsif ($#subvols == 0) {
|
} elsif ($#subvols == 0) {
|
||||||
$subvol = $subvols[0];
|
$path = "/$subvols[0]$path";
|
||||||
} else {
|
}
|
||||||
my ($status, @btrfsOut) = runCommand("btrfs subvol get-default @{[$fs->mount]}");
|
|
||||||
if ($status != 0) {
|
|
||||||
die "Failed to retrieve btrfs default subvolume"
|
|
||||||
}
|
|
||||||
my @results = join("", @btrfsOut) =~ m/path ([^ ]*)/;
|
|
||||||
if ($#results > 0) {
|
|
||||||
die "Btrfs device @{[$fs->device]} has multiple default subvolumes\n";
|
|
||||||
} elsif ($#results == 1) {
|
|
||||||
$subvol = $results[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$path = "/$subvol" . $path;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not $search eq "") {
|
if (not $search eq "") {
|
||||||
$search = "search --set=drive$driveid " . $search;
|
$search = "search --set=drive$driveid " . $search;
|
||||||
$path = "(\$drive$driveid)" . $path;
|
$path = "(\$drive$driveid)$path";
|
||||||
$driveid += 1;
|
$driveid += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue