Всем привет!

В прошлом посте Windows 10: Сброс к заводским настройкам я рассказывал о двух методах возврата ОС в исходное состояние: «начать заново» и «возврат к исходному состоянию». На последней я хочу заострить внимание.

Функция возврата системы к исходному состоянию предлагает нам на выбор сохранение или удаление пользовательских данных. Так-же дополнительно можно очистить информацию только с системного или со всех дисков. Данные могут быть просто удалены или удалены без возможности воссстановления. Это полезно во время предпродажной подготовки оборудования.

Alt text

Я выбрал сценарий сохранения пользовательских данных. Он предполагает выполнение следующих шагов:

  • Сбор информации
  • Создание нового каталога Windows
  • Сборка системы путем создания жестких ссылок на уже имеющиеся файлы. В сборке участвуют компоненты, обновленные старше 30 дней во избежание проблем.
  • Установка компонентов
  • Установка обновлений
  • Перенос старой Windows в каталог Windows.old
  • Перенос новой Windows на диск C:\
  • Удаление каталога Windows.old
  • Настройка загрзчика и перезапуск в новую ОС
  • Установка оборудования

Таким образом мы получаем систему в первозданном виде, но с уже установленными обновлениями за исключением последних 30-ти дней. В добавок, нам совсем не потребовался доступ к Сети.

Информации от Майкрософт нет, поэтому займемся разбором лога.

Установщик собирает информацию об установленной системе

2019-04-15 22:20:25, Info Registry: Loading SOFTWARE hive from online OS
2019-04-15 22:20:25, Info Registry: Loading SYSTEM hive from online OS

Удаление снимков теневого копирования

Info OfflineBoot: -> Cleaning up VSS snapshots
Info Snapshot: Deleting all VSS snapshots on [C:]

Настройка запуска WinRE

Info OfflineBoot: -> Configuring BCD to boot WinRE
Info [SystemSettingsAdminFlows.exe] Enter WinReGetConfig
Info [SystemSettingsAdminFlows.exe] Parameters: configWinDir: NULL
Info [SystemSettingsAdminFlows.exe] WinRE config file path: C:\Windows\system32\Recovery\ReAgent.xml
Info [SystemSettingsAdminFlows.exe] Update enhanced config info is enabled.
Info [SystemSettingsAdminFlows.exe] WinRE is installed
Info [SystemSettingsAdminFlows.exe] WinRE is installed at: \?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE
Info [SystemSettingsAdminFlows.exe] System is WimBoot: FALSE
Info [SystemSettingsAdminFlows.exe] WinRE image validated
Info [SystemSettingsAdminFlows.exe] Exit WinReGetConfig return value: 1, last error: 0x0
Info OfflineBoot: -> Redirect WinRE BCD for bootstat.dat
Info OfflineBoot: -> Redirect WinRE BCD to [C:\$Sysreset\Logs\WinRE\bootstat.dat]
Info OfflineBoot: -> Configuring WinRE to launch offline client
Info [SystemSettingsAdminFlows.exe] Enter WinReSetRecoveryAction
Info [SystemSettingsAdminFlows.exe] Parameters: Operation: 7, OperationParam: -continue, Permanent: FALSE, ConfigWinDir: C:\Windows
Info [SystemSettingsAdminFlows.exe] Update enhanced config info is enabled.
Info [SystemSettingsAdminFlows.exe] WinRE is installed
Info [SystemSettingsAdminFlows.exe] Exit WinReSetRecoveryAction return value: 1, last error: 0x0

Перезагрузка

2019-04-15 23:11:59, Info OnlineUI: Initiate system reboot

Чтение и настройка конфигурации

