Re: Multiple swap partitions listed wrong

Guest section DW (dwguest@win.tue.nl)
Mon, 17 May 1999 00:47:55 +0200 (MET DST)


From: "Robert Ekl" <roberte@tt.comm.mot.com>

Hi. I have Linux 2.2.8, and multiple swap partitions, 1 on each of 2 drives.
The swap partitions are different sizes, but appear to be the same size, as
indicated by swapon -s, and /proc/swaps, as shown below.

Please let me know if I have something wrong on my end (I've checked everything
I could think of), or if this is a bug.

My conjecture is user error.

[root@orange linux]# swapon -s
Filename Type Size Used Priority
/dev/hda5 partition 72256 2304 1
/dev/hdc2 partition 72256 2328 1
[root@orange rob]# fdisk /dev/hda
...
/dev/hda5 512 520 72261 82 Linux swap
...

[root@orange rob]# fdisk /dev/hdc
...
/dev/hdc2 78 94 68544 82 Linux swap
...

A swap partition has a header that tells the kernel how large it is,
and which bad blocks should be avoided.
This header is written by the utility mkswap.
If you do not give a size argument to mkswap it will use the full
partition (unless that is larger than allowed by kernel and/or
swap partition type, see mkswap(8)).
If you do give a size argument to mkswap (as it appears you have done)
then you can create swap areas of a size unrelated to that of the
file or partition containing the area.
Here it looks like you have one swap area that fits in its partition
and one that does not. If it really is used entirely, then you will
have corrupted your disk.

[Another way to get into this situation is to use mkswap, and
later shrink the partition using fdisk or so.
I have added a warning to mkswap in util-linux-2.9s (not released yet).
Will send Linus a patch for the swapon system call to protect
innocent users.]

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/