The Linux swap partition uses a 4096-byte header that holds the label & UUID. You can see the structure here. FreeBSD doesn't use a header at all.
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(8) tool:
It's as simple as running these commands:
But it would be even better if we use a label instead of a device path, like /dev/swaplinux/LABEL
I created a PR to do add Linux swap label support to GEOM label:
GEOM is truly a great piece of software.
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(8) tool:
It's as simple as running these commands:
Bash:
sudo gnop create -v -o 4096 /dev/vtbd1s1
sudo swapon /dev/vtbd1s1.nop
...
sudo swapoff /dev/vtbd1s1.nop
sudo gnop destroy /dev/vtbd1s1.nop
But it would be even better if we use a label instead of a device path, like /dev/swaplinux/LABEL
I created a PR to do add Linux swap label support to GEOM label:
glabel: Add support for detecting Linux swap by ricardobranco777 · Pull Request #1083 · freebsd/freebsd-src
This will benefit dual-boot installations and also live-CD's. How I tested it: Compile kernel without GEOM_LABEL cd /sys/modules/geom/geom_label make sudo make install Reboot Attach virtual disk t...
github.com
GEOM is truly a great piece of software.