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:

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:

June 20:

June 21:

June 24:

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:

...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, 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