How to unmark an NTFS cluster as bad?
I'll answer the title question nothing more.1
First, do note that, if the sector is truly bad, unmarking it won't make it readable. So your cloning software is likely to choke on reading it instead.
In NTFS, a cluster is marked as bad by assigning it to a special stream, $BadClus:$Bad
, a sparse file.
What you need is to
- edit its runlist to remove the corresponding allocated block(s)
- mark the corresponding cluster(s) as free in
$Bitmap
.
To unmark all bad blocks, there's
ntfsfix -b -d
(-b
=clear bad block list,-d
=clear/don't set "dirty" flag) (another method withntfstruncate
does exactly the same2).- It might introduce minor inconsistencies into metadata (in my case, a few indices apparently became unsorted), I'm not sure why, so either run
chkdsk -f
by hand or omit-d
to trigger it at Windows startup if / in case you get FS errors.
- It might introduce minor inconsistencies into metadata (in my case, a few indices apparently became unsorted), I'm not sure why, so either run
To clear a specific block is much more difficult since I didn't find any existing software that can do this out of the box3. NTFS Bad Sectors Resolution: The $BadClus metafile - Katy's code describes the way - basically, it's editing the runlist and bitmap by hand.
1 Only because handling bad sectors + NTFS + cloning is too broad a topic. I'll gladly answer ones directly related to the matter at hand.
2 checked the source code of ntfsfix
v2015.3.14
.
3 for the insistent ones, these can't do it: ntfscat
(can't read unreadable sectors),ntfscp
(can't write to offset), ntfstruncate
,ntfsfallocate
,dd
(can't open $BadClus:$Bad
for writing)
I had a hard drive that developed some bad clusters. I replaced it with a known good drive. The restore process restored the bad cluster data as well as the other data. This was on a Windows 7 Enterprise computer.
My solution was to run "chkdsk d: /b" (as has been suggested previously). The /b tells it (for NTFS only) to rescan previously marked bad clusters. At least in my case (and I would suspect all versions that support /b), it clears the bad cluster list immediately before beginning the read scan. Once you see the message "Removing X clusters from the Bad Clusters File" you should be able to kill the chkdsk process (as it is only reading data).
Note: The potential does exist for chkdsk to be updating the bad clusters file at the instant you kill the process if it happened to find a bad sector at the beginning of the drive. I took the risk and it successfully reset the bad clusters file without the need to download a bunch of other programs that require a full chkdsk afterward anyway. YMMV.