Info LogSession: Reopened a log session at [C:\$SysReset\Logs]
Info ResetResumeLog: Reopened session logs in [C:\$SysReset\Logs]
Info OfflineUI: Continue: Loading session from [C:]
Info ResetLoadSession: Loading session from [C:]
Info WorkingDirs: Opening existing working directory tree at [C:\$SysReset]
Info LogSession: Closing log session at [C:\$SysReset\Logs]
Info LogSession: Reopened a log session at [C:\$SysReset\Logs]
Info Registry: Loading SOFTWARE hive from offline OS C:\Windows
Info Registry: Loading offline registry hive from [C:\Windows\System32\config\SOFTWARE]
Info Registry: No more open handles to [C:\Windows\System32\config\SOFTWARE], closing hive …
Info ResetLoadSession: Session loaded successfully
Info OfflineUI: Beginning execution
Info OfflineUI: Progress: [1]
Info ResetExecute: Executing offline phase of reset
Info Session: Suspending BitLocker protection per scenario requirements
Info Session: Checking main OS for a test ID
Info Telemetry: Checking [C:] for a test ID
Info Registry: Loading SOFTWARE hive from offline OS C:\Windows
Info Registry: Loading offline registry hive from [C:\Windows\System32\config\SOFTWARE]
Info Telemetry: No test ID present
Info Registry: No more open handles to [C:\Windows\System32\config\SOFTWARE], closing hive …
Info Session: Reading system configuration
Info SenseContext: Opening system BCD
Info SenseContext: Reading WinRE config
Info [sysreset.exe] Enter WinReGetConfig
Info [sysreset.exe] Parameters: configWinDir: NULL
Info [sysreset.exe] Using recovery file at \?\GLOBALROOT\Device\HarddiskVolume4\RECOVERY\WINDOWSRE\ReAgent.xml
Info [sysreset.exe] WinRE config file path: \?\GLOBALROOT\Device\HarddiskVolume4\RECOVERY\WINDOWSRE\ReAgent.xml
Info [sysreset.exe] Update enhanced config info is enabled.
Info [sysreset.exe] ReAgentConfig::ReadBcdAndUpdateEnhancedConfigInfo (In WinPE) Using winre guid from the config file
Info [sysreset.exe] WinRE is installed
Info [sysreset.exe] WinRE is installed at: \?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE
Info [sysreset.exe] System is WimBoot: FALSE
Info [sysreset.exe] Exit WinReGetConfig return value: 1, last error: 0x0
Info SenseContext: Checking whether the target OS [C:] is accessible …
Info SenseContext: Target is accessible, will load registry hives
Info SenseContext: Loading target SOFTWARE hive
Info Registry: Loading SOFTWARE hive from offline OS C:\Windows
Info Registry: Loading offline registry hive from [C:\Windows\System32\config\SOFTWARE]
Info SenseContext: Loading target SYSTEM hive
Info Registry: Loading SYSTEM hive from offline OS C:\Windows
Info Registry: Loading offline registry hive from [C:\Windows\System32\config\SYSTEM]
Info SenseContext: Loaded
Info SystemInfo: Reading BCD settings
Info SystemInfo: Locating the boot device
Info SystemInfo: This is Windows PE — finding the ramdisk host device
Info Registry: Loading SYSTEM hive from online OS
Info WindowsRE: Extracted RDPATH [MULTI(0)DISK(0)RDISK(0)PARTITION(4)\RECOVERY\WINDOWSRE\WINRE.WIM] from start options [ NOEXECUTE=OPTIN MININT NOVGA RDIMAGEOFFSET=8192 RDIMAGELENGTH=3161088 RDPATH=MULTI(0)DISK(0)RDISK(0)PARTITION(4)\RECOVERY\WINDOWSRE\WINRE.WIM]
Info GetDriveType returned drive type [3] for media path [\?\GLOBALROOT\Device\HarddiskVolume4]
Info SystemInfo: Getting firmware info
Info SystemInfo: Reading host version number
Info SystemInfo: Searching for migration XML
Info SystemInfo: Reading power configuration
Info SystemInfo: Checking whether target OS volume is accessible …
Info SystemInfo: The target OS volume is accessible
Info SystemInfo: Checking if narrator auto start reg key turned on
Info SystemInfo: Detecting target BitLocker state
Info SystemInfo: Checking whether target is healthy
Info SystemInfo: Reading target build information
Info SystemInfo: PBR is in WinRE, detect Lean(CloudE) from edition. Edition = [Core]
Info SystemInfo: Reading target’s reset policy flags
Info SystemInfo: Searching target for OEM extensibility
Info SystemInfo: Checking whether target OS is Signature Edition …
Info SystemInfo: Get reconstruction version from registry key
Info SystemInfo: Failed to get the reconstruction version from registry key. Use Latest as default.
Info SystemInfo: Detecting Team OS
Info Registry: Loading SOFTWARE hive from online OS
Info SystemInfo: Detecting Windows-to-Go
Info SystemInfo: Locating WinRE
Info SystemInfo: Detecting current WinRE’s build number
Info SystemInfo: Detecting Narrator Running
Info Registry: No more open handles to [C:\Windows\System32\config\SOFTWARE], closing hive …
Info Registry: No more open handles to [C:\Windows\System32\config\SYSTEM], closing hive …
Info Session: Finished reading SystemInfo

