Commit fa96c76e authored by Mike Hibler's avatar Mike Hibler
Browse files

Still more NVMe support changes.

parent 0aabaac8
......@@ -898,9 +898,13 @@ dolinux() {
;;
# NVM disks
nvd[0-9])
dtype="nvme0n1"
dtype="nvme"
dunit=`echo $disk | sed -e 's/nvd\([0-9][0-9]*\)$/\1/'`
lrootdev="8${dunit}${part}"
# XXX assume "n1"
ldisk="${dtype}${dunit}n1p"
rootdev="/dev/${ldisk}${part}"
;;
# SCSI
da[0-7])
......@@ -930,9 +934,12 @@ dolinux() {
return 1
;;
esac
dunit=`echo $dunit | sed -e 'y/01234567/abcdefgh/'`;
ldisk=$dtype$dunit
rootdev=/dev/${disk}s${part}
dunit=`echo $dunit | sed -e 'y/0123456789/abcdefghij/'`;
if [ "$dtype" != "nvme" ]; then
ldisk=$dtype$dunit
rootdev=/dev/${disk}s${part}
fi
#
# See if there is a valid filesystem UUID to use in fstab and grub.
......@@ -991,7 +998,13 @@ dolinux() {
# change the devices in fstab
echo " updating /etc/fstab"
sed -i .preemulab -e "s;^/dev/[hs]d.\([0-7]\);/dev/${ldisk}\1;" /mnt/etc/fstab || {
sed -i .preemulab -e "s;^/dev/[hs]d.\([0-9]\);/dev/${ldisk}\1;" /mnt/etc/fstab || {
echo "Failed to update /etc/fstab"
umount $rootdev
return 1
}
# XXX handle NVMe too...
sed -i '' -e "s;^/dev/nvme.n1p\([0-9]\);/dev/${ldisk}\1;" /mnt/etc/fstab || {
echo "Failed to update /etc/fstab"
umount $rootdev
return 1
......
......@@ -177,16 +177,22 @@ sub isSSD($)
my ($dev) = @_;
my $isssd = 0;
if (-e "/dev/$dev" && -x "/sbin/hdparm" &&
open(HFD, "/sbin/hdparm -I /dev/$dev 2>/dev/null |")) {
while (my $line = <HFD>) {
chomp($line);
if ($line =~ /:\s+solid state device$/i) {
$isssd = 1;
last;
if (-e "/dev/$dev") {
# hdparm doesn't seem to handle NVMe
if ($dev =~ /^nvme\d+n\d+/) {
$isssd = 1;
}
elsif (-x "/sbin/hdparm" &&
open(HFD, "/sbin/hdparm -I /dev/$dev 2>/dev/null |")) {
while (my $line = <HFD>) {
chomp($line);
if ($line =~ /:\s+solid state device$/i) {
$isssd = 1;
last;
}
}
close(HFD);
}
close(HFD);
}
return $isssd;
......@@ -294,7 +300,8 @@ sub findSpareDisks($;$) {
# device otherwise it is a disk device. But that got screwed up by,
# e.g., the cciss device where "c0d0" is a disk while "c0d0p1" is a
# partition. The new fallible heuristic is: if it ends in a digit
# but is of the form cNdN then it is a disk!
# but is of the form cNdN then it is a disk! And now there is
# "nvme0n1" and "nvme0n1p1" to consider!
#
if ($devpart =~ /^(\S+)(\d+)$/) {
my ($dev,$part) = ($1,$2);
......@@ -307,6 +314,14 @@ sub findSpareDisks($;$) {
$dev = $1;
}
# nvmeNnN(pN) format
elsif ($devpart =~ /(.*nvme\d+n\d+)(p\d+)?$/) {
if (!defined($2)) {
goto isdisk;
}
$dev = $1;
}
# This is a partition on an earlier discovered disk device,
# ignore the disk device. This is signalled by clearing the size.
if (exists($retval{$dev}{"size"})) {
......@@ -355,6 +370,7 @@ sub findSpareDisks($;$) {
# one final check: partition id
my $output = `sfdisk $sfcmd /dev/$dev $part 2>/dev/null`;
chomp($output);
$output =~ s/^\s+//;
if ($?) {
print STDERR "WARNING: findSpareDisks: error running 'sfdisk $sfcmd /dev/$dev $part': $! ... ignoring /dev/$devpart\n";
}
......@@ -370,20 +386,21 @@ isdisk:
next
if ($skipssds && isSSD($devpart));
if (!defined($mounts{"/dev/$devpart"}) &&
!defined($ftents{"/dev/$devpart"}) &&
if (!exists($mounts{"/dev/$devpart"}) &&
!exists($ftents{"/dev/$devpart"}) &&
$size >= $minsize) {
$retval{$devpart}{"size"} = $BLKSIZE * $size;
$retval{$devpart}{"path"} = "/dev/$devpart";
}
}
}
close(PFD);
foreach my $d (keys(%retval)) {
if (scalar(keys(%{$retval{$d}})) == 0) {
delete $retval{$d};
}
}
close(PFD);
return %retval;
}
......
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