From c62f14e16d76970939bdb534f8af233f047c9863 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 21 Jan 2019 12:11:55 +0100 Subject: [PATCH] mxraid_assemble: Add support for nvme devices --- mxraid/mxraid_assemble | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index 54bb440..de9f5d0 100755 --- a/mxraid/mxraid_assemble +++ b/mxraid/mxraid_assemble @@ -134,7 +134,7 @@ if ($opts{l}) { my $md = $hd->mddev_by_member()->{$rec->[0]}; $md = 'n/a' unless defined $md; $reg{$md}+=1; - printf " %-5s %5s %-16s '%s'\n", $md, @$rec; + printf " %-5s %-9s %-16s '%s'\n", $md, @$rec; } print " Note: this doesn't look like a standard configuration.\n" if scalar keys %reg != 1; print "\n"; @@ -142,7 +142,7 @@ if ($opts{l}) { if ($VERBOSE >= 2) { print "Disks not part of a configured SW-RAID:\n"; for my $rec (@{$hd->non_raid_disks()}) { - printf " %5s %-16s '%s'\n", @$rec; + printf " %-9s %-16s '%s'\n", @$rec; } print "\n"; } @@ -159,7 +159,7 @@ if ($opts{n}) { $entry .= $opts{n}.':'; for my $rec (@{$hd->non_raid_disks()}) { my $dev = $rec->[0]; - next unless $dev =~ m/sd[a-z]+/; + next unless $dev =~ m/(sd[a-z]+|nvme\d+n\d+)/; if (grep {m|^/dev/$dev\d*\b|} @mounts) { warn "# NOTE: /dev/$dev is mounted, skipping.\n" if $VERBOSE >= 2; next; @@ -520,7 +520,10 @@ exit; sub discover_basic { my $self = shift; - my @disks = ( glob('/sys/block/sd[a-z]'), glob('/sys/block/sd[a-z][a-z]') ); # 676 disks max + # take only whole disks, no partitions + my @disks = grep {m:/(sd[a-z]+|nvme\d+n\d+)$:} ( + glob('/sys/block/sd[a-z]*'), glob('/sys/block/nvme[0-9]*') + ); my $diskinfo = $self->get_hd_info(\@disks); my @non_raid; my %configured_raids; @@ -670,13 +673,16 @@ exit; # } my $serial_number; - if (-e '/sys/block/'.$dk.'/device/vpd_pg80') { + if (-e '/sys/block/'.$dk.'/device/vpd_pg80') { # exists even for ahci attached disks # Vital Product Data, page xyz my $vpd_pg80 = parse_vpd_pg80(sys_fs_get_prop('/sys/block/'.$dk.'/device/vpd_pg80')); if (defined $MxRaid::HostData::BAD_MODELS{uc($model)}) { $vpd_pg80 = $MxRaid::HostData::BAD_MODELS{uc($model)}($vpd_pg80); } $serial_number = $vpd_pg80; + } elsif (-e '/sys/block/'.$dk.'/device/serial') { # nvme disks are supposed to have this + $serial_number = sys_fs_get_prop('/sys/block/'.$dk.'/device/serial'); + $serial_number =~ s/^\s+//; } else { if ($self->{root_priv}) { $serial_number = smartctl_info($dev_list->[$i], 'Serial_Number');