LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-16-2013, 09:49 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
Old 09-17-2013, 01:06 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
With ext.*fs you could
Code:
tune2fs -l /dev/devicename |awk -F':' '/^Filesystem s/ {print $2}'
 
1 members found this post helpful.
Old 09-17-2013, 10:45 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks unSpawn
 
Old 09-20-2013, 12:21 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.

Last edited by catkin; 09-20-2013 at 12:22 AM. Reason: prettification
 
1 members found this post helpful.
Old 09-24-2014, 02:06 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to detect file system of a ramdisk.img? chinabenjamin66 Linux - Embedded & Single-board computer 4 11-11-2012 01:09 AM
detect file deletion on an operating system and trace the file history or activity? lovsis Linux - Security 2 10-19-2010 08:52 AM
detect bit mode (32 vs 64 bit) for linux powah Linux - General 1 06-01-2007 11:36 AM
Detect storage device by checking mounted file system to Linux syseeker Programming 4 02-06-2006 10:14 AM
Slack 9.1 shuts down leaving file system dirty wartstew Slackware 3 10-15-2003 07:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration