Bug 69291

Summary: swap partition not automouning anymore on boot
Product: systemd Reporter: Hussam Al-Tayeb <ht990332>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: freedesktop, ht990332, phani00, ph.wolfer, teg
Version: unspecifiedKeywords: regression
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Hussam Al-Tayeb 2013-09-12 20:32:50 UTC
i did a build from http://cgit.freedesktop.org/systemd/systemd/commit/?id=982e44dbc3e70c97e83464a30354b80973d52b41
and now my swap partition won't mount automatically at boot

cat /etc/fstab 
# 
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# UUID=0249fe74-9da0-4ce8-9d02-6af38224ba02
/dev/mapper/root        /        ext4   defaults,relatime       0 1

# UUID=9b6caf94-e5fe-461c-9fad-1a395d9d0da4
/dev/sda1               /boot    ext4   defaults,relatime       0 2

/dev/sda2 none swap defaults 0 0


it was working when i did a build around a week ago :)

How can I check logs for why this isn't working anymore? thank you :)
Comment 1 Hussam Al-Tayeb 2013-09-12 20:33:29 UTC
manually doing swapon -a enables the swap partition.
Comment 2 Hussam Al-Tayeb 2013-09-13 00:17:33 UTC
I just saw this commit:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=4f0be680b5323e037314cfbd3dba34f03e637c8f
build-sys: prepare 207

Please take a look at this bug before releasing systemd 207
Comment 3 Hussam Al-Tayeb 2013-09-13 02:01:40 UTC
this checkin is what broke it for me:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=64347fc2b983f33e7efb0fd2bb44e133fb9f30f4
Comment 4 Harald Hoyer 2013-09-13 10:43:38 UTC
WORKSFORME

~$ fgrep swap /etc/fstab
UUID=0a5847a8-358d-454f-ab98-8592de5ca4ba 	swap                    swap   defaults        	0 0

~$ cat /proc/swaps 
Filename				Type		Size	Used	Priority
/dev/sda4                               partition	6029308	0	-1


$ fgrep -r swap.target /lib/systemd/system/
/lib/systemd/system/sysinit.target:Wants=local-fs.target swap.target
/lib/systemd/system/sysinit.target:After=local-fs.target swap.target emergency.service emergency.target

~$ echo /run/systemd/generator/*.swap 
/run/systemd/generator/dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.swap

~$ cat /run/systemd/generator/*.swap 
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab

[Swap]
What=/dev/disk/by-uuid/0a5847a8-358d-454f-ab98-8592de5ca4ba

~$ find /run/systemd/generator.late/ -name '*swap*'
/run/systemd/generator.late/swap.target.wants
/run/systemd/generator.late/swap.target.wants/dev-sda4.swap
/run/systemd/generator.late/dev-sda4.swap


$ systemctl show 'dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.swap'
Id=dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.swap
Names=dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.swap
Following=dev-sda4.swap
Wants=system.slice
BindsTo=dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.device
RequiredBy=swap.target
WantedBy=dev-disk-by\x2duuid-0a5847a8\x2d358d\x2d454f\x2dab98\x2d8592de5ca4ba.device
Conflicts=umount.target
Before=umount.target swap.target
Comment 5 Hussam Al-Tayeb 2013-09-13 11:07:02 UTC
[hussam@hades linux]$  fgrep swap /etc/fstab
UUID=085d0683-1c42-436e-9218-642a81a31830 swap swap defaults 0 0
[hussam@hades linux]$ cat /proc/swaps 
Filename                                Type            Size    Used    Priority
[hussam@hades linux]$  fgrep -r swap.target /lib/systemd/system/
/lib/systemd/system/sysinit.target:Wants=local-fs.target swap.target
/lib/systemd/system/sysinit.target:After=local-fs.target swap.target emergency.service emergency.target
[hussam@hades linux]$ echo /run/systemd/generator/*.swap 
/run/systemd/generator/dev-disk-by\x2duuid-085d0683\x2d1c42\x2d436e\x2d9218\x2d642a81a31830.swap
[hussam@hades linux]$  cat /run/systemd/generator/*.swap 
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab

[Swap]
What=/dev/disk/by-uuid/085d0683-1c42-436e-9218-642a81a31830
[hussam@hades el_linux]$  find /run/systemd/generator.late/ -name '*swap*'
find: `/run/systemd/generator.late/': No such file or directory
Comment 6 Hussam Al-Tayeb 2013-09-13 11:10:43 UTC
I do have /run/systemd/generator/dev-disk-by\x2duuid-085d0683\x2d1c42\x2d436e\x2d9218\x2d642a81a31830.swap
though.
Comment 8 Hussam Al-Tayeb 2013-09-13 17:45:49 UTC
Now I have:

[hussam@hades ~]$  fgrep swap /etc/fstab
UUID=085d0683-1c42-436e-9218-642a81a31830 swap swap defaults 0 0
[hussam@hades ~]$ cat /proc/swaps 
Filename                                Type            Size    Used    Priority
[hussam@hades ~]$ fgrep -r swap.target /lib/systemd/system/
/lib/systemd/system/sysinit.target:Wants=local-fs.target swap.target
/lib/systemd/system/sysinit.target:After=local-fs.target swap.target emergency.service emergency.target
[hussam@hades ~]$ echo /run/systemd/generator/*.swap 
/run/systemd/generator/dev-disk-by\x2duuid-085d0683\x2d1c42\x2d436e\x2d9218\x2d642a81a31830.swap
[hussam@hades ~]$ cat /run/systemd/generator/*.swap 
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab

[Swap]
What=/dev/disk/by-uuid/085d0683-1c42-436e-9218-642a81a31830
[hussam@hades ~]$ find /run/systemd/generator.late/ -name '*swap*'
find: `/run/systemd/generator.late/': No such file or directory

But i still need to manually swapon -a
Comment 9 Hussam Al-Tayeb 2013-09-13 22:23:55 UTC
reopening as this is still broken for me and I have verified which checking breaks it.
Comment 10 Hussam Al-Tayeb 2013-09-14 14:12:49 UTC
http://sprunge.us/cTWB journalctl -b output.
Comment 11 Hussam Al-Tayeb 2013-09-14 14:20:04 UTC
perhaps this will help too:

systemctl show 'dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap'
Id=dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap
Names=dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap
Wants=system.slice
BindsTo=dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.device
RequiredBy=swap.target
WantedBy=dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.device
Conflicts=umount.target
Before=umount.target swap.target
After=systemd-journald.socket dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.device system.slice
Description=/dev/disk/by-uuid/5ad323ca-ad74-4f4d-baea-8d89c9072560
LoadState=loaded
ActiveState=inactive
SubState=dead
FragmentPath=/run/systemd/generator/dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap
SourcePath=/etc/fstab
InactiveExitTimestampMonotonic=0
ActiveEnterTimestampMonotonic=0
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
Comment 12 Hussam Al-Tayeb 2013-09-14 14:25:01 UTC
I just found out  systemctl start 'dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap' enables the swap partition (for this session)

Also '/usr/lib/systemd/system-generators/systemd-fstab-generator' outputs nothing.
Comment 13 Hussam Al-Tayeb 2013-09-14 15:46:02 UTC
first time I run /usr/lib/systemd/system-generators/systemd-fstab-generator after a reboot, it says nothing. second time it outputs warnings.

[root@hades hussam]# /usr/lib/systemd/system-generators/systemd-fstab-generator
[root@hades hussam]# /usr/lib/systemd/system-generators/systemd-fstab-generator
Failed to create mount unit file /tmp/-.mount, as it already exists. Duplicate entry in /etc/fstab?
Failed to create mount unit file /tmp/boot.mount, as it already exists. Duplicate entry in /etc/fstab?
Failed to create swap unit file /tmp/dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap, as it already exists. Duplicate entry in /etc/fstab?

boot partition is mounted correctly from fstab
Comment 14 Hussam Al-Tayeb 2013-09-14 16:21:49 UTC
Confirmed also by thrice in #systemd channel on freenode that it is still broken in latest git.
Comment 15 phanisvara 2013-09-14 20:04:37 UTC
(In reply to comment #14)
> Confirmed also by thrice in #systemd channel on freenode that it is still
> broken in latest git.

yep, here on an up-to-date arch install, too.
Comment 16 Tom Gundersen 2013-09-15 15:26:27 UTC
Could you please post the 'systemctl status' of the swap unit, the swap target and the corresponding device unit? I'll have a look at this tonight.
Comment 17 Hussam Al-Tayeb 2013-09-15 15:54:52 UTC
systemctl status swap.target 
swap.target - Swap
   Loaded: loaded (/usr/lib/systemd/system/swap.target; static)
   Active: active since Sun 2013-09-15 17:12:47 EEST; 1h 40min ago
     Docs: man:systemd.special(7)

Sep 15 17:12:48 hades systemd[1]: Starting Swap.
Sep 15 17:12:48 hades systemd[1]: Reached target Swap.

systemctl status dev-disk-by\x2dlabel-swap.device
dev-disk-byx2dlabel-swap.device
   Loaded: loaded
   Active: inactive (dead)
Comment 18 phanisvara 2013-09-15 16:02:35 UTC
(In reply to comment #16)

same for me, even though something's wrong with my journalctl it seems. on every reboot, it claims that the journal has been rotated, which shouldn't be the case:

------------
[root@laptop phani]# systemctl status swap.target 
swap.target - Swap
   Loaded: loaded (/usr/lib/systemd/system/swap.target; static)
   Active: active since Sun 2013-09-15 21:03:38 IST; 10min ago
     Docs: man:systemd.special(7)

Sep 15 21:03:39 laptop systemd[1]: Starting Swap.
Sep 15 21:03:39 laptop systemd[1]: Reached target Swap.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
------------

can't find any "swap unit," but will look into the device unit you requested...
Comment 19 Hussam Al-Tayeb 2013-09-15 16:06:51 UTC
(In reply to comment #18)
> (In reply to comment #16)
> 
> same for me, even though something's wrong with my journalctl it seems. on
> every reboot, it claims that the journal has been rotated, which shouldn't
> be the case:
> 
> ------------
> [root@laptop phani]# systemctl status swap.target 
> swap.target - Swap
>    Loaded: loaded (/usr/lib/systemd/system/swap.target; static)
>    Active: active since Sun 2013-09-15 21:03:38 IST; 10min ago
>      Docs: man:systemd.special(7)
> 
> Sep 15 21:03:39 laptop systemd[1]: Starting Swap.
> Sep 15 21:03:39 laptop systemd[1]: Reached target Swap.
> Warning: Journal has been rotated since unit was started. Log output is
> incomplete or unavailable.
> ------------
> 
> can't find any "swap unit," but will look into the device unit you
> requested...

it says your journal is rotated because on reboot, the following happens:
systemd closes all your applications. not all of them close gracefully. it tries  to log crash data to journal, fails because the crash data is too big => bad shutdown => journal corruption. but that's a different story :D
Comment 20 phanisvara 2013-09-15 16:10:55 UTC
ah, thanks for the explanation.

and my device unit shows the same failure as hussam's of course.
Comment 21 Tom Gundersen 2013-09-15 21:09:50 UTC
@hussam:

Based on what you have posted so far I'm a bit confused :-) It appears swap.target correctly requires the swap unit and the device correctly wants the swap unit, but swap.target is active without the swap unit being active... That shouldn't be possible...

After a fresh boot, could you please do

systemctl status dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap

systemctl status dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.device

systemctl status swap.target

?
Comment 22 phanisvara 2013-09-15 22:00:09 UTC
replacing the UUID with my own, i get this:


[root@laptop phani]# systemctl status dev-disk-by\x2duuid-de358999\913d\477d\a077\5704a4ef9f2b.swap
dev-disk-byx2duuid-de358999913d477da0775704a4ef9f2b.swap - /dev/disk/byx2duuid/de358999913d477da0775704a4ef9f2b
   Loaded: loaded
   Active: inactive (dead)
     What: /dev/disk/byx2duuid/de358999913d477da0775704a4ef9f2b

[root@laptop phani]# systemctl status dev-disk-by\x2duuid-de358999\913d\477d\a077\5704a4ef9f2b.device
dev-disk-byx2duuid-de358999913d477da0775704a4ef9f2b.device
   Loaded: loaded
   Active: inactive (dead)

[root@laptop phani]# systemctl status swap.target
swap.target - Swap
   Loaded: loaded (/usr/lib/systemd/system/swap.target; static)
   Active: active since Mon 2013-09-16 03:08:08 IST; 19min ago
     Docs: man:systemd.special(7)

Sep 16 03:08:09 laptop systemd[1]: Starting Swap.
Sep 16 03:08:09 laptop systemd[1]: Reached target Swap.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
[root@laptop phani]# 


(still couldn't figure out what screws up the journal on shutting down.)
Comment 23 Hussam Al-Tayeb 2013-09-15 22:13:19 UTC
[root@hades el_linux]# systemctl status dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.swap
dev-disk-byx2duuid-5ad323cax2dad74x2d4f4dx2dbaeax2d8d89c9072560.swap - /dev/disk/byx2duuid/5ad323cax2dad74x2d4f4dx2dbaeax2d8d89c9072560
   Loaded: loaded
   Active: inactive (dead)
     What: /dev/disk/byx2duuid/5ad323cax2dad74x2d4f4dx2dbaeax2d8d89c9072560

[root@hades el_linux]# systemctl status dev-disk-by\x2duuid-5ad323ca\x2dad74\x2d4f4d\x2dbaea\x2d8d89c9072560.device
dev-disk-byx2duuid-5ad323cax2dad74x2d4f4dx2dbaeax2d8d89c9072560.device
   Loaded: loaded
   Active: inactive (dead)

[root@hades el_linux]# systemctl status swap.target
swap.target - Swap
   Loaded: loaded (/usr/lib/systemd/system/swap.target; static)
   Active: active since Mon 2013-09-16 00:56:00 EEST; 17min ago
     Docs: man:systemd.special(7)

Sep 16 00:56:00 hades systemd[1]: Starting Swap.
Sep 16 00:56:00 hades systemd[1]: Reached target Swap.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Comment 24 Hussam Al-Tayeb 2013-09-15 22:20:04 UTC
btw, can't you simply review the culprit checkin I mentioned and see what it could have broken?
Comment 25 phanisvara 2013-09-15 22:30:48 UTC
i had my uuids mixed up, but with the correct ones it still gives the same result, plus the "What: " line with 'systemctl status ~.swap'.
Comment 26 Tom Gundersen 2013-09-15 23:19:12 UTC
Turns out that our lazy unit loading got me fooled, as calling 'systemctl show' would trigger the default dependency logic, hiding the bug...

I pushed a fix to git just now, at least it works for me. Could anyone confirm?
Comment 27 Hussam Al-Tayeb 2013-09-15 23:51:32 UTC
works now, thank you :D

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.