feat(fws-windows-bcdfix): add Intel VMD driver injection support for WinPE
Add support for injecting Intel VMD drivers into WinPE environment via a new DRV parameter. This enables proper NVMe device detection during Windows PE boot and installation. Changes: - Accept optional 5th parameter (DRV) for driver directory path - Embed driver files into WinPE boot image via drvload command - Register driver in target Windows installation via DISM - Copy driver directory into boot.wim fwsdrv folder for accessibility
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
# Args : <ISO_MOUNT> <ESP_MOUNT> <WIN_DISK> <ESP_PARTNUM>
|
# Args : <ISO_MOUNT> <ESP_MOUNT> <WIN_DISK> <ESP_PARTNUM>
|
||||||
# ============================================================
|
# ============================================================
|
||||||
set -u
|
set -u
|
||||||
ISO="${1:-}"; ESP="${2:-}"; WIN_DISK="${3:-}"; ESP_PN="${4:-1}"
|
ISO="${1:-}"; ESP="${2:-}"; WIN_DISK="${3:-}"; ESP_PN="${4:-1}"; DRV="${5:-}"
|
||||||
log(){ printf '\e[36m[bcdfix]\e[0m %s\n' "$*"; }
|
log(){ printf '\e[36m[bcdfix]\e[0m %s\n' "$*"; }
|
||||||
die(){ printf '\e[31m[bcdfix] ERREUR : %s\e[0m\n' "$*" >&2; exit 1; }
|
die(){ printf '\e[31m[bcdfix] ERREUR : %s\e[0m\n' "$*" >&2; exit 1; }
|
||||||
[ -d "$ISO" ] && [ -d "$ESP" ] && [ -b "$WIN_DISK" ] || die "args invalides"
|
[ -d "$ISO" ] && [ -d "$ESP" ] && [ -b "$WIN_DISK" ] || die "args invalides"
|
||||||
@@ -43,6 +43,8 @@ INI
|
|||||||
# winload.efi (NTFS auto-monté), et l'ESP par son label WINESP via diskpart.
|
# winload.efi (NTFS auto-monté), et l'ESP par son label WINESP via diskpart.
|
||||||
cat > "$TMP/fwspe.cmd" <<'CMD'
|
cat > "$TMP/fwspe.cmd" <<'CMD'
|
||||||
@echo off
|
@echo off
|
||||||
|
rem Pilote Intel VMD (si injecté) : le charger pour que WinPE VOIE les NVMe.
|
||||||
|
if exist X:\fwsdrv\*.inf for %%I in (X:\fwsdrv\*.inf) do drvload %%I
|
||||||
set WIN=
|
set WIN=
|
||||||
for %%D in (C D E F G H I J K L M N O P) do if exist %%D:\Windows\System32\winload.efi set WIN=%%D:
|
for %%D in (C D E F G H I J K L M N O P) do if exist %%D:\Windows\System32\winload.efi set WIN=%%D:
|
||||||
echo list volume > X:\dp.txt
|
echo list volume > X:\dp.txt
|
||||||
@@ -53,10 +55,17 @@ for /f "tokens=2" %%V in ('findstr /i "WINESP" X:\vol.txt') do (
|
|||||||
diskpart /s X:\dp2.txt
|
diskpart /s X:\dp2.txt
|
||||||
)
|
)
|
||||||
if not defined WIN goto reboot
|
if not defined WIN goto reboot
|
||||||
|
rem Enregistrer le pilote VMD dans le Windows appliqué (boot device) via DISM.
|
||||||
|
if exist X:\fwsdrv\*.inf dism /image:%WIN%\ /add-driver /driver:X:\fwsdrv /recurse /forceunsigned
|
||||||
if exist S:\ ( bcdboot %WIN%\Windows /s S: /f UEFI ) else ( bcdboot %WIN%\Windows /f UEFI )
|
if exist S:\ ( bcdboot %WIN%\Windows /s S: /f UEFI ) else ( bcdboot %WIN%\Windows /f UEFI )
|
||||||
:reboot
|
:reboot
|
||||||
wpeutil reboot
|
wpeutil reboot
|
||||||
CMD
|
CMD
|
||||||
|
# Pilote Intel VMD à embarquer dans la WinPE (pour drvload + dism) ?
|
||||||
|
if [ -n "$DRV" ] && [ -d "$DRV" ]; then
|
||||||
|
mkdir -p "$TMP/fwsdrv"; cp -rf "$DRV"/. "$TMP/fwsdrv/" 2>/dev/null || true
|
||||||
|
log "Pilote Intel VMD embarqué dans la WinPE (drvload + dism)."
|
||||||
|
fi
|
||||||
# Image amorcée = « Boot Index » (typiquement 2) ; on injecte aussi l'index 1 en ceinture.
|
# Image amorcée = « Boot Index » (typiquement 2) ; on injecte aussi l'index 1 en ceinture.
|
||||||
BOOTIDX="$(wimlib-imagex info "$TMP/boot.wim" 2>/dev/null | sed -n 's/^Boot Index:[[:space:]]*//p' | head -1)"
|
BOOTIDX="$(wimlib-imagex info "$TMP/boot.wim" 2>/dev/null | sed -n 's/^Boot Index:[[:space:]]*//p' | head -1)"
|
||||||
[ -n "$BOOTIDX" ] || BOOTIDX=2
|
[ -n "$BOOTIDX" ] || BOOTIDX=2
|
||||||
@@ -67,6 +76,8 @@ for i in $BOOTIDX 1; do
|
|||||||
&& wimlib-imagex update "$TMP/boot.wim" "$i" \
|
&& wimlib-imagex update "$TMP/boot.wim" "$i" \
|
||||||
--command="add '$TMP/fwspe.cmd' /fwspe.cmd" 2>/dev/null \
|
--command="add '$TMP/fwspe.cmd' /fwspe.cmd" 2>/dev/null \
|
||||||
&& INJECTED=1
|
&& INJECTED=1
|
||||||
|
[ -d "$TMP/fwsdrv" ] && wimlib-imagex update "$TMP/boot.wim" "$i" \
|
||||||
|
--command="add '$TMP/fwsdrv' /fwsdrv" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
[ "$INJECTED" = 1 ] || die "injection winpeshl/fwspe dans boot.wim échouée"
|
[ "$INJECTED" = 1 ] || die "injection winpeshl/fwspe dans boot.wim échouée"
|
||||||
cp -f "$TMP/boot.wim" "$ESP/sources/boot.wim" || die "copie boot.wim → ESP échouée"
|
cp -f "$TMP/boot.wim" "$ESP/sources/boot.wim" || die "copie boot.wim → ESP échouée"
|
||||||
|
|||||||
Reference in New Issue
Block a user