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

fix: ensure passive.img is sparse after install (backport #960) #970

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Feb 12, 2025

Problem:
If passive.img is not a sparse file, it can result in too much disk space being used on the COS_STATE partition which causes problems for upgrades (see related issues).

Solution:
After installation, run fallocate --dig-holes to make passive.img sparse if it's not already.

Related Issue:
harvester/harvester#7457
harvester/harvester#7518

Test plan:

  • Install Harvester
  • Post-install, check disk usage of active.img and passive.img. They should be the same (about 1.7G):
    # du -sh /run/initramfs/cos-state/cOS/*
    1.7G	/run/initramfs/cos-state/cOS/active.img
    1.7G	/run/initramfs/cos-state/cOS/passive.img
    
  • The fact that passive.img shrunk from 3.1G to 1.7G should be recorded in the install log, e.g.:
    # grep passive /oem/install/console.log | tail -n 3
    time="2025-02-11T11:59:38Z" level=info msg="[stdout]: Ensuring passive.img is sparse..."
    time="2025-02-11T11:59:38Z" level=info msg="[stdout]:   was: 3.1G\t/tmp/mnt/STATE/cOS/passive.img"
    time="2025-02-11T11:59:38Z" level=info msg="[stdout]:   now: 1.7G\t/tmp/mnt/STATE/cOS/passive.img"
    ```<hr>This is an automatic backport of pull request #960 done by [Mergify](https://mergify.com).
    

Related issue: harvester/harvester#7457
Related issue: harvester/harvester#7518

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 05152ff)
sparsify_passive_img()
{
# See https://github.com/harvester/harvester/issues/7518
echo "Ensuring passive.img is sparse..."
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this interesting fix, just a question:

To be more secure, should we test if ${STATEDIR}/cOS/passive.img) is there first? There is no passive.img definition on Harvester code, elemental has following information

https://github.com/rancher/elemental-toolkit/blob/50f6b4ec667767ef4e7c1036866a2d0180221044/pkg/constants/constants.go#L195

https://github.com/rancher/elemental-toolkit/blob/50f6b4ec667767ef4e7c1036866a2d0180221044/docs/content/en/docs/Getting%20started/upgrading.md?plain=1#L68

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not overly concerned about that here -- we run elemental install a few lines above sparsify_passive_img, and elemental install is what creates passive.img in the first place, so it will always be present at this point.

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.

4 participants