Linux – NTFS; marking sectors bad using Linux


I have a massive ZFS array on my fileserver. Whenever a disk reports bad sectors to smartmon, I order a replacement, and I shelve the failing one.

And by "shelving the failing one", I mean that I give it a low-level format if applicable, or a destructive badblocks run to possible claim spare sectors to replace the bad ones, then use it to dump my DVDs (and lately BluRays) on, so that I can use it with my HTPC and bring it with me when going to my friends to watch movies. It's just a really easy and portable way to watch movies with XBMC. I have the stuff on pressed discs already, so I'm not dependent on their reliance, and the dying drive just gets a hospice life serving as quick-access media storage. Keeping in mind Google's reports that drives are 39x more likely to die within 60 days after their first SMART error, I'm expanding that period by the fact that these drives mostly remain on their shelves and are only plugged into the SATA bay once or twice every year.

I'm just saying this to make clear that I'm not confused about these drives dying, and I'm not looking to elongate their lives 😉

So. Sometimes these drives, after a badblocks run, simply claim fresh sectors from the spare pool, but sometimes there aren't any left, and I face the fact that there are bad sectors in my FS. That's not a problem if you use one of a set of linux filesystems, as mkfs.* often takes a badblocks list as input. But seeing as I sometimes bring a drive or two to my girlfriend's (Mac) or one of my friends (usually Windows), I've decided to use NTFS for these things. Up untill now, when a drive had unrelocatable bad sectors, I've just written data to it, re-read it, and files that were bad were put in a "BAD_SECTOR_FILES" folder on the drive.

Sure, it works, but it would be really nice to be able to just mark those sectors bad instead. It's a lot of hassle the other way around.

So I read some posts, of which most quickly switch subject to the often accurate one of "replace your drive!!!", and some suggest spinrite, but really, I don't see why I should pay that much money for such a trivial task.

The alternative is to use ext3, but I'd like to hear if someone knows how I can feed badblocks output to mkfs.ntfs, so that the bad blocks aren't used. Or if there are other tools (I could use Windows in a VM) that do the same. I'm confused about chkdsk, it seems the bad sectors thing is FAT only?

Best Answer

To mark sectors as bad on an NTFS filesystem requires modification and knowledge of the hidden "$BadClus" file. I'm not sure of a Linux utility capable of editing that file.

I was under the impression that a non-quick NTFS format would scan the hard drive and mark bad sectors to skip later. Have you tried just reformatting the drive with bad sectors in a Windows VM using either the FORMAT command or diskmgmt.msc and then do a chkdsk to see if it reports the number of bad sectors consistent with what you've discovered?