Установщик определяет каталоги, которые создаст

Info ExecSetup: Creating new system via reconstruction
Info SP Creating new system (5). Old system root: C:\, System drive: C
Info SP ENVTRACK: Adding SystemDrive=C:
Info SP ENVTRACK: Result %SystemDrive%=C:
Info SP ENVTRACK: Adding WinDir=C:\Windows
Info SP ENVTRACK: Result %WinDir%=C:\Windows
Info SP ENVTRACK: Adding SystemRoot=C:\Windows
Info SP ENVTRACK: Result %SystemRoot%=C:\Windows
Info SP ENVTRACK: Adding CSIDL_WINDOWS=C:\Windows
Info SP ENVTRACK: Result %CSIDL_WINDOWS%=C:\Windows
Info SP ENVTRACK: Adding ProgramFiles=C:\Program Files
Info SP ENVTRACK: Result %ProgramFiles%=C:\Program Files
Info SP ENVTRACK: Adding CSIDL_PROGRAM_FILES=C:\Program Files
Info SP ENVTRACK: Result %CSIDL_PROGRAM_FILES%=C:\Program Files
Info SP ENVTRACK: Adding ProgramFiles(x86)=C:\Program Files (x86)
Info SP ENVTRACK: Result %ProgramFiles(x86)%=C:\Program Files (x86)
Info SP ENVTRACK: Adding CSIDL_PROGRAM_FILESX86=C:\Program Files (x86)
Info SP ENVTRACK: Result %CSIDL_PROGRAM_FILESX86%=C:\Program Files (x86)
Info SP ENVTRACK: Adding public=%SystemDrive%\Users\Public
Info SP ENVTRACK: Result %public%=C:\Users\Public
Info SP ENVTRACK: Adding ProfilesFolder=%SystemDrive%\Users
Info SP ENVTRACK: Result %ProfilesFolder%=C:\Users

Установщик определил недостаток дискового пространства

Info SP Settling on disk space requirements:
Info SP Full: 21474836480
Info SP Available: 13947105280
Info SP CNewSystem::PreInitialize: Low disk space detected. Will enabled optimized installation path.
Info SP NEO installation path is turned off in low disk space scenario

Установщик собирает список пакетов для сброса

Info CBS Enumerate packages for reset

Определяется дата точки отката.

Info CBS Go back to UTC timestamp: 0x01d44d136b34ab1b in filetime format

Создается каталог C:$WINDOWS.~BT\NewOS. Тут будет собираться новая операционная система. Старая система будет перемещена в каталог C:\Windows.old.

Установщик формирует новую систему, создавая жесткие ссылки на имеющиеся файлы пакетов. Это существенно экономит дисковое пространство.

