Commit 1382b7d0 authored by David Johnson's avatar David Johnson

Add nvme support to mkextrafs on Linux.

The problem is that nvme block devs on Linux have a radically different
naming convention (nvmeXnYpZ).  So, I just supported that.  I was going
to try to understand all the naming conventions, but I couldn't quickly
find a document that claimed to describe them all.  Oh well.

(I also added a fallback autodetect the rootdev on Linux that uses
newer methodologies, back when I hadn't understood the problem.)
parent 4faf8369
......@@ -62,6 +62,10 @@ my $GPTUNUSED = "00000000-0000-0000-0000-000000000000";
my $GPTLINUXDATA = "0FC63DAF-8483-4772-8E79-3D69D8477DE4";
my $GPTLINUXLVM = "E6D6D379-F507-44C2-A23C-238F2A3DF928";
# Does the partitioned device have a 'p' before the partition number?
# We try to detect that, rather than hardcoding specific formats.
my $NEEDSPFORMAT = 0;
#
# Turn off line buffering on output
#
......@@ -157,16 +161,44 @@ if (!$lvm || ($lvm && $lmonster)) {
if (defined($diskopt)) {
$disk = $diskopt;
$disk =~ s/^\/dev\///;
if ($disk =~ /^nvme\dn\d+$/) {
$NEEDSPFORMAT = 1;
}
}
else {
my $rootdev = `df | egrep '/\$' | grep -v rootfs`;
if ($rootdev =~ /^\/dev\/([a-z]+)\d+\s+/) {
$disk = $1;
print "disk = $disk\n";
}
elsif ($rootdev =~ /^\/dev\/(nvme\dn\d+)p\d+\s+/) {
$disk = $1;
$NEEDSPFORMAT = 1;
print "nvme disk = $disk\n";
}
else {
my $rpartdev = `blkid -L /`;
chomp($rpartdev);
if ($? == 0 && $rpartdev =~ /^\/dev\/(.*)$/) {
my $bpath = `readlink -f /sys/class/block/$1`;
chomp($bpath);
if ($? == 0) {
if ($bpath =~ /.+\/([^\/]+)\/([^\/]+)$/) {
$disk = "$1";
if ($disk =~ /^nvme\dn\d+$/) {
$NEEDSPFORMAT = 1;
}
}
}
}
}
}
my $diskdev = "/dev/${disk}";
my $fsdevice = "${diskdev}${slice}";
if ($NEEDSPFORMAT) {
$fsdevice = "${diskdev}p${slice}";
}
#
# For LVM, just exit if the physical volume already exists
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment