LinuxQuestions.org
Help answer threads with 0 replies.
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 12-05-2013, 06:31 AM   #1
subi211
LQ Newbie
 
Registered: Nov 2010
Distribution: Xubuntu 12.04
Posts: 9

Rep: Reputation: 0
Partitions mounted read-only do not increment mount count.


I have a minimum Ubuntu 12.04 install running on a homebrew arcade machine. The disk is an SSD split into three partitions, OS, Game and Log, all ext4. To avoid corruption issues, the OS and Game partitions are mounted as read-only by fstab, while Log is mounted read-write as normal.

One evening, when turning the machine on, Log refused to mount with a can't-start-journalling error. fsck fixed it in a jiffy, but I decided to start running fsck on each boot to automate the process should such an error ever occur again.

I dutifully performed tune2fs -c 1 on each partition and left it at that. However, over the next few days I noticed that the fsck didn't seem to be talking up much (if any) time. Given that there is well over a GB of data on the OS partition alone I would have expected it to at least be visible.

I checked when the last check was done via dumpe2fs -h, and found that checks were NOT being performed on the two read-only partitions. This seemed to be caused by the mount count not incrementing - it was 0 for OS and Game, but 1 for Log.

I changed OS and Log to mount read-write and the mount count was incremented and the check was duly performed on each boot. Making them read-only again stopped it.

Given that this is information updated by (presumably) the mount command, I would have expected the mount count to be incremented no matter what the partition is mounted as. Is there any way I can force the mount count to be incremented no matter what state the partition is mounted as?
 
Old 12-05-2013, 01:43 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,803

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Updating the mount count would require writing to the super block, and that is something the mount command is never going to do for a read-only mount. You could use the tune2fs command's "-C" (upper case) option to adjust the current mount count at any time:
Code:
Dev=/dev/sda2
Count=$(tune2fs -l $Dev | sed -ne 's/^Mount count: *//p')
tune2fs -C $((Count+1)) $Dev
An alternative would be to momentarily remount the file system read-write:
Code:
mount -o remount,rw /whatever
mount -o remount,ro /whatever
But, that is something you probably don't want to do routinely to your read-only partitions.

Or, you could just set the time interval between checks to some non-zero value and let that trigger the check.

Last edited by rknichols; 12-05-2013 at 01:50 PM. Reason: Add time interval suggestion
 
Old 12-06-2013, 04:48 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,314

Rep: Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172
Quote:
Originally Posted by subi211 View Post
Is there any way I can force the mount count to be incremented no matter what state the partition is mounted as?
I wouldn't think so.
Not with (current) ext4 anyway. Used to be "read only" was effectively ignored, and any outstanding journal entr{y,ies} was/were always replayed on mount - even a "read only" mount. Messed with forensic/recovery situations something terrible.

Ted changed this a while back on ext4 so read only means just that.

Maybe convert to ext3 if you really feel the need - but what benefit is fsck on a filesystem that's never updated ?.
 
Old 12-06-2013, 11:09 AM   #4
subi211
LQ Newbie
 
Registered: Nov 2010
Distribution: Xubuntu 12.04
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Maybe convert to ext3 if you really feel the need - but what benefit is fsck on a filesystem that's never updated ?.
Almost certainly none, you're quite correct. I've been trying to thing of anything that could affect a read-only filesystem and I couldn't come up with anything (corruption due to power failure being my major concern). But I thought better safe than sorry.

Also, I was curious. I would have thought that superblock information was required to be accurately maintained, even on read-only, so I was quite surprised when it wasn't. However, that being said...

Quote:
Originally Posted by rknichols View Post
Or, you could just set the time interval between checks to some non-zero value and let that trigger the check.
Yes, that does work. Even manages to write the last check and last write times to the superblock (although the last mount time remains un-updated). So something still writes to it while it's read-only anyway.

Last edited by subi211; 12-06-2013 at 11:29 AM.
 
Old 12-06-2013, 02:01 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,803

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by subi211 View Post
So something still writes to it while it's read-only anyway.
At the time fsck is run, the file system isn't mounted at all.
 
Old 12-06-2013, 03:13 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by subi211 View Post
Almost certainly none, you're quite correct. I've been trying to thing of anything that could affect a read-only filesystem and I couldn't come up with anything (corruption due to power failure being my major concern). But I thought better safe than sorry.

Also, I was curious. I would have thought that superblock information was required to be accurately maintained, even on read-only, so I was quite surprised when it wasn't. However, that being said...


Yes, that does work. Even manages to write the last check and last write times to the superblock (although the last mount time remains un-updated). So something still writes to it while it's read-only anyway.
You are specifically directing fsck to update the filesystem...

And as other pointed out, fsck only works when the filesystem is NOT mounted. IF all you are doing is checking for problems, but don't want anything updated, use the -N option.
 
  


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
i think the LQ sugjestions and feedback board should not increment post count smeezekitty LQ Suggestions & Feedback 4 10-16-2009 09:37 AM
Boot mount errors - partitions busy or already mounted Frank64 Linux - General 0 06-28-2008 10:35 AM
Mount, READ and WRITE reiserfs and ext3 partitions smiley_lauf Linux - Newbie 21 04-03-2006 05:11 PM
Users cannot mount or access mounted windows vfat partitions (Distro: Gentoo Linux) kamel Linux - Software 6 05-15-2004 07:08 PM
mount windows partitions so users (and not just root) can read it TheOneAndOnlySM Slackware 1 10-10-2003 06:20 PM

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

All times are GMT -5. The time now is 10:06 AM.

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