Reputation: 1514
I'd like to know whether it's possible to clear the NTFS dirty bit in bash script.
Upvotes: 3
Views: 12828
Reputation: 12140
Though this question belongs on Unix.SE, you can clear the NTFS dirty bit with the ntfsfix
tool, which comes with the ntfs-3g
package in most Linux distributions. The -d
flag explicitly clears the dirty bit.
ntfsfix -d /dev/sda1
Upvotes: 6
Reputation: 2459
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.
Upvotes: 0
Reputation: 38536
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?
Upvotes: 1