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

Create a tmpfs mount for logs to avoid storage wear #161

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

klutchell
Copy link
Owner

@klutchell klutchell commented Aug 1, 2022

Signed-off-by: Kyle Harding [email protected]
Resolves: #131

@klutchell klutchell marked this pull request as ready for review August 24, 2022 17:57
@klutchell klutchell changed the title Create tmpfs mount for logs to avoid storage wear Create 100MB tmpfs mount for logs to avoid storage wear Aug 26, 2022
@klutchell klutchell force-pushed the kyle/log-to-tmpfs branch 2 times, most recently from 3771e26 to d5e41f8 Compare August 26, 2022 13:23
@klutchell klutchell changed the title Create 100MB tmpfs mount for logs to avoid storage wear Create a tmpfs mount for logs to avoid storage wear Aug 26, 2022
@klutchell
Copy link
Owner Author

I would prefer to limit the tmpfs size to 100MB but the feature was only recently supported in the supervisor and is still not supported in the builder.

@klutchell klutchell marked this pull request as draft August 26, 2022 13:27
@klutchell
Copy link
Owner Author

klutchell commented Aug 29, 2022

Your thoughts on this @eiddor?

Essentially if we create a tmpfs mount at /var/lib/pihole then logs will be written to memory, and cleared on container recreation or reboot.

Pros:

  • does not write logs to SD card, thus extending life
  • does not accidentally fill up disk when bugs are encountered

Cons:

  • balena does not allow a custom max tmpfs size right now via compose, so it will default to half of total memory
  • logs will not persist, but they are writing to container ephemeral storage now anyway so no change here
  • logs will share space with application memory, so a lot of logs on a very low memory device might be an issue?

I'm tempted to go forward with this even if the tmpfs is larger than we want. This should only be an issue if the logs go crazy and then all of a sudden your device has 50% less memory. On a good day we should never notice the loss of a few hundred megabytes of memory? At least it won't fill your storage and risk bricking your device...

@eiddor
Copy link
Collaborator

eiddor commented Aug 29, 2022

Traveling so I can't test anything, but I think I'm good with this - We should probably have a recommended memory amount for the project just to avoid some of the smaller devices running into issues on day 1.

Is it worth testing this with the bugged version of pihole/PADD just to see the impact when there is a log issue?

@klutchell
Copy link
Owner Author

Traveling so I can't test anything, but I think I'm good with this - We should probably have a recommended memory amount for the project just to avoid some of the smaller devices running into issues on day 1.

Is it worth testing this with the bugged version of pihole/PADD just to see the impact when there is a log issue?

Great idea! Here is a branch with Pi-hole v2022.07.1, PADD v3.8.0 and the tmpfs for logs.
https://github.com/klutchell/balena-pihole/tree/kyle/logging-experiments

It should fill the tmpfs pretty fast and we will see what happens.

@klutchell
Copy link
Owner Author

The consequences of a full tmpfs seems manageable compared to a full data partition with possible corruption so I'm going to merge this and we can revert it down the road if it adds complications.

@klutchell klutchell marked this pull request as ready for review September 2, 2022 19:29
@klutchell klutchell merged commit e3fbeb3 into main Sep 2, 2022
@klutchell klutchell deleted the kyle/log-to-tmpfs branch September 2, 2022 19:34
@eiddor
Copy link
Collaborator

eiddor commented Sep 2, 2022

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use tmpfs for log directories to reduce storage media wear
2 participants