Skip to content

Instantly share code, notes, and snippets.

@floriandejonckheere
Last active July 20, 2022 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floriandejonckheere/1f207a16820c3aec1e927cb8ac2eefd7 to your computer and use it in GitHub Desktop.
Save floriandejonckheere/1f207a16820c3aec1e927cb8ac2eefd7 to your computer and use it in GitHub Desktop.
PXE install Windows 10

Install Windows 10 over PXE from Linux

Follow this guide if you want to install Windows over PXE using Arch Linux as a PXE server.

Ensure the PXE target is booting in UEFI mode (without CSM support). Set PCI LAN as first and only boot device, and disable UEFI IPv6 Network Stack (we'll boot over IPv4).

pacman -S dnsmasq wimlib darkhttpd samba

# Allow dnsmasq to send a PXE boot file
cat > /etc/dnsmasq.conf
  user=dnsmasq
  group=dnsmasq
  dhcp-boot=ipxe.efi
  enable-tftp
  tftp-root=/var/tftp/
  tftp-secure
^D

# If using NetworkManager
ln -s /etc/dnsmasq.conf /etc/NetworkManager/dnsmasq-shared.d/dnsmasq.conf

# Create necessary directories
mkdir -p /var/tftp/ /var/http/ /mnt/win10/ /mnt/iso/
chown dnsmasq:dnsmasq /var/tftp/

# Create a WinPE ISO
mount -o loop,ro Win10.iso /mnt/win10/
cat > /tmp/start.cmd
  cmd.exe
  pause
^D
mkwinpeimg --iso --windows-dir=/mnt/win10/ --start-script=/tmp/start.cmd /tmp/winpe.iso

# Copy WinPE files to HTTP folder
mount -o loop,ro /tmp/winpe.iso /mnt/iso/
cp /mnt/iso/sources/boot.wim /var/http/boot.wim
cp -r /mnt/iso/boot/ /var/http/boot/
umount /mnt/iso/

# Remove temporary files
rm /tmp/start.cmd /tmp/winpe.iso

# Copy wimboot to HTTP folder
wget https://github.com/ipxe/wimboot/releases/latest/download/wimboot -O /var/http/wimboot

# Create iPXE configuration file
cat > /var/http/default.ipxe
  #!ipxe
  
  kernel wimboot
  initrd boot/bcd                     BCD
  initrd boot/boot.sdi                boot.sdi
  initrd boot.wim                     boot.wim
  boot
^D

# Create samba share
cat > /etc/samba/smb.conf
  [REMINST]
  browsable = true
  read only = no
  guest ok = yes
  path = /mnt/win10/
^D

# Start samba server
systemctl start smb

# Start HTTP server
sudo darkhttpd /var/http/ &|

When the target machine boots into Windows PE, execute the following commands:

wpeinit
ipconfig
net use I: \\10.42.0.1\REMINST
I:\setup.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment