Skip to content

Instantly share code, notes, and snippets.

@maynero
Last active May 17, 2022 12:30
Show Gist options
  • Save maynero/1de3fb6c12d5894ad2ede325d75a8a2a to your computer and use it in GitHub Desktop.
Save maynero/1de3fb6c12d5894ad2ede325d75a8a2a to your computer and use it in GitHub Desktop.
Install Windows 10 from iSCSI using iPXE

Install Windows 10 from iSCSI using iPXE

This assumes that you already have (and know) the following:

  1. iPXE
  2. HTTP server (or a TFTP server)
  3. iSCSI target
  4. Windows 10 ISO file
  5. A client that can boot via PXE

Prepare your iSCSI Target

  1. Mount your iSCSI target to either Windows using ISCSI Initiator or Linux using open-iscsi
  2. Format the drive as NTFS
  3. Copy the content of Windows 10 ISO file to the iSCSI target drive

Booting Instructions

using wimboot + WinPE

  1. Download wimboot an and upload it to your HTTP server
  2. Create windows_winpe_wimboot.ipxe and upload it to your HTTP server (Don't forget to replace iscsi-host, iscsi-url and http-url)
  3. Create startnet.cmd and upload it to your HTTP server
  4. For testing, you can chain load this file directly via iPXE shell otherwise add this to your existing iPXE menu
  5. Once booted you should be able to see the Windows Setup

without using wimboot

  1. Create windows_no_wimboot.ipxe and upload it to your HTTP server (Don't forget to replace iscsi-host and iscsi-url)
  2. For testing, you can chain load this file directly via iPXE shell otherwise add this to your existing iPXE menu
  3. Once booted you should be able to see the Windows Setup

Most information here are base from https://gist.github.com/robinsmidsrod/2234639

@echo off
@REM Initialize and wait for the network to be available
wpeinit
wpeutil WaitForNetwork
net start dnscache
@REM Mount the iSCSI drive as Drive W. Modify this part as needed.
echo rescan > "%SYSTEMROOT%\system32\diskpart.txt"
echo select disk 0 >> "%SYSTEMROOT%\system32\diskpart.txt"
echo select volume 0 >> "%SYSTEMROOT%\system32\diskpart.txt"
echo assign letter=W >> "%SYSTEMROOT%\system32\diskpart.txt"
diskpart /s %SYSTEMROOT%\system32\diskpart.txt
W:\setup.exe
#!ipxe
set iscsi-host 10.10.10.5
set iscsi-url iscsi:${iscsi-host}:::1:iqn.2020-10.com.example.test
# Force gateway to be the iSCSI target server (from https://gist.github.com/robinsmidsrod/2234639)
set netX/gateway ${iscsi-host}
# Prevent iPXE from detaching a SAN drive
set netX/keep-san 1
set root-path ${iscsi-url}:ipxestorage
sanboot --drive 0x80 ${root-path} || goto failed
boot || goto failed
:failed
shell
#!ipxe
set iscsi-host 10.10.10.5
set iscsi-url iscsi:${iscsi-host}:::1:iqn.2020-10.com.example.test
set http-url http://10.10.10.6
# Force gateway to be the iSCSI target server (from https://gist.github.com/robinsmidsrod/2234639)
set netX/gateway ${iscsi-host}
# Prevent iPXE from detaching a SAN drive
set netX/keep-san 1
# Hook the iSCSI target, this will ensure that the iSCSI is available when WinPE boots up
set root-path ${iscsi-url}:ipxestorage
sanhook --drive 0x80 ${iscsi-url}:ipxestorage
# Identify the architecture. If you only have amd64, you can remove this
cpuid --ext 29 && set arch amd64 || set arch x86
# set the kernet to use wimboot
kernel ${http-url}/kernel/wimboot
# Inject the startup script `startnet.cmd`, this should be the exact filename
# If you want different filename, you need to inject `winpeshl.ini`
initrd ${http-url}/os/windows/winpe/startnet.cmd startnet.cmd
# Inject winpe boot files
initrd ${http-url}/os/windows/winpe/${arch}/media/Boot/BCD BCD || goto failed
initrd ${http-url}/os/windows/winpe/${arch}/media/Boot/boot.sdi boot.sdi || goto failed
initrd ${http-url}/os/windows/winpe/${arch}/media/sources/boot.wim boot.wim || goto failed
boot || goto failed
:failed
shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment