Bug 721666

Summary: swapon and swapoff are not occurring (encrypted swap)
Product: [openSUSE] openSUSE 12.1 Reporter: Neil Rickert <nwr10cst-oslnx>
Component: BasesystemAssignee: Frederic Crozat <fcrozat>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: bruno, fcrozat, puzel
Version: Beta 1   
Target Milestone: ---   
Hardware: i686   
OS: SUSE Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Output from dmesg after rebooting with the requested options
tarball of generator (in /run/systemd) on dell laptop

Description Neil Rickert 2011-10-02 05:27:57 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20100101 Firefox/7.0

System is a Dell inspiron N5010.  I installed 12.1 Beta1 from the 32bit live KDE disk.

The swap partition is encrypted (dm-crypt, random key).

After booting, swap has not been mounted.  The crypto has been done, so that a simple "swapon -a" will mount swap.  It looks as if the initial swapon fails because it is too early (crypto not handled yet).  It fails to retry after the cryptsetup.

On shutdown, if I have manually mounted swap, there is a message that flashes by indicating a failure to shutdown the crypto.  It looks as if swapoff is not being run in time for the crypto shutdown.

Reproducible: Always

Steps to Reproduce:
1. After boot, run the "free" command.  It shows 0 swap unless I manually add swap.
2.
3.
Actual Results:  
Shows 0 swap

Expected Results:  
Should show several gig of swap available.
Comment 1 Bruno Friedmann 2011-10-03 09:15:09 UTC
See here too, with factory and systemd 
My layout is raid1 for /boot and raid0 for sda2 & sdb2
md1 (raid0) is encrypted on top of that I've LVM2 system
lvswap is never mounted 

systemctl status swap.service 
swap.service
          Loaded: masked (/dev/null)
          Active: inactive (dead)

starting a swapon -a just start the partition.
Without swap no hibernation is possible.
Comment 2 Frederic Crozat 2011-10-05 14:32:40 UTC
please attach /etc/fstab
Comment 3 Frederic Crozat 2011-10-05 14:32:59 UTC
and /etc/crypttab
Comment 4 Bruno Friedmann 2011-10-05 14:42:17 UTC
For me /etc/fstab
cat /etc/fstab 
/dev/vgsys/lvsuse    /                    ext4       data=writeback,acl,user_xattr,barrier=1,commit=60,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 1
UUID=f25ecb65-b690-4c17-8572-fb7a74a1f546  /boot                ext4       noatime,acl,user_xattr,barrier=1 1 2
/dev/vgsys/lvhome    /home                ext4       data=writeback,acl,user_xattr,barrier=1,commit=60,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2
/dev/vgsys/lvsrv     /srv                 ext4       data=writeback,acl,user_xattr,barrier=1,commit=30,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2
/dev/vgsys/lvswap    swap                 swap       defaults              0 0
/dev/sda2            /media/rescue-sda    vfat       noatime,user,noauto,iocharset=utf8,codepage=437,users,gid=users,umask=0002,utf8=true 0 0
/dev/sdb2            /media/rescue-sdb    vfat       noatime,user,noauto,iocharset=utf8,codepage=437,users,gid=users,umask=0002,utf8=true 0 0
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0

# Montage NFS ioda-net
yoda:/ioda/data      /ioda/data.nfs  nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
yoda:/ioda/home      /ioda/home      nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
yoda:/ioda/install   /ioda/install   nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
yoda:/ioda_saves     /ioda/saves     nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
yoda:/ioda/archives  /ioda/archives  nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
yoda:/srv/mirror     /ioda/mirror    nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0

#[2001:1620:f7c::1]:/ioda/data      /ioda/data.nfs  nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
#[2001:1620:f7c::1]:/ioda/home      /ioda/home      nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
#[2001:1620:f7c::1]:/ioda/install   /ioda/install   nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
#[2001:1620:f7c::1]:/ioda_saves     /ioda/saves     nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
#[2001:1620:f7c::1]:/ioda/archives  /ioda/archives  nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0
#[2001:1620:f7c::1]:/srv/mirror     /ioda/mirror    nfs             noauto,defaults,soft,rw,posix,noatime,nodiratime,mountproto=tcp6 0 0


# Point de remontage utilisé pour l'archivage automatique
#//dumbo/archives     /media/archives     cifs    noauto,rw,soft,credentials=/root/.cifs_creds_sigeom
#//dumbo/data         /sigeom/data        cifs    noauto,rw,soft,credentials=/root/.cifs_creds_sigeom
#LABEL=sigeom  /sigeom ext4     noauto,rw,user,noexec,nodev,suid,acl,user_xattr,noatime,nodiratime,comit=15,barrier=0
LABEL=lvsigeom          /sigeom btrfs noauto,rw,users,noexec,nodev,suid,noatime,nodiratime 0 0
LABEL=lvobsbuild        /media/obsbuild ext4 noauto,rw,users,noexec,nodev,suid,noatime,nodiratime,acl,user_xattr,barrier=0,commit=10 0 0 
LABEL=lvobsswap  swap swap noauto,default 0 0 

# Testing btrfs
#/dev/vgbackup/lvbtrfs  /media/lvbtrfs btrfs noauto,rw,users 0 0
#/dev/vgbackup/lvscratch  /media/lvscratch btrfs noauto,rw,users 0 0

/dev/vgbackup/lvbackup   /media/lvbackup      ext4    noauto,rw,data=writeback,acl,user_xattr,noatime,nodiratime,commit=30,barrier=1,noauto_da_alloc,journal_async_commit,journal_checksum,journal_ioprio=2 0 0 

# iso sysrescuecd
#/home/bruno/src_tmp/systemrescuecd-x86-2.3.1.iso /media/iso iso9660    noauto,ro,loop  0 0


et /etc/crypttab

cat /etc/crypttab 
# cr_md1          /dev/disk/by-id/md-uuid-3efb3f60:bfb4210f:8ca3dc5d:f474fc7c none       none
Comment 5 Bruno Friedmann 2011-10-05 14:43:23 UTC
swapon -s
Filename                                Type            Size    Used    Priority

swapon -a
swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/vgsys-lvswap                partition       19296252        0       -1
Comment 6 Frederic Crozat 2011-10-05 14:54:28 UTC
please give output of "systemctl show swap.target"

Does it work if you change in /etc/fstab
/dev/vgsys/lvswap by 
dev/mapper/vgsys-lvswap 

?
Comment 7 Bruno Friedmann 2011-10-05 16:02:01 UTC
Id=swap.target
Names=swap.target
Wants=dev-vgsys-lvswap.swap
WantedBy=sysinit.target
Conflicts=shutdown.target
Before=sysinit.target
After=dev-disk-by\x2dlabel-lvobsswap.swap dev-vgsys-lvswap.swap
Description=Swap
LoadState=loaded
ActiveState=active
SubState=active
FragmentPath=/lib/systemd/system/swap.target
UnitFileState=static
InactiveExitTimestamp=Wed, 05 Oct 2011 09:51:12 +0200
InactiveExitTimestampMonotonic=33079047
ActiveEnterTimestamp=Wed, 05 Oct 2011 09:51:12 +0200
ActiveEnterTimestampMonotonic=33079047
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureIsolate=no
IgnoreOnIsolate=no
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
ConditionTimestamp=Wed, 05 Oct 2011 09:51:12 +0200
ConditionTimestampMonotonic=33079046
ConditionResult=yes
lines 1-36/36 (END)
Comment 8 Bruno Friedmann 2011-10-05 16:05:08 UTC
lvobsswap is a small swap use with the osc build --local-package and the kvm launch for building package ...

It should be excluded as I've precise noauto in /etc/fstab
Comment 9 Bruno Friedmann 2011-10-05 16:09:04 UTC
I've modified my fstab to /dev/mapper/vgsys-lvswap and commented the LABEL=lvswap
tonight after a cold reboot I will be able to tell you if it works
Comment 10 Frederic Crozat 2011-10-05 16:29:07 UTC
before rebooting, give output of

systemctl show  dev-vgsys-lvswap.swap
Comment 11 Neil Rickert 2011-10-05 21:27:48 UTC
Here's a short transcript.  I logged into the system (via ssh) shortly after booting, ran a couple of commands to list "crypttab" and "fstab", then logged out.

 ---- begin transcript -----
% ssh croot@nwr 
Last login: Sat Oct  1 19:26:37 2011
Have a lot of fun...
nwr.cs.niu.edu:croot 1# uname -a
Linux nwr.cs.niu.edu 3.1.0-rc7-3-default #1 SMP Wed Sep 28 14:41:36 UTC 2011 (50fb02f) i686 i686 i386 GNU/Linux
nwr.cs.niu.edu:croot 2# free
             total       used       free     shared    buffers     cached
Mem:       3024260     549872    2474388          0      27760     290328
-/+ buffers/cache:     231784    2792476
Swap:            0          0          0
nwr.cs.niu.edu:croot 3# swapon -a
nwr.cs.niu.edu:croot 4# free
             total       used       free     shared    buffers     cached
Mem:       3024260     551392    2472868          0      27776     288620
-/+ buffers/cache:     234996    2789264
Swap:     11815772          0   11815772
nwr.cs.niu.edu:croot 5# cat /etc/crypttab
cr_sda9         /dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part9 /dev/urandom swap
nwr.cs.niu.edu:croot 6# cat /etc/fstab
/dev/mapper/cr_sda9  swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part10 /                    ext4       acl,user_xattr        1 1
/dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part3 /windows/C           ntfs-3g    ro,noauto,users,gid=users,uid=601,fmask=133,dmask=022,locale=en_US.UTF-8 0 0
/dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part6 /windows/D           vfat       users,uid=601,gid=users,umask=0002,utf8=true 0 0
/dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part2 /windows/E           ntfs-3g    ro,noauto,users,uid=601,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0
/dev/disk/by-id/ata-ST9500325AS_6VEGYD5L-part1 /windows/dell        vfat       ro,noauto,users,gid=users,umask=0002,utf8=true 0 0
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
nwr.cs.niu.edu:croot 7# exit
nwr.cs.niu.edu:croot 8# logout
Connection to 192.168.254.100 closed.
 ---- end transcript -----
Comment 12 Bruno Friedmann 2011-10-06 07:29:17 UTC
@Frederic ok I've some good more informations
systemctl show swap.target (before moving in /etc/fstab/ to device/mapper/vgsys-lvswap ...

Id=swap.target
Names=swap.target
Wants=dev-mapper-vgsys\x2dlvswap.swap
WantedBy=sysinit.target
Conflicts=shutdown.target
Before=sysinit.target
After=dev-mapper-vgsys\x2dlvswap.swap
Description=Swap
LoadState=loaded
ActiveState=active
SubState=active
FragmentPath=/lib/systemd/system/swap.target
UnitFileState=static
InactiveExitTimestamp=Thu, 06 Oct 2011 09:16:33 +0200
InactiveExitTimestampMonotonic=61962260
ActiveEnterTimestamp=Thu, 06 Oct 2011 09:16:33 +0200
ActiveEnterTimestampMonotonic=61962260
ActiveExitTimestamp=Thu, 06 Oct 2011 09:15:52 +0200
ActiveExitTimestampMonotonic=20855486
InactiveEnterTimestamp=Thu, 06 Oct 2011 09:15:52 +0200
InactiveEnterTimestampMonotonic=20855486
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureIsolate=no
IgnoreOnIsolate=no
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
ConditionTimestamp=Thu, 06 Oct 2011 09:16:33 +0200
ConditionTimestampMonotonic=61962259
ConditionResult=yes
~


I've made several tests and the result is the following 
once I let the second swap in fstab the swap failed at boot. 
I don't know if it's related to the fact that one is by device name and the other by LABEL

If I comment out the second swap everything work fine. 
But having several swap is more than quiet common on desktop/server like having a small swap partition on each block device to spread load, and increase perf.

This doesn't fix the report of Neil.
Comment 13 Frederic Crozat 2011-10-06 14:04:19 UTC
let try something else :

please reboot your system with systemd.log_level=debug systemd.log_target=kmsg

and when system is started, attach dmesg output to the bug (please, no copy/paste, use file attachment feature from bugzilla).
Comment 14 Neil Rickert 2011-10-06 16:15:29 UTC
Created attachment 454918 [details]
Output from dmesg after rebooting with the requested options

dmesg output at around 11:10 am CST, Oct 06 2011 on dell laptop with 12.1 Beta1, and boot options "systemd.log_level=debug systemd.log_target=kmsg"
Comment 15 Frederic Crozat 2011-10-06 16:28:10 UTC
Neil, you have a dependency cycle, which explains the issue.

Could you do a tarball of /run/systemd/generator and attach it to the bug report ?

Thanks.
Comment 16 Neil Rickert 2011-10-06 17:49:45 UTC
Created attachment 454928 [details]
tarball of generator (in /run/systemd) on dell laptop

Tar was made from within the "/run/systemd" directory.
Comment 17 Bruno Friedmann 2011-10-08 17:37:53 UTC
@Frederic : I've found my error the LABEL=lvobsswap has a typo errors
default in place of defaults 

now with the correct flags, swap is correctly mounted on boot .
Comment 18 Neil Rickert 2011-10-09 17:48:33 UTC
>Neil, you have a dependency cycle, which explains the issue.

That may explain it for you.  It does not help me.

I am seeing "unable to break cycle" during bootup.

This problem has been there since install, and is not caused by any changes that I might have made.  I tried installing (also from the KDE live iso) on another system, where I have been using encrypted swap.  So I included encrypted swap in that install also.  The same problem (swapon not done) is occurring there.

For comparison, I also have 12.1 installed on a system with encrypted LVM.  I am not having swap problems there, and I don't think I am seeing that "unable to break cycle" message either.  In that system, everything except "/boot" is encrypted, and the cryptsetup is run from the "initrd".
Comment 19 Frederic Crozat 2011-10-10 12:00:52 UTC
there is a dependency loop between crypsetup target, which adds systemd-random-seed-load.service when password=/dev/*random is specified in /etc/crypttab (and only in this case, which explains why you had the issue) and local-fs.target which requires and is required by the cryptsetup target.

I'm discussing with upstream on how to fix this.
Comment 20 Frederic Crozat 2011-10-17 12:38:32 UTC
I've just committed a fix which has been submitted upstream for this bug.

Could you test package from home:fcrozat:systemd / systemd ? it should fix your issue.
Comment 21 Neil Rickert 2011-10-17 22:56:31 UTC
Yes, that seems to work.  Thanks.  I hope that will be in the released 12.1

Is there a way to directly use the string you provided to configure that repo?  I had to do some fumbling around to work out how to configure it.
Comment 22 Bruno Friedmann 2011-10-18 05:33:23 UTC
Neil 

This should add the repository 

zypper ar -cgf -n "fcrozat:systemd" http://download.opensuse.org/repositories/home:fcrozat:systemd/openSUSE_Factory "fcrozat:systemd"

and when you want to disable it

zypper mr -d fcrozat:systemd
Comment 23 Frederic Crozat 2011-10-18 08:26:41 UTC
thanks for the feedback. I'm waiting for upstream final decision on the patch before pushing it to Factory.
Comment 24 Frederic Crozat 2011-10-26 08:19:09 UTC
closing, pushed to factory
Comment 25 Bernhard Wiedemann 2011-10-26 09:00:07 UTC
This is an autogenerated message for OBS integration:
This bug (721666) was mentioned in
https://build.opensuse.org/request/show/89338 Factory / systemd