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?

I think it would be best to directly start with the web based UI only. It should mostly work on Windows already and you can run it in edge etc. like the Linux live cd does. It is in the dev branch. You might have to port the backend for this from the dev branch as well.

2.6.x would be great, or dev branch and I can cherry pick it over.

Maybe it would fit into the wxwidgets UI repo? Given there is some UI tool to create the winpe ios? (Which windows users might perhaps want)

Short update: the web restore from the dev branch now also runs on Windows (WinPE), PR #183 for 2.6.x. I restored a Windows Server 2022 image from an Internet server in a WinPE VM with Secure Boot and it boots.

The ISO build script is in the frontend repo as PR #18 (run as admin with the Windows ADK installed). It puts Firefox ESR on the medium and opens the restore page on boot.

One open question is in the PR: should the client package include httpserver.dll and the restorewww folder, or should they be a separate download like the Linux restore tarball?

1 Like