diff options
author | William A. Kennington III <william@wkennington.com> | 2014-05-02 00:44:36 -0500 |
---|---|---|
committer | William A. Kennington III <william@wkennington.com> | 2014-08-28 13:35:36 -0700 |
commit | 87d5e457fe124facb261d13f52e14a7c6e6511af (patch) | |
tree | 0f4972f0420f3553ea167460fe5e41bb31b29f0e /nixos | |
parent | 429f785135ebca304767ecf435b5d5e979c2f3f2 (diff) | |
download | nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar.gz nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar.bz2 nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar.lz nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar.xz nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.tar.zst nixlib-87d5e457fe124facb261d13f52e14a7c6e6511af.zip |
nixos/grub: Grub detection is much simpler using subvol show
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index 6748a5ca08fa..82809edd6e86 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -135,35 +135,21 @@ sub GrubFs { # BTRFS is a special case in that we need to fix the referrenced path based on subvolumes if ($fs->type eq 'btrfs') { - my $subvol = ""; - - my ($status, @mounts) = runCommand('mount'); + my ($status, @info) = runCommand("btrfs subvol show @{[$fs->device]}"); 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) { - 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) { - $subvol = $subvols[0]; - } 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; + $path = "/$subvols[0]$path"; + } } } if (not $search eq "") { $search = "search --set=drive$driveid " . $search; - $path = "(\$drive$driveid)" . $path; + $path = "(\$drive$driveid)$path"; $driveid += 1; } } |