0

Note: This question is specifically about hard links in Windows like those used by the Windows Component Store This question is not about Reparse Points, Symbolic Links, or Junctions.


I am using this system clone utility that seems to use DISM under the hood. Occasionally during cloning it fails with the following error:

Clone failed - Error 9 - The file or directory is corrupted and unreadable. (1392)

Sometimes the running the command Dism /Online /Cleanup-Image /StartComponentCleanup recommended in this answer seems to cure the problem. Other times a Windows Update seems to cure the problem. Sometimes, though, neither works.

That answer states the following about that command:

/StartComponentCleanup: Cleans the Component Store of any broken hard links

It's imperative folks on Insider Builds run this regularly due to the frequent updates

That all fits with my symptoms so far. A search for hard links shows that some files like the following are indeed hard links to the component store:

C:\> Get-Item 'C:\Program Files (x86)\WindowsPowerShell\Modules\Pester\3.4.0\Snippets\Context.snippets.ps1xml' | Select-Object LinkType,Target

LinkType : HardLink Target : {C:\Windows\WinSxS\wow64_microsoft.powershell.pester_31bf3856ad364e35_10.0.26100.1150_none_7a6e656d581b85dd\Context.snippets.ps1xml}

Sometimes, though, neither /StartComponentCleanup nor a Windows Update cures error 1392. Troubleshooting this error has become very slow because the 1392 failure occurs only about an hour into the operation.

So I've been looking for a way to test directly for "broken hard links". None of the techniques have resulted in detecting any broken hard links, though. To validate the broken hard link detection techniques I'm trying to create a hard link that is "broken" myself. Ideally that hard link would be broken in the same way that they apparently get broken in the component store by Windows Update.

Based on (probably misunderstanding) this answer I expected the following would create a broken hard link:

'content1' | Set-Content file.txt
$null =
New-Item               `
    -Path     link.txt `
    -ItemType HardLink `
    -Target   file.txt
Remove-Item file.txt
Get-Content link.txt
'content2' | Set-Content file.txt
Get-Content link.txt
Get-Content file.txt

But it outputs the following without error:

content1
content1
content2

So that doesn't seem to work to create broken hard links.

  1. Is there a way to create a "broken hard link" on Windows?
  2. If it's not possible, what is meant by "broken hard links" in this answer?
  3. If it is possible, how do I do create one?
alx9r
  • 391

0 Answers0