systemd is activating swap twice, through both fstab and gpt generators

Bug #1399595 reported by Tom H
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemd (Debian)
Fix Released
Unknown
systemd (Ubuntu)
Fix Released
Medium
Martin Pitt

Bug Description

systemd is activating swap twice, via its sda name and its uuid.

It looks like it's because two swap units are being generated.

# journalctl | grep swap | grep -v unit_create_cgroups
Dec 05 04:30:40 yoga.lenovo systemd[1]: Activating swap Swap Partition...
Dec 05 04:30:40 yoga.lenovo systemd[1]: Activating swap /dev/disk/by-uuid/73d341f1-eedc-43fc-9e53-ba4194dae3fb...
Dec 05 04:30:40 yoga.lenovo swapon[396]: swapon: /dev/disk/by-uuid/73d341f1-eedc-43fc-9e53-ba4194dae3fb: swapon failed: Device or resource busy
Dec 05 04:30:40 yoga.lenovo systemd[1]: dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap swap process exited, code=exited status=255
Dec 05 04:30:40 yoga.lenovo systemd[1]: Failed to activate swap /dev/disk/by-uuid/73d341f1-eedc-43fc-9e53-ba4194dae3fb.
Dec 05 04:30:40 yoga.lenovo systemd[1]: Unit dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap entered failed state.
Dec 05 04:30:40 yoga.lenovo systemd[1]: Activated swap Swap Partition.
Dec 05 04:30:40 yoga.lenovo kernel: Adding 8298492k swap on /dev/sda3. Priority:-1 extents:1 across:8298492k SSFS

# systemctl status dev-sda3.swap
● dev-sda3.swap - Swap Partition
   Loaded: loaded (/run/systemd/generator.late/dev-sda3.swap)
   Active: active since Fri 2014-12-05 04:30:40 EST; 27min ago
     What: /dev/sda3
     Docs: man:systemd-gpt-auto-generator(8)
  Process: 395 ExecActivate=/sbin/swapon /dev/sda3 (code=exited, status=0/SUCCESS)

Dec 05 04:30:40 yoga.lenovo systemd[1]: Activating swap Swap Partition...
Dec 05 04:30:40 yoga.lenovo systemd[1]: Activated swap Swap Partition.

# systemctl status dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
● dev-disk-byx2duuid-73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb.swap - /dev/disk/byx2duuid/73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb
   Loaded: loaded
   Active: inactive (dead)
     What: /dev/disk/byx2duuid/73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb

# swapon -s
Filename Type Size Used Priority
/dev/sda3 partition 8298492 0 -1

# blkid /dev/sda3
/dev/sda3: UUID="73d341f1-eedc-43fc-9e53-ba4194dae3fb" TYPE="swap" PARTUUID="63a48c8a-8c88-482c-9577-50060d5afcb0"

# find /run -name "*73d341f1*"
/run/systemd/generator/swap.target.wants/dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
/run/systemd/generator/dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
/run/udev/links/\x2fdisk\x2fby-uuid\x2f73d341f1-eedc-43fc-9e53-ba4194dae3fb

# find /run -name "*sda3*"
/run/systemd/generator.late/swap.target.wants/dev-sda3.swap
/run/systemd/generator.late/dev-sda3.swap

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: systemd 217-3ubuntu1
ProcVersionSignature: Ubuntu 3.16.0-25.33-generic 3.16.7
Uname: Linux 3.16.0-25-generic x86_64
ApportVersion: 2.14.7-0ubuntu10
Architecture: amd64
CurrentDmesg: Error: command ['sh', '-c', 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'] failed with exit code 1: comm: /var/log/dmesg: No such file or directory
Date: Fri Dec 5 04:51:30 2014
MachineType: LENOVO 20266
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-3.16.0-25-generic root=UUID=b51ee688-137c-47ec-9635-b69434b4e1f8 ro init=/lib/systemd/systemd ipv6.disable_ipv6=1
SourcePackage: systemd
UdevLog: Error: [Errno 2] No such file or directory: '/var/log/udev'
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 03/25/2014
dmi.bios.vendor: LENOVO
dmi.bios.version: 76CN35WW
dmi.board.asset.tag: No Asset Tag
dmi.board.name: Yoga2
dmi.board.vendor: LENOVO
dmi.board.version: 31900058STD
dmi.chassis.asset.tag: No Asset Tag
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Lenovo Yoga 2 Pro
dmi.modalias: dmi:bvnLENOVO:bvr76CN35WW:bd03/25/2014:svnLENOVO:pn20266:pvrLenovoYoga2Pro:rvnLENOVO:rnYoga2:rvr31900058STD:cvnLENOVO:ct10:cvrLenovoYoga2Pro:
dmi.product.name: 20266
dmi.product.version: Lenovo Yoga 2 Pro
dmi.sys.vendor: LENOVO
mtime.conffile..etc.systemd.journald.conf: 2014-10-17T14:43:13.493155

Revision history for this message
Tom H (tomh0665) wrote :
Revision history for this message
Tom H (tomh0665) wrote :

(I can't find the option to tag this report with "systemd-boot". Is this a question of Launchpad permissions or am I too stupid to find the right thing to click?)

I saw that "/lib/systemd/system-generators/" has systemd-fstab-generator and systemd-gpt-auto-generator so I disabled swap in my fstab:

# grep swap /etc/fstab
#UUID=73d341f1-eedc-43fc-9e53-ba4194dae3fb none swap sw 0 0

And swap's now activated once:

# journalctl | grep swap | grep -v unit_create_cgroups
Dec 06 04:21:00 yoga.lenovo systemd[1]: Activating swap Swap Partition...
Dec 06 04:21:00 yoga.lenovo kernel: Adding 8298492k swap on /dev/sda3. Priority:-1 extents:1 across:8298492k SSFS
Dec 06 04:21:00 yoga.lenovo systemd[1]: Activated swap Swap Partition.

# swapon -s
Filename Type Size Used Priority
/dev/sda3 partition 8298492 0 -1

# find /run -name "*73d341f1*"
/run/udev/links/\x2fdisk\x2fby-uuid\x2f73d341f1-eedc-43fc-9e53-ba4194dae3fb

# find /run -name "*sda3*"
/run/systemd/generator.late/swap.target.wants/dev-sda3.swap
/run/systemd/generator.late/dev-sda3.swap

Revision history for this message
Martin Pitt (pitti) wrote :

> I can't find the option to tag this report

"Tags:" right below the description, above the first comment.

tags: added: systemd-boot
Revision history for this message
Martin Pitt (pitti) wrote :

This doesn't happen on my system, but this could be a bad interaction between the GPT and the fstab generator. Can you please run the following:

mkdir /tmp/fstab; /lib/systemd/system-generators/systemd-fstab-generator /tmp/fstab x x
mkdir /tmp/gpt; sudo /lib/systemd/system-generators/systemd-gpt-auto-generator /tmp/gpt x x
tar xf /tmp/result.tar /tmp/fstab /tmp/gpt

and then attach /tmp/result.tar here?

Changed in systemd (Ubuntu):
status: New → Incomplete
Revision history for this message
Tom H (tomh0665) wrote :

Thanks.

The gpt generator failed:

$ sudo /lib/systemd/system-generators/systemd-gpt-auto-generator /tmp/gpt x x
Failed to create unit file x/dev-sda3.swap: No such file or directory

$ tar -tf /tmp/result.tar
tmp/fstab/
tmp/fstab/boot-efi.mount
tmp/fstab/dev-disk-by\\x2duuid-73d341f1\\x2deedc\\x2d43fc\\x2d9e53\\x2dba4194dae3fb.swap
tmp/fstab/local-fs.target.wants/
tmp/fstab/local-fs.target.wants/systemd-fsck-root.service
tmp/fstab/local-fs.target.requires/
tmp/fstab/local-fs.target.requires/boot-efi.mount
tmp/fstab/local-fs.target.requires/-.mount
tmp/fstab/swap.target.requires/
tmp/fstab/swap.target.requires/dev-disk-by\\x2duuid-73d341f1\\x2deedc\\x2d43fc\\x2d9e53\\x2dba4194dae3fb.swap
tmp/fstab/-.mount
tmp/gpt/

Revision history for this message
Martin Pitt (pitti) wrote :

Tom,

ah, sorry about that, I didn't know that the gpt generator also uses the "late" argument (it wasn't here, but then again it doesn't produce anything for me). But indeed it seems to produce a swap unit for you, which explains this bug. Can you please re-do this with

  mkdir /tmp/gpt; sudo /lib/systemd/system-generators/systemd-gpt-auto-generator /tmp/gpt /tmp/gpt /tmp/gpt

and tar up /tmp/gpt ?

Please also include your /etc/fstab for reference, or at least the line which mounts the swap partition.

Thanks!

Revision history for this message
Tom H (tomh0665) wrote :

Thanks again for looking into this.

systemd-gpt-auto-generator output attached.

$ cat /etc/fstab
# filesystem mountpoint type options dump pass
# sda1
UUID=6151-AFD6 /boot/efi vfat defaults 0 1
# sda2
UUID=b51ee688-137c-47ec-9635-b69434b4e1f8 / ext4 defaults 0 1
# sda3
UUID=73d341f1-eedc-43fc-9e53-ba4194dae3fb none swap sw 0 0

(Until your post yesterday, I've had sda3 commented out.)

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for the additional data, that helps a lot. I'll forward this to upstream now. I have an idea how to fix that, but I'd like to discuss it upstream first.

> (Until your post yesterday, I've had sda3 commented out.)

Was that only in response to that bug? It would be weird if that bug would still happen even if you have swap commented out in /etc/fstab -- that would mean the fstab generator wouldn't recognize comments or so. Can you confirm that this is not the case?

Thanks!

Changed in systemd (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Triaged
summary: - systemd is activating swap twice
+ systemd is activating swap twice, through both fstab and gpt generators
Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Tom H (tomh0665) wrote :

Yes. I commented out sda3 in order to suppress the errors. (Swap was mounted nonetheless.)

Changed in systemd (Debian):
status: Unknown → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Upstream has a proposed patch for this. I built a package for vivid with this, would you be able to test this? https://launchpad.net/~pitti/+archive/ubuntu/ppa

Thanks in advance!

Changed in systemd (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
Revision history for this message
Tom H (tomh0665) wrote :

Fixed:

# journalctl | grep swap
Jan 28 07:35:09 yoga.lenovo systemd[1]: Activating swap Swap Partition...
Jan 28 07:35:09 yoga.lenovo systemd[1]: Activating swap /dev/disk/by-uuid/73d341f1-eedc-43fc-9e53-ba4194dae3fb...
Jan 28 07:35:09 yoga.lenovo kernel: Adding 8298492k swap on /dev/sda3. Priority:-1 extents:1 across:8298492k SSFS
Jan 28 07:35:10 yoga.lenovo systemd[1]: Activated swap Swap Partition.
Jan 28 07:35:10 yoga.lenovo systemd[1]: Activated swap /dev/disk/by-uuid/73d341f1-eedc-43fc-9e53-ba4194dae3fb.

# systemctl status dev-sda3.swap
● dev-sda3.swap - Swap Partition
   Loaded: loaded (/run/systemd/generator.late/dev-sda3.swap)
   Active: active since Wed 2015-01-28 07:35:09 EST; 44min ago
     What: /dev/sda3
     Docs: man:systemd-gpt-auto-generator(8)
  Process: 372 ExecActivate=/sbin/swapon /dev/sda3 (code=exited, status=0/SUCCESS)

Jan 28 07:35:10 yoga.lenovo systemd[1]: Activated swap Swap Partition.

# systemctl status dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
● dev-disk-byx2duuid-73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb.swap - /dev/disk/byx2duuid/73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb
   Loaded: loaded
   Active: inactive (dead)
     What: /dev/disk/byx2duuid/73d341f1x2deedcx2d43fcx2d9e53x2dba4194dae3fb

Many thanks.

Revision history for this message
Martin Pitt (pitti) wrote :

Fixed upstream:

  http://cgit.freedesktop.org/systemd/systemd/commit/?id=7663df377016
  http://cgit.freedesktop.org/systemd/systemd/commit/?id=cdda4aa8d
  http://cgit.freedesktop.org/systemd/systemd/commit/?id=37cf8fee4

I got confirmation in the Debian bug that this works, but confirmation from you would be highly appreciated. The second commit was done just now and fixes a regression that caused the boot to get stuck on systems which mount swap just from fstab; I'll update the PPA accordingly.

Changed in systemd (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

Ah, so you just did, thanks! The remaining worry is that in your case the gpt generator "won", but we want to prefer the fstab one.

Revision history for this message
Tom H (tomh0665) wrote :

You're welcome.

I wasn't sure whether I had the latest or whether I had a previous version but you didn't bump up the package version so I ran 'apt-get --reinstall install udev systemd libudev1 libsystemd0 libpam-systemd libgudev-1.0-0 gir1.2-gudev-1.0'.

Please let me know if you'd some more info to look into why the gpt generator's winning.

The fstab generator creates a "swap.target.requires" entry and the gpt generator creates a "swap.target.wants" entry so I would've expected fstab to trump gpt.

# find /run -name "*73d341f1*"
/run/systemd/generator/swap.target.requires/dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
/run/systemd/generator/dev-disk-by\x2duuid-73d341f1\x2deedc\x2d43fc\x2d9e53\x2dba4194dae3fb.swap
/run/udev/links/\x2fdisk\x2fby-uuid\x2f73d341f1-eedc-43fc-9e53-ba4194dae3fb

# find /run -name "*sda3*"
/run/systemd/generator.late/swap.target.wants/dev-sda3.swap
/run/systemd/generator.late/dev-sda3.swap

[You didn't generate libsystemd-daemon0, libsystemd-journal0, libsystemd-login0 packages. Are they still needed?]

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 1399595] Re: systemd is activating swap twice, through both fstab and gpt generators

Hey Tom,

Tom H [2015-01-28 14:55 -0000]:
> I wasn't sure whether I had the latest or whether I had a previous
> version but you didn't bump up the package version so I ran 'apt-get
> --reinstall install udev systemd libudev1 libsystemd0 libpam-systemd
> libgudev-1.0-0 gir1.2-gudev-1.0'.

Actually I did, you should have 218-6ubuntu1pitti1. With
218-6ubuntu1 from vivid you should still get the error.

> Please let me know if you'd some more info to look into why the gpt
> generator's winning.

No, it's quite clear why that happens (it's a simple race condition).
Lennart says it doesn't matter which wins, but I'm still a bit
doubtful about that due to not respecting mout options in gpt. But
either way that's already true right now, so this patch is already an
improvement.

> [You didn't generate libsystemd-daemon0, libsystemd-journal0, libsystemd-login0 packages. Are they still needed?]

No, they are obsolete and already dropped in vivid, too.

Thanks,

Martin

Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (3.8 KiB)

This bug was fixed in the package systemd - 218-7ubuntu1

---------------
systemd (218-7ubuntu1) vivid; urgency=medium

  * Merge with Debian unstable. Remaining Ubuntu changes:
    - Hack to support system-image read-only /etc, and modify files in
      /etc/writable/ instead.
    - Keep our much simpler udev maintainer scripts (all platforms must
      support udev, no debconf).
    - initramfs init-top: Drop $ROOTDELAY, we do that in a more sensible way
      with wait-for-root. Will get applicable to Debian once Debian gets
      wait-for-root in initramfs-tools.
    - initramfs init-bottom: If LVM is installed, settle udev,
      otherwise we get missing LV symlinks. Workaround for LP #1185394.
    - Add debian/udev.lvm2.init: Dummy SysV init script to satisfy insserv
      dependencies to "lvm2" which is handled with udev rules in Ubuntu.
    - Provide shutdown fallback for upstart. (LP: #1370329)
    - debian/extra/ifup@.service: Additionally run for "auto" class. We don't
      really support "allow-hotplug" in Ubuntu at the moment, so we need to
      deal with "auto" devices appearing after "/etc/init.d/networking start"
      already ran. (LP: #1374521)
    - ifup@.service: Drop dependency on networking.service (i. e.
      /etc/init.d/networking), and merely ensure that /run/network exists.
      This avoids unnecessary dependencies/waiting during boot and dependency
      cycles if hooks wait for other interfaces to come up (like ifenslave
      with bonding interfaces). (LP: #1414544)
    - Add Get-RTC-is-in-local-time-setting-from-etc-default-rc.patch: In
      Ubuntu we currently keep the setting whether the RTC is in local or UTC
      time in /etc/default/rcS "UTC=yes|no", instead of /etc/adjtime.
      (LP: #1377258)
    - Put session scopes into all cgroup controllers. This makes unprivileged
      user LXC containers work under systemd. (LP: #1346734)
    - Lower Breaks: to plymouth version which has the udev inotify fix in
      Ubuntu.
    - Lower libappamor1 dep to the Ubuntu version where it moved to /lib.
    - Make failure of boot-and-services NSpawn.test_boot non-fatal for now.
      This currently fails when being triggered by Jenkins, but is totally
      unreproducible when running this manually on the exact same machine.

    Upgrade fixes, keep until 16.04 LTS release:
    - systemd Conflicts/Replaces/Provides systemd-services.
    - Remove obsolete systemd-logind upstart job.
    - Clean up obsolete /etc/udev/rules.d/README.

systemd (218-7) experimental; urgency=medium

  [ Martin Pitt ]
  * Don't attempt to mount the same swap partition twice through different
    device node aliases. (Closes: #772182, LP: #1399595)
  * logind: handle closing sessions over daemon restarts. (Closes: #759515,
    LP: #1415104)
  * logind: Fix sd_eviocrevoke ioctl call, to make forced input device release
    after log out actually work.
  * debian/rules: Drop obsolete --disable-multi-seat-x and
    --with-firmware-path configure options.
  * debian/udev.README.Debian: Trim the parts which are obsolete, wrong, or
    described in manpages. Only keep the Debian specific bits.
    (Part of #776546)
  * Actually install udev's RE...

Read more...

Changed in systemd (Ubuntu):
status: Fix Committed → Fix Released
Changed in systemd (Debian):
status: Confirmed → Fix Released
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.