site  contact  subhomenews

Ext4 with or without journal on flash stick

March 04, 2022 — BarryK

The ext4 filesystem with journal enabled, will write frequently to a flash stick, shortening its life. EasyOS image file has ext4 working-partition. Originally, it had the journal disabled; however, sometime early in 2020 I enabled the journal.

A post from 'rudyt' got me thinking about this again:

https://forum.puppylinux.com/viewtopic.php?p=51085#p51085

Now, I have to try and recall the reasoning at the time, that resulted in the journal being enabled. I have a far from perfect memory, so it is good that I post frequently to this blog...

March 02:
https://bkhome.org/news/202003/easyos-clean-shutdown-and-ssd-trim.html

June 20:
https://bkhome.org/news/202006/tracing-continuous-drive-activity.html

June 21:
https://bkhome.org/news/202006/change-ext4-journal-commit-interval-from-5-to-30.html

June 24:
https://bkhome.org/news/202006/fix-for-journal-commit-interval-change.html

As you can see in those links, I changed the journal default commit-interval from 5 seconds to 30 seconds, attempting to prolong life of the flash drive.

Should I go back to no journal? What about increasing the journal commit-interval to, say, 10 minutes? -- what will be the repercussions of doing that? Well, how about this:

https://superuser.com/questions/479379/how-long-can-file-system-writes-be-cached-with-ext4

...we could set the commit interval to 136 years, but any 'fsync' or 'sync' will flush data and journal immediately -- at least so it seems from online reading.

That is very interesting, it seems to mean that under normal shutdown, EasyOS does do a 'sync', so all is good. The problem would be with an abnormal shutdown, such as a system crash. The initrd currently mounts the working partition like this:

 mount -t ${WKG_FS} -o commit=30,rw,relatime,data=ordered /dev/${WKG_DEV} /mnt/${WKG_DEV} 2>/dev/null

...so, why don't I give it a try with "commit=600" (10 minutes)? Yeah, why not, will do that.

I still haven't quite got my head around all those "data=journal|ordered|writeback" options and how they affect frequency of writes to the drive.   

Tags: easy