Plan: Windows-based restore CD (WinPE)

The current restore CD is Linux-based. uroni suggested a Windows-based one, so here is what I’d like to build, and what I’ve already checked in a test VM (WinPE from the current Windows ADK, UEFI with Secure Boot on). I’d like your opinion before writing the real code.

What I tested:

  • The existing Windows client backend runs in WinPE as it is. Only the Visual C++ runtime DLLs have to be copied next to it. In restore mode it starts and listens on its ports. I haven’t done a full restore from a server yet.
  • Writing the MBR/GPT from a backup to .\PhysicalDriveN works with the existing code. Restoring a partition image onto the partition with the existing copy code worked too: a file in the restored file system has the same checksum as on the source.
  • Windows refuses raw writes into a mounted volume, and WinPE mounts new partitions (and gives them drive letters) as soon as the partition table is read. So the restore has to lock and dismount each volume before writing, which works. Turning automount off is worse: the volume stays offline and writes fail.
  • If the target disk is larger than the original, Windows rewrites the primary GPT header as soon as it re-reads the table, and leaves it pointing at an empty partition array. The restore therefore has to write a GPT that fits the new disk itself (the Linux CD uses gdisk for this).
  • WinPE has no Wi-Fi support, so LAN (or USB network) only.
  • The Windows ADK license allows WinPE for installing and recovering Windows but not redistributing it, so there can’t be a ready-made ISO download. Users would build the ISO with a script from the free ADK.

Plan:

  1. Windows code paths in the restore code: disk list via Windows APIs, lock/dismount, re-read the partition table, fix the GPT for larger disks.
  2. The wizard: it uses “dialog” today. A console version first, with the same text files. Maybe a GUI later.
  3. A PowerShell build script (ADK + WinPE add-on) that makes the ISO or USB stick, with an optional folder for extra drivers (e.g. RAID/NVMe).
  4. Restore to different hardware: edit the restored Windows registry with Windows’ own tools instead of chntpw.

Questions:

  • Is this something you’d want upstream, and on 2.6.x?
  • Is a console wizard OK for the first version?
  • Should the build script live in the main repo (e.g. restore_cd_win/) or separately?