LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-06-2018, 11:03 AM   #1
kktsuri
LQ Newbie
 
Registered: Jan 2014
Distribution: Mint
Posts: 22

Rep: Reputation: Disabled
Prevent mount/unmount writes (timestamp updates) when mounted as read/write


First, I didn't know where to post this question, not sure if it's appropriate here. I wanted to post it on the kernel mailing list but that's for development only, and I'm asking about how to tweak a (stupid) behavior. If anyone knows a better place to ask about it, please direct me to it, but anyway.

Basically everytime you mount most filesystems via the Linux Kernel, especially as read/write, it tends to update the superblock or some equivalent to this (root directory, etc) depending on the filesystem, with a timestamp. The famous "superblock time is in the future" comes to mind here and all other problems related to this idiotic practice (in my opinion).

The thing is, I don't want the timestamps updated, ever, it's a pointless write to my USB flash drives which are very fragile (compared to SSDs) because it always writes TWICE to the same damn block and they have no (or weak) wear leveling. I don't want to mount the filesystem as read-only either, because then I have to remount it if I have to write something to it (which is quite rare, I usually just read from them). It writes TWICE because it writes it once when mounting and once when unmounting, even if I didn't touch a single file!!

So I decided to screw ext4 due to this stupid forced behavior and go with UDF for my thumb drives. Problem is, it still writes something on EVERY mount and umount that is not read-only and updates the stupid timestamp. Argh, I just want it to not touch my damn drive unless I write something to it specifically! (and yes I did mount with noatime and nodiratime, I always do, screw that!)

For the record, mounting it on Windows and NOT writing a single file to it (reading files is fine) does NOT update it at all and doesn't write to it (because I compare the raw image afterwards). Windows only updates the stupid timestamp if you write at least one thing to it, so it's much better behavior.

I will never understand this forced timestamp update bullshit and obsession (who cares if it's inaccurate, seriously? it causes more problems than it's worth), guess some people didn't learn a thing from the atime problems. Accessing something (even if just for reading) should never write to it, period.



___________

tl;dr
  • I want to mount my thumb drives as read/write so I don't have to remount if I end up writing to them later.
  • I want zero writes done to the thumbdrive UNLESS I end up writing to it, not have updated timestamps on the superblock "behind my back" (i.e. I want Windows' behavior on Linux)
  • If I have to disable ALL timestamps updates on the superblock/root dir, then so be it, that's even better.

I just want the kernel to stop writing to my thumbdrive when I mount it or umount it, and it's WAY harder than it seems.


Is there a hidden option I'm not aware of? Do I have to modify the kernel? Some kernel configuration or option perhaps (at build time)? I don't mind recompiling the kernel, but I want to know where and what I have to change for it to disable updating the timestamp on mount/umount or ANY writes on mount/umount at all, or at least disable it if I haven't actually written anything to the drive. If anyone knows where, please share!

(btw, I'm interested in UDF driver mainly, since it's what I'll be using on my thumb drives from now on (as they read just fine on Windows also), if that matters)
 
Old 05-07-2018, 05:32 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
The short answer, you can't do what you want to do. The amount of writing being done to the drive is so small as to not even matter. You're complaining about nothing. In the end, your drive will not wear out any faster. You're really overblowing the situation. I'd maybe have a few drinks and try to relax for a while.
 
Old 05-07-2018, 10:53 PM   #3
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
Unless I'm missing something, I don't see that behavior on my Debian box.
Code:
$ sudo mount /dev/sda6 /mnt  # spinning drive for b/u usually sleeping

$ date
Mon May  7 20:48:54 CDT 2018

$ stat /dev/sda6
  File: /dev/sda6
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 6h/6d   Inode: 2183        Links: 1     Device type: 8,6
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2018-05-07 07:34:00.391296259 -0500
Modify: 2018-05-07 07:33:55.995296434 -0500
Change: 2018-05-07 07:33:55.995296434 -0500
 Birth: -

$ cat /proc/mounts | grep sda6
/dev/sda6 /mnt ext4 rw,relatime,block_validity,delalloc,barrier,user_xattr,acl 0 0

$ uname -a
Linux debian 4.15.0-3-amd64 #1 SMP Debian 4.15.17-1 (2018-04-19) x86_64 GNU/Linux

Last edited by norobro; 05-07-2018 at 10:55 PM. Reason: added kernel version
 
Old 05-07-2018, 11:09 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,073

Rep: Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813
Quote:
Originally Posted by norobro View Post
Unless I'm missing something, I don't see that behavior on my Debian box.
You are missing something. Unmount /dev/sda6 and then run (as root) "tune2fs -l /dev/sda6 | grep time". You will find the time of your last mount recorded in the super block (and backup super blocks) in the filesystem. The only way to avoid that super block update is by mounting read-only.
 
1 members found this post helpful.
Old 05-07-2018, 11:16 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,241

Rep: Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638
Quote:
Originally Posted by AwesomeMachine View Post
You're really overblowing the situation.
What's the point of a rant if it's not overblown ...
Quote:
I'd maybe have a few drinks and try to relax for a while.
Always sage advice.
 
Old 05-08-2018, 08:32 AM   #6
kktsuri
LQ Newbie
 
Registered: Jan 2014
Distribution: Mint
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
The short answer, you can't do what you want to do. The amount of writing being done to the drive is so small as to not even matter. You're complaining about nothing. In the end, your drive will not wear out any faster. You're really overblowing the situation. I'd maybe have a few drinks and try to relax for a while.
Most USB Flash Drives or Memory Cards don't have wear leveling or anything fancy on their controller. Writing two times on it on every mount (because also at umount) is bad because it's on the same block. If it uses TLC you can expect up to ~1000 rewrites on the same block so that means only 500 mounts/umounts, if you do it twice a day it won't even last you a year.

I know the typical answer is that "but they're cheap buy new ones", but that is a much bigger inconvenience (mostly because transferring data to them back again is slow!) than disabling a stupid timestamp. I know there has to be an option in the kernel, if not, hack the source code itself obviously... if I knew where.

Do you know a better place (i.e. more about kernel internals) I could ask this? I mean somewhere about kernel internals. It would really help. (not on kernel mailing list, since that's for development only, sigh).

Last edited by kktsuri; 05-08-2018 at 08:33 AM.
 
  


Reply

Tags
kernel, mount, superblock, timestamp, write


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - Newbie 16 09-01-2010 10:07 AM
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - General 2 08-26-2010 04:32 PM
root unable to write on drive mounted with read/write perrmission aquash2000 Linux - Server 5 07-19-2008 01:20 PM
Mounted read-write Fat32 partition suddenly becomes read-only?? hohead Linux - General 8 04-05-2007 01:17 PM
Fs mounted in Read Only , Read Write Mode benjaminrtz Linux - General 2 07-31-2002 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration