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

swapon: Do not overwrite Linux swap header #1084

Closed
wants to merge 1 commit into from

Conversation

ricardobranco777
Copy link
Contributor

@ricardobranco777 ricardobranco777 commented Jan 26, 2024

The Linux swap partition uses a 4096-byte header that holds the label & UUID. You can see the structure here.

The problem is thus how to prevent FreeBSD from overwriting the header. It turns out there's a neat way to do just that with GEOM using the gnop system tool:

sudo gnop create -v -o 4096 /dev/vtbd1s1
sudo swapon /dev/vtbd1s1.nop
...
sudo swapoff /dev/vtbd1s1.nop
sudo gnop destroy /dev/vtbd1s1.nop

This PR modifies swapon to automate this process, which also works with /etc/fstab. This will benefit dual-boot installations and also live-CD's.

For automated detection of swap label by GEOM see this PR: #1083

Fixes: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221935

@ricardobranco777 ricardobranco777 changed the title umount: Do not overwrite Linux swap header swapon: Do not overwrite Linux swap header Jan 26, 2024
@ricardobranco777 ricardobranco777 force-pushed the swapon_linux branch 3 times, most recently from 20564a5 to 7f4cd01 Compare January 26, 2024 17:45
@bsdjhb
Copy link
Member

bsdjhb commented Feb 9, 2024

This seems sensible to me in light of the earlier discussion in #1083.

@bsdimp
Copy link
Member

bsdimp commented Apr 23, 2024

landed. Thanks! this one looks to be uncontested.

@bsdimp bsdimp closed this Apr 23, 2024
@bsdimp bsdimp added merged and removed ready labels Apr 23, 2024
freebsd-git pushed a commit that referenced this pull request Apr 23, 2024
Reviewed by: imp, jhb
Pull Request: #1084
@bsdimp bsdimp removed the merged label Apr 24, 2024
@bsdimp
Copy link
Member

bsdimp commented Apr 24, 2024

OK, I saw John's review but didn't read #1083 closely enough... I've backed this out in -current and will leave this closed. Pull requests aren't the place to hash out disagreements like this.

@ricardobranco777
Copy link
Contributor Author

ricardobranco777 commented Apr 24, 2024

OK, I saw John's review but didn't read #1083 closely enough... I've backed this out in -current and will leave this closed. Pull requests aren't the place to hash out disagreements like this.

Do you know what was the failure in armv7?

Also, this PR is independent of the other.

@bsdimp
Copy link
Member

bsdimp commented Apr 24, 2024

Do you know what was the failure in armv7?

Alignment requirement increased by cast.

The feedback was that it would be better if this were opt in rather than automatic... I'm happy to revisit.

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