mkswap does not wipe filesystem signatures

Bug #1047666 reported by Richard Hansen
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Fix Released
util-linux (Ubuntu)

Bug Description

The mkswap utility does not always clean up signatures left by other filesystems. This results in multiple signatures reported by 'wipefs -n /path/to/swap/device' and prevents mountall from activating the swap device on boot (see bug #1047659).

This bug has apparently been fixed in upstream util-linux 2.21 (which I have not tested). From <>:

       - wipe all old signatures [Karel Zak]

The following script reproduces the problem using a loopback device:


log() { printf %s\\n "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
try() { "$@" || fatal "'$*' failed"; }

# this script's name
myname=$(try basename "$0") || exit 1
# temporary file for storing the swap partition
# which loopback device to use for ${FS}

command -v mkfs.ufs >/dev/null \
    || fatal "mkfs.ufs not found; please install the ufsutils package"

log "creating ${LOOP} using a temporary 128MiB file..."
try dd if=/dev/zero of="${FS}" bs=1M count=128 2>/dev/null
try losetup "${LOOP}" "${FS}"
log "formatting ${LOOP} as UFS2..."
try mkfs.ufs "${LOOP}" >/dev/null
log "formatting ${LOOP} as swap..."
try mkswap "${LOOP}" >/dev/null
log "running 'wipefs -n ${LOOP}'..."
try wipefs -n "${LOOP}"
log "running 'blkid -p ${LOOP}'..."
blkid -p "${LOOP}"
log "cleaning up..."
try losetup -d "${LOOP}"
try rm "${FS}"

Note how wipefs reports multiple filesystem signatures:

offset type
0x1055c ufs [filesystem]

0xff6 swap [other]
                     UUID: 5ac922dc-3bc5-463f-a2e8-a692ee5c293a

Also note how blkid does not list the UUID of the swap device. It prints this error message instead:

    ambivalent result (probably more filesystems on the device, use wipefs(8) to see more details)

$ lsb_release -rd
Description: Ubuntu 12.04.1 LTS
Release: 12.04
$ apt-cache policy util-linux
  Installed: 2.20.1-1ubuntu3
  Candidate: 2.20.1-1ubuntu3
  Version table:
 *** 2.20.1-1ubuntu3 0
        500 precise/main amd64 Packages
        100 /var/lib/dpkg/status
$ apt-cache policy ufsutils
  Installed: 8.2-3
  Candidate: 8.2-3
  Version table:
 *** 8.2-3 0
        500 precise/universe amd64 Packages
        100 /var/lib/dpkg/status

Phillip Susi (psusi)
Changed in util-linux-ng:
status: New → Fix Released
Changed in util-linux (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (14.2 KiB)

This bug was fixed in the package util-linux - 2.25-8ubuntu1

util-linux (2.25-8ubuntu1) utopic; urgency=medium

  * Merge with Debian experimental.
    - This is now a non-ancient version. (LP: #1012081)
    - No longer uses /etc/ by default, but a file in /run/.
      (LP: #1244595)
    - mkswap wipes fs signatures (LP: #1047666)
    - Fix "reatime" manpage typo (LP: #1047666)
    - wipefs properly cleans up fs signatures (LP: #1059872)
    Remaining Ubuntu changes:
    - Regularly trim SSDs automatically (core-1311-ssd-trimming):
      + Add debian/fstrim-all: Script to detect which mounted partitions
        need/support trimming, and call fstrim(8) on all of them.
        Install into /usr/sbin/.
      + Add debian/fstrim-all.8: Manpage for the above.
      + Add debian/fstrim-all.cron: Trivial shell script to call fstrim-all,
        so that admins can easily adjust/disable it. Installed as
    - Upstart support:
      + Add hwclock{-save}.upstart, and install them in debian/rules.
      + Drop initscripts dependency.
      + Drop debian/hwclock.rules and hwclock.default.
    - Add mountall-options.patch, see patch header.
    - uuid-runtime.postinst: Due to the way the uuidd account is created, it
      will get a uid/gid allocation for userns use. This isn't needed and is a
      waste of uid/gid so always clear uuidd from subuid/subgid.
  * Drop /lib/init/fstab parsing fallback in mount. Patch does not apply at
    all any more, is specific to mountall (and thus should not be relied
    upon), and not very useful; all init systems, schroot, debootstrap etc.
    mount /sys, /proc/ and friends by themselves already.

util-linux (2.25-8) experimental; urgency=medium

  * Only install linux32/64 manpages on linux-any
  * Fix uuid-runtime.postinst to skip rmdir when not needed (Closes: #757432)
  * fdisk-udeb: use dh-exec to skip sfdisk install on sparc

util-linux (2.25-7) experimental; urgency=medium

  * Mangle installed files on sparc (sfdisk)
  * Fix sparc install mangling
  * Use --disable-mountpoint instead of rm
  * Use dh-exec (>= 0.13)
  * Install mips,ppc,s390 setarch symlinks and manpages

util-linux (2.25-6) experimental; urgency=medium

  The "Jonno was here" release.

  [ Jon Severinsson ]
  * Drop changelog file from the ancient mount source package.

  [ Andreas Henriksson ]
  * util-linux: Drop all (obsolete) Replaces/Conflicts

  [ Jon Severinsson ]
  * Add Replaces/Breaks bash-completion (<< 1:2.1-3).
  * Multiple cleanups in debian/control.
  * Minor cleanup of debian/rules.
  * Use filter, not findstring, for arch matching
  * Simplify linux-only install file handling
  * Use debian/*-udeb.install files for udeb packages.
  * Fix util-linux lintian override.

  [ Andreas Henriksson ]
  * Minor uuid-runtime.postinst cleanup
  * Add d/p/cfdisk-reenable-cursor-when-quitting.patch (Closes: #755991)

util-linux (2.25-5) experimental; urgency=medium

  The "big maintainer-script cleanup" release

  * Drop debian/uuid-runtime.prerm (and related lintian override)
    - dh_installinit will automatically start and stop services as needed.
  * Drop debian/libuuid1.postin...

Changed in util-linux (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers