How to detect a file system's dirty bit?
Is it possible to detect a file system's dirty bit before attempting to mount it?
The question arises for a backup script. Ideally it would run fsck if required before mounting to minimise the logging verbosity associated with a failed mount. In case the answer depends on the file system type, ext4 and JFS are of particular interest; others would be nice. |
With ext.*fs you could
Code:
tune2fs -l /dev/devicename |awk -F':' '/^Filesystem s/ {print $2}' |
Thanks unSpawn :)
|
And similarly with JFS2, jfs_tune -l and parse the "JFS state:" value from the output. Unlike for ext*, the state shows as "mounted" when it is, er, mounted; that can be convenient.
|
Finally we do not check JFS file systems to see if they are dirty before mounting them. It is so "cheap" to fsck a JFS file system that the cost of coding to avoid doing so unnecessarily is not justified. That can be a deciding factor between ext4 and JFS.
|
All times are GMT -5. The time now is 05:09 PM. |