NTFS journals metadata so the file system itself doesn't corrupt if the machine goes down. I read this is not the case for file data itself. But what if the data is only appended at the end of the file? I think databases do this, so presumably it's safe, but I couldn't find documentation. I want to resume downloads safely after power on.

  • It may not be a problem, but the downloading program needs to check actual downloaded bits on your disk upon resuming. If it stores this information (How many bits have been downloaded?) in database or something, the actual state may be different. – Vlastimil Ovčáčík Dec 7 '15 at 11:43

It Depends.TM From TechNet, emphasis mine:

NTFS uses transaction logging and recovery to guarantee that the volume structure is not corrupted.

In theory, NTFS guarantees that either all of a volume structure update will be on disk or none of it will. Therefore, one of these two things will be the case after the power comes back up:

  1. The file is its old size and your new data is absent
  2. The file has its new size and your new data is... oh wait

The point of NTFS's journaling is to ensure that the bookkeeping and metadata aren't demolished if a change to them was in progress when the power was lost. This is accomplished with the change journal. (I have heard anecdotes of bad sectors appearing after power failures, but I can't find any official sources to confirm that such things happen.)

The user data, however, isn't always written when you think it is, especially in the presence of write caching. Even so, in that case, your volume is fine and nothing bad will have happened to the existing data, since it didn't get updated.

That said, if your download application isn't designed to deal with situations like this, it's entirely possible that the file will have been expanded but the new portion filled with zeroes. If the application updates multiple places, any OS write caching invalidates assumptions you might make about when user data gets written. (FILE_FLAG_WRITE_THROUGH might help, but even that can be ignored if advanced performance is enabled.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.