Info CBS Migrate SxS configuration from old windows
Info CBS Copy HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType value from old windows
Info CBS Copy Removed FOD Markers from old windows
Info CBS Copying COMPONENTS hive from old windows.
Info CBS Hard-link Component Store from old windows

После сборки операционной системы, она будет перенесена из каталога C:$WINDOWS.~BT\NewOS на диск C:\

Определив недостаток дискового пространства, установщик удаляет уже ненужные файлы.

Info SP Cleanup operation «Cleanup caches in low-disk space» will cleanup:
Info SP Path: C:\hiberfil.sys
Info SP Path: C:\pagefile.sys
Info SP Path: C:\swapfile.sys
Info SP Path: C:\Windows\WinSxS\Reserve.tmp
Info SP Path: C:\ProgramData\Microsoft\Windows\WER
Info SP Path: C:\Windows\Minidump
Info SP Path: C:\Windows\LiveKernelReports
Info SP Cleanup operation «Cleanup Windows.old at end» will cleanup:
Info SP Path: C:\Windows.old\Windows
Info SP Path: C:\Windows.old\Program Files
Info SP Path: C:\Windows.old\Program Files (x86)
Info SP Path: C:\Windows.old\ProgramData
Info SP Path: C:\Windows.old\inetpub
Info SP Path: C:\Windows.old\SkyDriveTemp
Info SP Path: C:\Windows.old\Recovery
Info SP Path: C:\Windows.old\PerfLogs

Начинается установка пакетов обновлений

Info CBS Install permanent package: C:\Windows\Servicing\Packages\Package_for_KB4493510~31bf3856ad364e35~amd64~~17763.402.1.1.mum

Устанавливаются пакеты компонентов

Info CBS Install package: C:\Windows\Servicing\Packages\Package_for_DotNetRollup~31bf3856ad364e35~amd64~~10.0.1.2344.mum

Подготовка к перезагрузке в новую ОС

Info SP Operation (remaining): Prepare the new OS for first boot
Info SP Operation (remaining): Finalize critical boundary
Info SP Operation (remaining): Update Boot Code
Info SP Operation (remaining): Update Boot Sector
Info SP Operation (remaining): Relocate OS from C:\$WINDOWS.~BT\NewOS to C:\
Info SP Operation (remaining): Complete file operations for offline portion of first and oobe boot apply
Info SP Operation (remaining): Reserve space with file C:\$WINDOWS.~BT\Sources\Reserved.FirstApply (209715200)
Info SP AddSpace: add: 209715200, current: 209715200, peak: 209715200
Info SP Operation (remaining): Reserve space with file C:\$WINDOWS.~BT\Sources\Reserved.SecondApply (157286400)
Info SP AddSpace: add: 157286400, current: 367001600, peak: 367001600
Info SP Operation (remaining): Remove System Restore checkpoints
Info SP Operation (remaining): Close log files at C:\$WINDOWS.~BT\Sources\Panther
Info SP Operation (remaining): Reserve disk space first boot
Info SP AddSpace: add: 314572800, current: 681574400, peak: 681574400
Info SP AddSpace: add: 524288000, current:1205862400, peak:1205862400
Info SP Operation (remaining): Prepare SysPrep run
Info SP Operation (remaining): Upgrade security
Info SP Operation (remaining): First boot apply
Info SP Operation (remaining): Create registry key HKLM\SYSTEM\Setup\FirstBoot\Cleanup (value name: %SystemDrive%\$WINDOWS.~BT) on the new system
Info SP Operation (remaining): Stop suspended services
Info SP Operation (remaining): OOBE boot apply
Info SP Operation (remaining): Refresh localized strings
Info SP Operation (remaining): Execute provisioning migration
Info SP Operation (remaining): Start suspended services
Info SP Operation (remaining): Cleanup Windows.old at end

Операционная система загружается и начинается установка оборудования.