LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to detect a file system's dirty bit? (https://www.linuxquestions.org/questions/linux-general-1/how-to-detect-a-file-systems-dirty-bit-4175477384/)

catkin 09-16-2013 09:49 PM

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.

unSpawn 09-17-2013 01:06 AM

With ext.*fs you could
Code:

tune2fs -l /dev/devicename |awk -F':' '/^Filesystem s/ {print $2}'

catkin 09-17-2013 10:45 PM

Thanks unSpawn :)

catkin 09-20-2013 12:21 AM

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.

catkin 09-24-2014 02:06 AM

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.