Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partitioning: Reduce commit mount option for btrfs and ext4 to 120 #6919

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

ColorfulRhino
Copy link
Collaborator

Description

Mount option commit=600 (=10 minutes) seems pretty high.
Reduce it to 120 for ext4 (default for ext4 is commit=5) and 120 for btrfs (default for btrfs is commit=30) to reduce risk of losing data on power loss.

Only verly low settings (maybe 1-10) will have impact on performance according to documentation.

From ext4:

commit=nrsec (*)

This setting limits the maximum age of the running transaction to ‘nrsec’ seconds. The default value is 5 seconds. This means that if you lose your power, you will lose as much as the latest 5 seconds of metadata changes (your filesystem will not be damaged though, thanks to the journaling). This default value (or any low value) will hurt performance, but it’s good for data-safety. Setting it to 0 will have the same effect as leaving it at the default (5 seconds). Setting it to very large values will improve performance. Note that due to delayed allocation even older data can be lost on power failure since writeback of those data begins only after time set in /proc/sys/vm/dirty_expire_centisecs.

From btrfs:

commit=

(since: 3.12, default: 30)

Set the interval of periodic transaction commit when data are synchronized to permanent storage. Higher interval values lead to larger amount of unwritten data, which has obvious consequences when the system crashes. The upper bound is not forced, but a warning is printed if it’s more than 300 seconds (5 minutes). Use with care.

Sources:

How Has This Been Tested?

  • Change is reflected in fstab

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Mount option `commit=600` (=10 minutes) seems pretty high.
Reduce it to 120 for ext4 (default for ext4 is `commit=5`)
and 120 for btrfs (default for btrfs is `commit=30`) to reduce
risk of losing data on power loss.

Sources:
- https://www.kernel.org/doc/html/latest/admin-guide/ext4.html
- https://wiki.archlinux.org/title/Btrfs#Commit_interval
- https://btrfs.readthedocs.io/en/latest/Administration.html
@ColorfulRhino ColorfulRhino added the Needs review Seeking for review label Jul 8, 2024
@ColorfulRhino ColorfulRhino requested a review from a team as a code owner July 8, 2024 19:42
@github-actions github-actions bot added size/small PR with less then 50 lines Hardware Hardware related - kernel, u-boot, patches Framework Framework components BSP Board Support Packages labels Jul 8, 2024
@igorpecovnik igorpecovnik added the 08 Milestone: Third quarter release label Jul 9, 2024
Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is from the days when most people were using slow SD cards. Lets go with the time.

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Jul 9, 2024
@igorpecovnik igorpecovnik merged commit d638276 into armbian:main Jul 9, 2024
13 checks passed
@adeepn
Copy link
Member

adeepn commented Jul 9, 2024

This one is from the days when most people were using slow SD cards. Lets go with the time.

The question is no longer about the speed of the cards, but about minimizing the number of write operations and accesses to the card. In 10 minutes, there's a chance that several changes to the file system will be combined into one (for example, log files, databases, etc.).

The question of what is more important: the lifespan of the SD card or the survivability of the data in case of power loss remains open.

@ColorfulRhino
Copy link
Collaborator Author

minimizing the number of write operations and accesses to the card
The question of what is more important: the lifespan of the SD card or the survivability of the data in case of power loss remains open.

Yes, I kept this in mind, which is why I chose 120 instead of the default. 120 seconds is still quite a long time, considering the default for ext4 is 5 seconds. 120s is a compromise and can likely be lowered even more without meaningful impact.

That being said, my RPi has been running for about 7-8 years now 24/7 with just noatime as mount option, everything else default, and I have yet to see any signs of the SD card dying 😄

If anyone was seriously concerned about improving SD card lifespan, they would've made f2fs the default instead of ext4 long ago :)

for example, log files, databases, etc.

Don't run databases off of an SD card. Just don't do it 😆

For logs, Armbian is using ramlog by default (/var/log mounted to ZRAM)


BUT! Don't worry, I've got a few PRs lined up that will massively improve SD card lifespan if that's something you care about 😉

@adeepn
Copy link
Member

adeepn commented Jul 9, 2024

That being said, my RPi has been running for about 7-8 years now 24/7 with just noatime as mount option, everything else default, and I have yet to see any signs of the SD card dying 😄

You're falling into a perception error: your experience doesn't mean it works the same for everyone :)
I have about five SD cards that failed within six months to a year.
Moreover, on eMMC in some of our devices, the built-in sensor shows half the wear after two years with the current settings.

@ColorfulRhino
Copy link
Collaborator Author

You're falling into a perception error: your experience doesn't mean it works the same for everyone :)

True, but I do not believe that this is related to the commit mount option in any meaningful way. There are so many other factors at play. Just flashing a new image onto an SD card probably has magnitudes of higher impact on the writes than the mount option 😄

I have about five SD cards that failed within six months to a year.
Moreover, on eMMC in some of our devices, the built-in sensor shows half the wear after two years with the current settings.

Honestly, in that case I believe there has to be something else wrong. Some variable in your configuration that contributes to the wearing out big time.

Unrelated to eMMC, what brand and quality of SD cards were you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 Milestone: Third quarter release BSP Board Support Packages Framework Framework components Hardware Hardware related - kernel, u-boot, patches Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines
Development

Successfully merging this pull request may close these issues.

None yet

3 participants