Red Hat Bugzilla – Bug 154405
mkswap should clear key parts of the block device
Last modified: 2013-03-05 22:43:04 EST
Description of problem:
The first 512 bytes of a block device formatted with mkswap are not cleared;
this means that filesystems probers may errornously detect a swap partition as a
vfat partition, mount it and then data corruption may happen.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Kay Sievers <email@example.com> made a test program that creates a loop
device and formats, cross-formats and probes it with volume_id if the fs is
recognized. For now only: swap, fat, ext2, ext3 are cross-tested and it finds
only one error.
1. Download http://people.redhat.com/davidz/vid-044.tar.gz
2. Unpack archive
4. as root run ./fs-label-cross-test.pl from with the vid directory of the archive
mkswap should clear parts of the block device where other OS'es expects to find
file system signatures. For most practical situations this is clearing at least
the first 2048 bytes.
BTW, there's libblkid (from e2fsprogs package) that does same work as the "vid"
code. The best solution will be use same code in all our packages rather than
duplicate funcionality. The libblkid is really good designed and doesn't have a
problem with swap detection :-)
That's feature that mkswap doesn't touch the first block of swap area.
The new style header does not touch the first block, so may be preferable, in
case you have a boot loader or disk label there.