Skip to content

os-helpers-fs: move logic to assert partition structure to helper file#3679

Draft
alexgg wants to merge 6 commits intomasterfrom
alexgg/dmcrypt-assert
Draft

os-helpers-fs: move logic to assert partition structure to helper file#3679
alexgg wants to merge 6 commits intomasterfrom
alexgg/dmcrypt-assert

Conversation

@alexgg
Copy link
Copy Markdown
Contributor

@alexgg alexgg commented May 21, 2025

Move the generic dmcrypt partition assertion logic. This is slightly different as paritions do not contain meta-data that can identify the encrypted partitions so dmsetup is used after the partition is mounted.

Change-type: patch


Contributor checklist

Reviewer Guidelines

  • When submitting a review, please pick:
    • 'Approve' if this change would be acceptable in the codebase (even if there are minor or cosmetic tweaks that could be improved).
    • 'Request Changes' if this change would not be acceptable in our codebase (e.g. bugs, changes that will make development harder in future, security/performance issues, etc).
    • 'Comment' if you don't feel you have enough information to decide either way (e.g. if you have major questions, or you don't understand the context of the change sufficiently to fully review yourself, but want to make a comment)

@alexgg alexgg marked this pull request as draft May 21, 2025 09:00
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg temporarily deployed to balena-staging.com May 21, 2025 09:00 — with GitHub Actions Inactive
@alexgg alexgg had a problem deploying to sign.balena-cloud.com May 21, 2025 09:01 — with GitHub Actions Error
@deploynaut
Copy link
Copy Markdown

deploynaut Bot commented May 21, 2025

One or more environments require approval before deploying workflow runs.

Maintainers, please inspect changes carefully for improper handling of secrets or other sensitive information.

To approve pending deployments, submit an approved review, or a commented review with /deploy.

@flowzone-app
Copy link
Copy Markdown
Contributor

flowzone-app Bot commented May 21, 2025

Website deployed to CF Pages, 👀 preview link https://0f30483c.balena-os.pages.dev

@alexgg alexgg temporarily deployed to balena-cloud.com May 21, 2025 10:45 — with GitHub Actions Inactive
@alexgg alexgg had a problem deploying to balena-cloud.com May 21, 2025 10:45 — with GitHub Actions Failure
alexgg added 6 commits May 26, 2025 18:18
Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
The memory check before a migration run was not taking into account
that the tmp directory is now compressed ram.

This change approximates the compressed size of the raw image which is
the biggest in the calculation. The rest of the file sizes are left as
is to provide some buffer for approximation failures and not to complicate
the logic excessively.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
The logic to assert encrypted partitions was being implemented in a
device specific way as part of cryptsetup - move it to common code so
that this does not need to be re-implemented for every device type.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
…erts

Use the shared helper functions to assert encrypted partitions.

Note that the new functions have introduced some refactoring so that
they can be used in the general case.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
This is used from the initramfs of flasher devices to erase the disk
of secrets.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
Move the generic dmcrypt partition assertion logic. This is slightly
different as paritions do not contain meta-data that can identify the
encrypted partitions so dmsetup is used after the partition is mounted.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
# 0: Success
# 1: Failure
#
estimate_size_in_zram() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @alexgg, I'm wondering why what was a one liner, became this more complex function?
It's seems that this function measures the size that a file is going to take in zram by compressing the file manually and counting the blocks.
Was there a bug with the du command?
Why is it always zram compressed now? vs never compressed (du -cb)?
Is it that we were we were actually requiring the raw image size, when we actually needed the compressed one?
If not what was the problem and how was it solved?
I haven't yet really gotten into HUP and updating the OS and the associated complexity sorry if I'm lacking a bit of context.

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.

2 participants