NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/57921: swapon: Do not overwrite Linux swap header



>Number:         57921
>Category:       bin
>Synopsis:       swapon: Do not overwrite Linux swap header
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 10 20:10:00 +0000 2024
>Originator:     Ricardo Branco
>Release:        NetBSD 10.0_RC3
>Organization:
>Environment:
>Description:
The Linux swap partition uses a 4096-byte header that holds the label & UUID. You can see the structure here:
https://github.com/util-linux/util-linux/blob/master/include/swapheader.h

The problem is thus how to prevent NetBSD from overwriting the header. It turns out it can be done with wedge disks.

Doing it in the command line is not straight-forward as in FreeBSD, but it can be done like this:

# Calculate the offset and size of the swap partition and add/substract 8
# (which means 8 512-bytes blocks) from offset and size to dkctl.
sudo dkctl wd1 addwedge mylinuxswap 2056 2095096 swap 
sudo swapon /dev/dk2
swapctl -l
sudo swapctl -d /dev/dk2
sudo dkctl wd1 delwedge dk2
>How-To-Repeat:

>Fix:
I created a patch so it can be done like this:

sudo swapon /dev/wd1e
sudo swapctl -d /dev/sk2

https://github.com/NetBSD/src/pull/33



Home | Main Index | Thread Index | Old Index