views:

349

answers:

2

Hi folks!

I'd like to know whether it's possible to clear the NTFS dirty bit in bash script.

Thanks, User114788

A: 

Doing so is inherently unsafe. ntfsprogs has plans for a ntfsck, which would allow you to safely fix up and mark as clean a filesystem. However, the tool has not been implemented yet.

That said, simply clearing the dirty bit is a recipe for trouble. If a filesystem crashed you must run recovery before using it, which for now requires Windows as far as I know.

Why do you want to do that? Maybe there's a better way to do whatever you're trying to accomplish?

Steven Schlansker
I'm on Mac OS X and mount_ntfs -o rw,force does not mount NTFS drives unless dirty bit is reset. The major problem is that if you unplug an NTFS formatted USB stick without ejecting it on Windows (which is quite common), you cannot mount it read write.
That's because NTFS is a journaled filesystem. http://en.wikipedia.org/wiki/Filesystem_journalingThe dirty bit being set probably means that you need to replay the journal. If mount_ntfs can't do that, it should (and apparently does) refuse to mount the disk. Mounting a crashed disk without replaying the journal can cause *major* data loss.That said, I'm no NTFS expert. This is just how I believe it to work :-)
Steven Schlansker
A: 

The dirty bit is there because NTFS witnessed some corruption, not because it needs to replay its log (though the intuition here makes sense).

Are you trying to avoid a chkdsk run at startup? We call that 'autochk', and you can disable that via chkntfs. (Apparently we just love the term 'chk'.) Then you'll only get a chkdsk run when you ask for one.

jrtipton