Files
loc_az_hci/infrastructure/drivers/install-lsi-hba-drivers.ps1
defiQUG c39465c2bd
Some checks failed
Test / test (push) Has been cancelled
Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 09:04:46 -08:00

141 lines
6.0 KiB
PowerShell

# Install LSI HBA Drivers and Flash to IT Mode
# Supports: LSI 9207-8e (SAS2308)
param(
[string]$DriverPath = "",
[string]$FirmwarePath = "",
[switch]$FlashITMode = $true,
[switch]$Force = $false
)
$ErrorActionPreference = "Stop"
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "LSI HBA Driver Installation" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
# Check if running as Administrator
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "This script requires Administrator privileges." -ForegroundColor Red
exit 1
}
# Detect LSI HBAs
Write-Host "`nDetecting LSI storage controllers..." -ForegroundColor Yellow
$lsiControllers = Get-PnpDevice | Where-Object {
$_.FriendlyName -like "*LSI*" -or
$_.FriendlyName -like "*SAS2308*" -or
$_.FriendlyName -like "*9207*"
}
if ($lsiControllers.Count -eq 0) {
Write-Host "No LSI storage controllers detected." -ForegroundColor Yellow
Write-Host "This may be normal if controllers are not yet installed or drivers not loaded." -ForegroundColor Yellow
}
else {
Write-Host "Found $($lsiControllers.Count) LSI controller(s):" -ForegroundColor Green
foreach ($controller in $lsiControllers) {
Write-Host " - $($controller.FriendlyName): Status $($controller.Status)" -ForegroundColor White
}
}
# Download LSI driver if not provided
if ([string]::IsNullOrEmpty($DriverPath)) {
Write-Host "`nLSI mpt3sas driver information:" -ForegroundColor Yellow
Write-Host "For Windows: Download from Broadcom support site" -ForegroundColor Yellow
Write-Host "URL: https://www.broadcom.com/support" -ForegroundColor Yellow
Write-Host "`nFor Linux/Proxmox: mpt3sas driver is built into kernel 5.15+" -ForegroundColor Yellow
$tempPath = "$env:TEMP\LSI_Driver.exe"
Write-Host "Please download LSI driver and save to: $tempPath" -ForegroundColor Yellow
Read-Host "Press Enter after downloading (or Ctrl+C to skip Windows driver install)"
if (Test-Path $tempPath) {
$DriverPath = $tempPath
}
}
# Install Windows driver if provided
if (-not [string]::IsNullOrEmpty($DriverPath) -and (Test-Path $DriverPath)) {
Write-Host "`nInstalling LSI driver..." -ForegroundColor Yellow
try {
$process = Start-Process -FilePath $DriverPath -ArgumentList "/S /v/qn" -Wait -PassThru -NoNewWindow
if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 3010) {
Write-Host "LSI driver installed successfully." -ForegroundColor Green
}
else {
Write-Host "Installation completed with exit code: $($process.ExitCode)" -ForegroundColor Yellow
}
}
catch {
Write-Host "Error installing driver: $_" -ForegroundColor Red
}
}
# Flash to IT Mode (Linux/Proxmox)
if ($FlashITMode) {
Write-Host "`n=========================================" -ForegroundColor Cyan
Write-Host "LSI HBA IT Mode Firmware Flash" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "`nWARNING: Flashing firmware will erase current firmware!" -ForegroundColor Red
Write-Host "Ensure you have the correct IT mode firmware for your controller." -ForegroundColor Yellow
Write-Host "`nFor LSI 9207-8e (SAS2308), use firmware version P20 IT mode." -ForegroundColor Yellow
if (-not $Force) {
$confirm = Read-Host "`nDo you want to proceed with IT mode flash? (yes/no)"
if ($confirm -ne "yes") {
Write-Host "IT mode flash cancelled." -ForegroundColor Yellow
exit 0
}
}
Write-Host "`nIT mode firmware flash instructions:" -ForegroundColor Yellow
Write-Host "1. Boot into Linux/Proxmox or use Linux live USB" -ForegroundColor White
Write-Host "2. Download sas2flash or sas3flash utility" -ForegroundColor White
Write-Host "3. Download IT mode firmware (P20 for SAS2308)" -ForegroundColor White
Write-Host "4. Run: ./sas2flash -listall (to identify controller)" -ForegroundColor White
Write-Host "5. Run: ./sas2flash -o -f <firmware_file> -b <bios_file>" -ForegroundColor White
Write-Host "`nExample commands:" -ForegroundColor Cyan
Write-Host " ./sas2flash -listall" -ForegroundColor White
Write-Host " ./sas2flash -o -f 2308p20.fw -b mptsas2.rom" -ForegroundColor White
Write-Host "`nFor automated flash script, see: infrastructure/storage/flash-lsi-it-mode.ps1" -ForegroundColor Yellow
}
# Verify installation
Write-Host "`nVerifying LSI controller status..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
$updatedControllers = Get-PnpDevice | Where-Object {
$_.FriendlyName -like "*LSI*" -or
$_.FriendlyName -like "*SAS2308*" -or
$_.FriendlyName -like "*9207*"
}
if ($updatedControllers.Count -gt 0) {
Write-Host "Detected controllers:" -ForegroundColor Green
foreach ($controller in $updatedControllers) {
Write-Host " $($controller.FriendlyName): $($controller.Status)" -ForegroundColor White
}
}
else {
Write-Host "No LSI controllers detected. This may be normal if:" -ForegroundColor Yellow
Write-Host " - Controllers are not installed" -ForegroundColor White
Write-Host " - Running on Linux (use 'lspci | grep -i storage' to check)" -ForegroundColor White
Write-Host " - Drivers need to be installed" -ForegroundColor White
}
Write-Host "`n=========================================" -ForegroundColor Cyan
Write-Host "LSI HBA Driver Installation Complete" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "`nNext Steps:" -ForegroundColor Yellow
Write-Host "1. Verify storage shelves are detected" -ForegroundColor White
Write-Host "2. Check HBA status in OS" -ForegroundColor White
Write-Host "3. Verify IT mode firmware (if flashed)" -ForegroundColor White
Write-Host "4. Run storage health monitoring script" -ForegroundColor White