Red Hat Bugzilla – Bug 291391
confusing label for swapspace
Last modified: 2008-04-22 11:15:45 EDT
Description of problem: A label such as "SWAP-sdc5" is applied to a
newly-formatted swap partition. The last portion "sdc5" is based on anaconda's
enumeration of drives, which is often NOT the same as the enumeration used by
the installed system. For instance, in the running system the partiion can be
sda5. This causes needless confusion.
Version-Release number of selected component (if applicable):
How reproducible: always
Steps to Reproduce:
1. Custom manual disk layout install on 3-drive system: 1 PATA, 2 SATA drives.
The PATA drive and the last SATA drive are pre-partitioned, with partion 5 on
each drive having type 82 (Linux swap) but with no "SWAPSPACE2" magic number.
2. Select partition 5 on the PATA drive (pre-partitioned as type 82, but with no
"SWAPSPACE2" marking), and ask manual disk druid to format it as swap. Anaconda
calls this /dev/sdc5.
Actual results: Label "SWAP-sdc5" is written to partition 5 of the PATA drive,
and "LABEL=SWAP-sdc5" is inserted in /etc/fstab designating swap space.
"/dev/sda5", which is anaconda's name for the [unformatted] partition 5 on the
last SATA drive, is also written to /etc/fstab as swap space. When booted into
the installed system, the drives are enumerated backwards compared to anaconda.
So the unformatted partition 5 on the last SATA drive is now /dev/sdc5, while
the label "SWAP-sdc5" appears on the partition which is now called /dev/sda5.
The system uses only /dev/sda5, the 5th partition on the PATA drive, as swap space.
Expected results: Label for swapspace should not depend on enumeration order.
Instead, use the SerialNo from "hdparm -i /dev/sdX".
The serial number is going to be way too long. The label for swaps is limited
to 15 characters.
Take the rightmost 9 characters (non-blank) of the serial number. Pre-pend with
"SWAP-X" where X is the partition number [1-9a-f] of the drive. Then check for
uniqueness among the other such numbers on drives that are currently visible.
Adjust the 'X' as necessary [move to a different set of 15 characters.] to make
it unique among the labels that are currently visible.
Serial numbers that I observe range from 10 characters for Seagate and Maxtor
drives to 16 characters for Hitachi drives.
We should be using UUIDs for swap space on regular partitions now, so while they
are no longer very readable they should not be confusing.