0Windows Update IconWindows 7 to 10 upgrade error 0x8007001f

I was recently try­ing to upgrade a Win­dows 7 PC to Win­dows 10 but after sev­er­al reboots the win­dows 10 install­a­tion was fail­ing with an error “The install­a­tion failed in the SAFE_OS phase with an error dur­ing REPLACE_OC oper­a­tion” with code 0x8007001f — 0×20006.

The fix

I’ll start with the even­tu­al fix that worked, but below I will also include the instruc­tions for repair­ing Win­dows 7 sys­tem files as these may also be use­ful in oth­er cir­cum­stances, although they I did­n’t man­age to fix my prob­lem with them on this occasion.

The actu­al “fix” was simple. I did an “upgrade” install of the exist­ing Win­dows 7 SP1 to.… Win­dows 7 SP1! This is basic­ally a repair install. You need a Win­dows 7 SP1 ISO which matches the ver­sion of win­dows installed. Extract it to a folder and then run setup. You will get the option to keep all exist­ing files which you must select. Once the repair install is suc­cess­ful you can run the win­dows 10 upgrade and if you’re lucky like I was it will then com­plete successfully.

The Win­dows 7 ISO can still be down­loaded from Microsoft (which is obvi­ously much safer than from 3rd party sites) but you will need a legit­im­ate retail key (not an OEM key sadly) to do so. If you are forced to resort to unof­fi­cial sources please make sure you check the hash of the file to ensure it has­n’t been altered.

Fixing Windows 7 system files

Note: Before start­ing make sure you have run a disk scan with chkdsk /f /r

I tried run­ning the SURT tool (aka the Sys­tem Update Read­i­ness Tool KB947821) but gave up with it after sev­er­al hours as there was clearly sig­ni­fic­ant cor­rup­tion some­where. Instead I installed KB2966583 which installed quickly and allowed me to use the DISM tool to log and repair any cor­rup­tion of sys­tem files. SURT is basic­ally just a wrap­per for DISM with no visu­al feed­back so using DISM manu­ally is preferable.

After using the Check­SUR log (%WINDIR%\Logs\CBS\CheckSUR.log) I was able to identi­fy a large num­ber of cor­rupt update files that needed to be repaired. This is easi­er to do via a bit of manip­u­la­tion in note­pad and then excel…

  • open the file in notepad
  • delete everything at the top of the file down to and inc “Check­ing Packages”
  • delete everything at the bot­tom of the file from “Check­ing Com­pon­ent Store” and downwards
  • do a search replace of the following 
    • (f)CBS MUM Missing0x00000002servicing\Packages\Package_” -> “” (i.e. blank)
    • _” -> “,” (under­score to comma)
    • ~” -> “,” (tilde to comma)
  • Save the file as a CSV
  • Open in excel
  • Sort by column A
  • Delete all rows start­ing with (fix)
  • Re-sort by column C (which is the only column of interest now)
  • There may be lots of repeat entries in column C. simply remove all duplic­ates so there is just 1 entry for each KB number
  • That is the list of updates you need to download

Once you’ve got the list of needed updates…

  • Check which ver­sion of win­dows you are run­ning — x64 or x86
  • Down­load the pack­ages from the microsoft update cata­log or use google for the few that aren’t lis­ted on the update cata­log. Make sure you down­load the updates for the cor­rect OS: win­dows 7, 64bit or 32bit.
  • Browse to %SYSTEMROOT%\CheckSUR\ and cre­ate a folder called “pack­ages” if it does­n’t already exist
  • copy the .msu files into %SYSTEMROOT%\CheckSUR\packages\
  • Open an elev­ated com­mand prompt
  • run DISM /Online /Cleanup-Image /Scanhealth
  • When it has fin­ished check the Check­SUR log again
  • repeat the pro­cess with addi­tion­al updates if needed
  • when DISM is happy, run sfc /scannow

Once this is com­plete your win­dows 7 should be fully fixed, but as my example shows, there can clearly still be some issues in some cases. If I had to guess the issue at this point is likely to be with per­mis­sions or pos­sibly with the registry. This pro­cess should at least fix win­dows updates.

Leave a Reply