mountall silently fails to activate swap if device contains multiple filesystem signatures

Bug #1047659 reported by Richard Hansen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mountall (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

If the swap device (LVM logical volume on an encrypted physical volume in my case) has multiple filesystem signatures (as reported by 'wipefs -n /path/to/swap/device'), mountall will fail to activate the swap even though the swap device is listed in /etc/fstab. Manually running 'swapon -a' does work, however.

Also, blkid does not list the swap device in its output even though lsblk does. I'm assuming this is related to the mountall problem.

The following script replecates the situation by creating a looback block device with multiple filesystem signatures:

-------------
#!/bin/sh

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
FS=${myname}.tmpfs
# which loopback device to use for ${FS}
LOOP=/dev/loop0

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 mountall
mountall:
  Installed: 2.36
  Candidate: 2.36
  Version table:
 *** 2.36 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status
$ apt-cache policy util-linux
util-linux:
  Installed: 2.20.1-1ubuntu3
  Candidate: 2.20.1-1ubuntu3
  Version table:
 *** 2.20.1-1ubuntu3 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status
$ apt-cache policy ufsutils
ufsutils:
  Installed: 8.2-3
  Candidate: 8.2-3
  Version table:
 *** 8.2-3 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Richard Hansen (rhansen) wrote :

It looks like mkswap from util-linux 2.21 (which sadly didn't make it into 12.10 quantal) deletes all signatures, which should prevent the multiple signature problem from appearing in the first place.

However, it is still probably worthwhile for mountall to be able to handle this case, perhaps by printing an error message that the user will see.

Revision history for this message
Richard Hansen (rhansen) wrote :

I filed bug #1047666 for mkswap not clearing other filesystem signatures

Revision history for this message
Steve Langasek (vorlon) wrote :

Please show the /etc/fstab entry corresponding to this swap device.

Changed in mountall (Ubuntu):
status: New → Incomplete
Revision history for this message
Richard Hansen (rhansen) wrote :

My /etc/fstab:

proc /proc proc nodev,noexec,nosuid 0 0
/dev/mapper/datagram-root / ext4 errors=remount-ro 0 1
UUID=81b66788-b7b3-4048-bc32-374503feb780 /boot ext2 defaults 0 2
/dev/mapper/datagram-swap_1 none swap sw 0 0

Changed in mountall (Ubuntu):
status: Incomplete → New
Revision history for this message
Steve Langasek (vorlon) wrote :

Thanks. This confirms that it's not an issue with trying to reference a dm device by UUID.

You mention that 'swapon -a' works. Does 'swapon /dev/mapper/datagram-swap_1' also work?

I ask, because there really isn't any blkid handling in mountall, so the presence of multiple signatures shouldn't bother mountall at all.

Could you also try editing /etc/init/mountall.conf to replace the 'exec mountall' line with:

  exec mountall --daemon --verbose $force_fsck $fsck_fix > /run/mountall.log 2>&1

reboot, and attach the resulting /run/mountall.log file?

Changed in mountall (Ubuntu):
status: New → Incomplete
Revision history for this message
Richard Hansen (rhansen) wrote :

> Does 'swapon /dev/mapper/datagram-swap_1' also work?

Yes.

I have attached the verbose mountall log.

Changed in mountall (Ubuntu):
status: Incomplete → New
Revision history for this message
Richard Hansen (rhansen) wrote :

For confirmation, this is how I changed /etc/init/mountall.conf:

diff --git a/etc/init/mountall.conf b/etc/init/mountall.conf
index 95d9719..1b83bad 100644
--- a/etc/init/mountall.conf
+++ b/etc/init/mountall.conf
@@ -34,7 +34,7 @@ script
         export LANG LANGUAGE LC_MESSAGES LC_ALL
     fi

- exec mountall --daemon $force_fsck $fsck_fix
+ exec mountall --daemon --verbose $force_fsck $fsck_fix >/run/mountall.log 2>&1
 end script

 post-stop script

Revision history for this message
Steve Langasek (vorlon) wrote :

The log shows that mountall never sees the swap device become available. Can you also attach /var/log/udev?

Revision history for this message
Richard Hansen (rhansen) wrote :

/var/log/udev attached

Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 1047659] Re: mountall fails to activate swap if device contains multiple filesystem signatures

On Sat, Sep 08, 2012 at 09:46:59PM -0000, a7x wrote:
> /var/log/udev attached

Thanks. So this is an interaction with this section of the mountall
code:

        /* devmapper, md, loop and ram devices must be "ready" before
         * we'll try them - as must any device we found without udev.
         */
        if ((! action)
            || (! strncmp (kernel, "dm-", 3))
            || (! strncmp (kernel, "md", 2))
            || (! strncmp (kernel, "loop", 4))
            || (! strncmp (kernel, "ram", 3))) {
                if ((! usage) && (! type) && (! uuid) && (! label)) {
                        if (action)
                                nih_debug ("ignored %s (not yet ready?)", devname);
                        return;
                }
        }

Combined with the fact that blkid can't tell what the device is, this
results in ID_FS_* variables being unset by udev and mountall refusing to
act on the device because it can't tell that the device is ready.

I'm not sure it's at all possible for us to address this in mountall safely
(i.e., without breaking other cases). And since blkid knows the disk usage
is ambiguous, blkid doesn't seem to be doing anything wrong here either.
The only actionable bug here seems to be the mkswap one.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

Revision history for this message
Richard Hansen (rhansen) wrote : Re: mountall fails to activate swap if device contains multiple filesystem signatures

> I'm not sure it's at all possible for us to address this in mountall safely
> (i.e., without breaking other cases). And since blkid knows the disk usage
> is ambiguous, blkid doesn't seem to be doing anything wrong here either.

Agreed -- altering mountall to try to work around mkswap's bug does seem risky.

> The only actionable bug here seems to be the mkswap one.

What about altering mountall to log the failure to activate swap partition? Then users would have something they could google.

summary: - mountall fails to activate swap if device contains multiple filesystem
- signatures
+ mountall silently fails to activate swap if device contains multiple
+ filesystem signatures
Anders (eddiedog988)
Changed in mountall (Ubuntu):
status: New → Confirmed
Ken Sharp (kennybobs)
tags: added: precise quantal
Mathew Hodson (mhodson)
Changed in mountall (Ubuntu):
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.