Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up crypted swap partition sometimes fails (racey) #10179

Closed
paulvt opened this issue Sep 26, 2018 · 27 comments · Fixed by #15836
Closed

Setting up crypted swap partition sometimes fails (racey) #10179

paulvt opened this issue Sep 26, 2018 · 27 comments · Fixed by #15836
Labels
bug 🐛 Programming errors, that need preferential fixing pid1

Comments

@paulvt
Copy link

paulvt commented Sep 26, 2018

systemd version the issue has been seen with

237

Note: While we are aware that this version is over 2 versions old, we have noticed that no relevant changes have been made to the cryptsetup generator, a key part of this bug report, since this release (except for keydev support).

Used distribution

Ubuntu 18.04 LTS (Bionic)

Expected behaviour you didn't see

The crypted swap partition is set up correctly during all boot procedures on all our devices.

Unexpected behaviour you saw

The crypted swap partition set up succeeds but the device is not marked as active:

$ systemctl status dev-mapper-crypt_swap.device
● dev-mapper-crypt_swap.device
   Loaded: loaded
  Drop-In: /run/systemd/generator/dev-mapper-crypt_swap.device.d
           └─90-device-timeout.conf
   Active: inactive (dead)

Sep 26 11:52:22 hostname systemd[1]: dev-mapper-crypt_swap.device: Job dev-mapper-crypt_swap.device/start failed with result 'timeout'.
Sep 26 11:52:52 hostname systemd[1]: dev-mapper-crypt_swap.device: Job dev-mapper-crypt_swap.device/start timed out.
...etc

In case the swap partition is marked as that it should not fail, it blocks the boot process.

Steps to reproduce the problem

  • Set up a crypted swap partition with the following fstab and crypttab entries:

/etc/fstab:

/dev/mapper/crypt_swap   none      swap sw 0 2

/etc/crypttab:

crypt_swap   PARTLABEL=SwapPartition   /dev/urandom swap,cipher=aes-xts-plain64
  • Reboot the system

For us, the issue seems to cause problems where the system is either relatively slow CPU-wise or IO-wise.

Analysis

The cyptsetup-generate of systemd generates the following service file systemd-cryptsetup@crypt_swap.service:

# Automatically generated by systemd-cryptsetup-generator

[Unit]
Description=Cryptography Setup for %I
Documentation=man:crypttab(5) man:systemd-cryptsetup-generator(8) man:systemd-cryptsetup@.service(8)
SourcePath=/etc/crypttab
DefaultDependencies=no
Conflicts=umount.target
IgnoreOnIsolate=true
After=cryptsetup-pre.target
Before=cryptsetup.target
After=systemd-random-seed.service
BindsTo=dev-disk-by\x2dpartlabel-SwapPartition.device
After=dev-disk-by\x2dpartlabel-SwapPartition.device
Before=umount.target
Before=dev-mapper-%i.swap

[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutSec=0
KeyringMode=shared
ExecStart=/lib/systemd/systemd-cryptsetup attach 'crypt_swap' '/dev/disk/by-partlabel/SwapPartition' '/dev/urandom' 'swap,cipher=aes-xts-plain64'
ExecStop=/lib/systemd/systemd-cryptsetup detach 'crypt_swap'
ExecStartPost=/sbin/mkswap '/dev/mapper/crypt_swap'

What we think that the following is going on:

  • The systemd-cryptsetup attach call leads to systemd-udev creating the device /dev/mapper/crypt_setup with SYSTEMD_READY=0 as per /lib/udev/rules.d/99-systemd-rules and also starts setting up an inotify watch as per /lib/udev/rules.d/60-persistend-storage-dm.rules.
  • On slow systems the setup of this watch races with the mkswap call that is done next.
    If mkswap is called before the watch is set up by udev, it misses the fact that the swap partition is now ready, the device keeps being marked as SYSTEMD_READY=0.
  • As a result, the service dev-mapper-crypt_swap.device never becomes active and it blocks the boot because the job timeout is set to 0 for the service by a systemd override (in case the swap partition is considered "fail").

Below are the log files of the interaction of mkswap and systemd-udev for the cases where it goes right and wrong.

Correct

Sep 24 16:58:42 hostname systemd-cryptsetup[508]: Set cipher aes, mode xts-plain64, key size 256 bits for device /dev
...
Sep 24 16:58:46 hostname systemd-udevd[489]: handling device node '/dev/dm-1', devnum=b253:1, mode=0660, uid=0, gid=6
...
Sep 24 16:58:47 hostname systemd-udevd[485]: adding watch on '/dev/dm-1'
...
Sep 24 16:58:47 hostname mkswap[591]: Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
Sep 24 16:58:47 hostname mkswap[591]: no label, UUID=4a24083d-627c-416c-bbb0-aba431b9bfa5
...
Sep 24 16:58:47 hostname systemd-udevd[480]: inotify event: 8 for /dev/dm-1
...
Sep 24 16:58:47 hostname systemd-udevd[480]: device /dev/dm-1 closed, synthesising 'change'

Wrong

Sep 24 16:50:23 hostname systemd-cryptsetup[513]: Set cipher aes, mode xts-plain64, key size 256 bits for device /dev
...
Sep 24 16:50:27 hostname systemd-udevd[499]: handling device node '/dev/dm-1', devnum=b253:1, mode=0660, uid=0, gid=6
...
Sep 24 16:50:28 hostname mkswap[599]: Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
Sep 24 16:50:28 hostname mkswap[599]: no label, UUID=0a0ab441-8efe-44f3-92e4-2b8cb7a165c4
...
Sep 24 16:50:28 hostname systemd-udevd[498]: adding watch on '/dev/dm-1'

Considerations

While systemd often relies on proper notifications for other subsystems, such as LVM etc., in this case the setup is relatively bare and systemd itself calls the bare tool mkswap and relies on udev to mark the device as ready. We currently don't know how to solve this or get around the issue.

@arvidjaar
Copy link
Contributor

creating the device /dev/mapper/crypt_setup with SYSTEMD_READY=0 as per /lib/udev/rules.d/99-systemd-rules

Wow! This is entirely bogus. There is no reason to prohibit use of device without recognizable format.

Actually #10154 is related. If systemd had ability to run commands to bring up device, this workaround would not be needed. It would just wait for mkswap to complete and proceed with any dependent services.

We currently don't know how to solve this or get around the issue.

Add udevadm trigger as one more ExecStartPost, after mkswap. This should reset SYSTEMD_READY.

@paulvt
Copy link
Author

paulvt commented Oct 1, 2018

Indeed, I had already added the following override file systemd-cryptsetup@crypt_swap.service.d/90-trigger-udev.conf:

# Run udevadm trigger after the mkswap call in the original generated
# service

[Service]
ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i

You seem to imply that the udev rules should not set SYSTEMD_READY=0 for a new crypt (opened) device, so changing that rule could be another workaround too?

@arvidjaar
Copy link
Contributor

You seem to imply that the udev rules should not set SYSTEMD_READY=0 for a new crypt (opened) device, so changing that rule could be another workaround too?

Removing it now will break swap and tmp processing by starting followup units too early. This requires some non-trivial redesign of the whole mess.

@poettering poettering added bug 🐛 Programming errors, that need preferential fixing pid1 labels Nov 20, 2018
@mmstick
Copy link

mmstick commented Jul 23, 2019

Indeed, I had already added the following override file systemd-cryptsetup@crypt_swap.service.d/90-trigger-udev.conf:

# Run udevadm trigger after the mkswap call in the original generated
# service

[Service]
ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i

That seems to do the job. This is an issue experienced heavily on Pop!_OS, because we encrypt swap partitions by default. Most hardware is unaffected, but there are a few models that hit this error regularly. After applying this, the issue stopped entirely on the Galago Pro 2.

Now I need to find a way to apply this automatically for all installations.

mmstick added a commit to mmstick/systemd that referenced this issue Jul 23, 2019
On some systems, encrypted swap partitions occasionally fail to mount at boot, because systemd does not receive the triggers that it is waiting to hear. By running `udevadm trigger /dev/mapper/$cryptswap` immediately after creation, this issue is resolved. Frequency of occurrence varies from system to system, so some systems will never experience the issue, others will occasionally experience it, and then there's the worst case scenario that experiences it almost every boot.

- Pop!_OS issue report: pop-os/pop#316
- Solution based on systemd#10179 (comment)
- Closes systemd#10179
@DemiMarie
Copy link

I strongly suspect that the real bug is in systemd-udevd: it emits an add event before establishing an inotify watch. As a result, it races against mkswap.

@ndusart
Copy link

ndusart commented Oct 30, 2019

Is there any plan to fix this ?

I'm experiencing this on Archlinux too. Most of the time, systemd will hang waiting for the swap partition while it is effectively created.

@grzegorzk
Copy link

grzegorzk commented Jan 13, 2020

I'm experiencing this issue too. Fresh Archlinux installs, boot hangs while waiting for crypt-swap device. I experience this issue 100% boots on 1CPU/1Gb RAM Linode.

On fresh install with systemd 244 I configured crypttab and fstab swap entries with noauto

Starting auto-generated swap unit manually works 100% of times.

systemd-networkd will also fail if cryp-swap is enabled. Without crypt-swap systemd-networkd will not fail.

Hope this helps!

Applying the workaround with udevadm trigger works. This seems to be the best solution for now.

ddstreet pushed a commit to ddstreet/systemd that referenced this issue Apr 25, 2020
…t processing

While external programs that take an exclusive flock on block devices while
modifying them (e.g. partitioning or mkfs) will safely work with udevd so
that the block device modifications don't race with udevd processing of the
device (e.g. creating symlinks for the newly-created partitions), any
external program that doesn't take an exclusive flock will race with udevd,
and the changes made to the block device may be missed by udevd, leading to
failures, e.g. udevd might not create the symlinks for new partitions, or
might not create the /dev/disk/by-* for new filesystems.

This updates the flock function to also take a short-duration inotify
watch, so that after processing the device, udevd can synthesize a new
uevent if it detected any IN_CLOSE_WRITE while the device was being
processed, before the real watch was added.

One example is the mkswap that we ourselves actually run, from the service
created by cryptsetup-generator; we have it running mkswap:

if (swap)
  fprintf(f,
    "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
    name_escaped);

However, this is racy, because it doesn't take an exclusive flock.  This
(and probably other places in our own code) should have done "flock ..."
instead.  If it's hard for us to get this right, it seems too much to
expect all other non-systemd programs to also be aware they need to flock
the block device.

Fixes: systemd#10179
ddstreet pushed a commit to ddstreet/systemd that referenced this issue Apr 26, 2020
…t processing

While external programs that take an exclusive flock on block devices while
modifying them (e.g. partitioning or mkfs) will safely work with udevd so
that the block device modifications don't race with udevd processing of the
device (e.g. creating symlinks for the newly-created partitions), any
external program that doesn't take an exclusive flock will race with udevd,
and the changes made to the block device may be missed by udevd, leading to
failures, e.g. udevd might not create the symlinks for new partitions, or
might not create the /dev/disk/by-* for new filesystems.

This updates the flock function to also take a short-duration inotify
watch, so that after processing the device, udevd can synthesize a new
uevent if it detected any IN_CLOSE_WRITE while the device was being
processed, before the real watch was added.

One example is the mkswap that we ourselves actually run, from the service
created by cryptsetup-generator; we have it running mkswap:

if (swap)
  fprintf(f,
    "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
    name_escaped);

However, this is racy, because it doesn't take an exclusive flock.  This
(and probably other places in our own code) should have done "flock ..."
instead.  If it's hard for us to get this right, it seems too much to
expect all other non-systemd programs to also be aware they need to flock
the block device.

Fixes: systemd#10179
ddstreet pushed a commit to ddstreet/systemd that referenced this issue Apr 26, 2020
…t processing

While external programs that take an exclusive flock on block devices while
modifying them (e.g. partitioning or mkfs) will safely work with udevd so
that the block device modifications don't race with udevd processing of the
device (e.g. creating symlinks for the newly-created partitions), any
external program that doesn't take an exclusive flock will race with udevd,
and the changes made to the block device may be missed by udevd, leading to
failures, e.g. udevd might not create the symlinks for new partitions, or
might not create the /dev/disk/by-* for new filesystems.

This updates the flock function to also take a short-duration inotify
watch, so that after processing the device, udevd can synthesize a new
uevent if it detected any IN_CLOSE_WRITE while the device was being
processed, before the real watch was added.

One example is the mkswap that we ourselves actually run, from the service
created by cryptsetup-generator; we have it running mkswap:

if (swap)
  fprintf(f,
    "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
    name_escaped);

However, this is racy, because it doesn't take an exclusive flock.  This
(and probably other places in our own code) should have done "flock ..."
instead.  If it's hard for us to get this right, it seems too much to
expect all other non-systemd programs to also be aware they need to flock
the block device.

Fixes: systemd#10179
ddstreet pushed a commit to ddstreet/systemd that referenced this issue Apr 26, 2020
…t processing

While external programs that take an exclusive flock on block devices while
modifying them (e.g. partitioning or mkfs) will safely work with udevd so
that the block device modifications don't race with udevd processing of the
device (e.g. creating symlinks for the newly-created partitions), any
external program that doesn't take an exclusive flock will race with udevd,
and the changes made to the block device may be missed by udevd, leading to
failures, e.g. udevd might not create the symlinks for new partitions, or
might not create the /dev/disk/by-* for new filesystems.

This updates the flock function to also take a short-duration inotify
watch, so that after processing the device, udevd can synthesize a new
uevent if it detected any IN_CLOSE_WRITE while the device was being
processed, before the real watch was added.

One example is the mkswap that we ourselves actually run, from the service
created by cryptsetup-generator; we have it running mkswap:

if (swap)
  fprintf(f,
    "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
    name_escaped);

However, this is racy, because it doesn't take an exclusive flock.  This
(and probably other places in our own code) should have done "flock ..."
instead.  If it's hard for us to get this right, it seems too much to
expect all other non-systemd programs to also be aware they need to flock
the block device.

Fixes: systemd#10179
@Thorsten42
Copy link

Thorsten42 commented May 4, 2020

Hi, I think I am facing this issue but I’m using ubuntu server 18.04.04 and I’m using whole disc encryption and I also mount additional encrypted partitions. I hope you could help me to adjust your quick fix to my situation.

My system is a small homeserver sever, which I use remotely with a ssd for the os and two hdds for data. Therefore, I am using dropbear/ssh for decrypting the ssd remotely, which contains a key file for mounting the two hdds which contain a luks encrypted btrfs raid. However, the boot process hangs indefinitely in 1 out of 20 boot attempts. This is unfortunately quite inconvenient from a remote location.

Since i have 3 encrypted devices I also have 3 systemd services - so is adding

[Service]
ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i

to all services ok?

Here is my crypttab file:

cat /etc/crypttab
sda3_crypt UUID=4a9229f3-1a91-4d9d-aeaa-09ba39bca09a none luks,discard
storage1 UUID=ec520805-0997-4940-9daa-a918a6c492bc /keyfile luks
storage2 UUID=99de0ac4-1f73-4933-abe4-a9e8496d399d /keyfile luks

And here my fstab:

cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/node--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda2 during installation
UUID=b74cd290-51ac-4019-a572-ba9b7d106b69 /boot           ext4    defaults        0       2
# /boot/efi was on /dev/sda1 during installation
UUID=C329-C41A  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/node--vg-swap_1 none            swap    sw              0       0
/dev/mapper/storage1 /mnt/data btrfs defaults,device=/dev/mapper/storage1,device=/dev/mapper/storage2 0 0

And here the 3 systemd cryptsetup services

sudo systemctl status systemd-cryptsetup@sda3_crypt.service 
● systemd-cryptsetup@sda3_crypt.service - Cryptography Setup for sda3_crypt
   Loaded: loaded (/etc/crypttab; generated)
   Active: active (exited) since Mon 2020-05-04 08:38:03 CEST; 7h ago
     Docs: man:crypttab(5)
           man:systemd-cryptsetup-generator(8)
           man:systemd-cryptsetup@.service(8)
 Main PID: 925 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/system-systemd\x2dcryptsetup.slice/systemd-cryptsetup@sda3_crypt.service

May 04 08:38:03 node systemd[1]: Starting Cryptography Setup for sda3_crypt...
May 04 08:38:03 node systemd-cryptsetup[925]: Volume sda3_crypt already active.
May 04 08:38:03 node systemd[1]: Started Cryptography Setup for sda3_crypt.


sudo systemctl status systemd-cryptsetup@storage1.service 
● systemd-cryptsetup@storage1.service - Cryptography Setup for storage1
   Loaded: loaded (/etc/crypttab; generated)
   Active: active (exited) since Mon 2020-05-04 08:38:06 CEST; 7h ago
     Docs: man:crypttab(5)
           man:systemd-cryptsetup-generator(8)
           man:systemd-cryptsetup@.service(8)
 Main PID: 907 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/system-systemd\x2dcryptsetup.slice/systemd-cryptsetup@storage1.service

May 04 08:38:03 node systemd[1]: Starting Cryptography Setup for storage1...
May 04 08:38:03 node systemd-cryptsetup[907]: Set cipher aes, mode xts-plain64, key size 256 bits for device /dev/disk/by-uuid/ec520805-0997-4
May 04 08:38:06 node systemd[1]: Started Cryptography Setup for storage1.


sudo systemctl status systemd-cryptsetup@storage2.service 
● systemd-cryptsetup@storage2.service - Cryptography Setup for storage2
   Loaded: loaded (/etc/crypttab; generated)
   Active: active (exited) since Mon 2020-05-04 08:38:06 CEST; 7h ago
     Docs: man:crypttab(5)
           man:systemd-cryptsetup-generator(8)
           man:systemd-cryptsetup@.service(8)
 Main PID: 908 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/system-systemd\x2dcryptsetup.slice/systemd-cryptsetup@storage2.service

May 04 08:38:03 node systemd[1]: Starting Cryptography Setup for storage2...
May 04 08:38:03 node systemd-cryptsetup[908]: Set cipher aes, mode xts-plain64, key size 256 bits for device /dev/disk/by-uuid/99de0ac4-1f73-4
May 04 08:38:06 node systemd[1]: Started Cryptography Setup for storage2.

Thanks!

@paulvt
Copy link
Author

paulvt commented May 11, 2020

@Thorsten42 I would think so! But these services are generated so you'll need to use overrides. This issue is mainly caused of a race between mkswap and udev setting up the swatch. In your case the FS is already there so it is a bit unrelated but it could help?

@Thorsten42
Copy link

@paulvt thanks I will test it :)

poettering added a commit to poettering/systemd that referenced this issue May 18, 2020
… and "tmp" options

This way we can take benefit of the correct block device locking we just
added.

I was thinking whether to instead pull in a regular
systemd-makefs@.service instance, but I couldn't come up with a reason
to, and thus opted for just doing the minimal patch and just replacing
the simply mkfs calls.

Fixes: systemd#10179
Replaces: systemd#13162
@poettering
Copy link
Member

My proposed fix is in #15836. would be great if anyone could test if it makes things work for them!

@poettering poettering linked a pull request May 18, 2020 that will close this issue
poettering added a commit to poettering/systemd that referenced this issue May 18, 2020
… and "tmp" options

This way we can take benefit of the correct block device locking we just
added.

I was thinking whether to instead pull in a regular
systemd-makefs@.service instance, but I couldn't come up with a reason
to, and thus opted for just doing the minimal patch and just replacing
the simply mkfs calls.

Fixes: systemd#10179
Replaces: systemd#13162
3point2 added a commit to 3point2/arch-systemd-gh10179 that referenced this issue May 18, 2020
@3point2
Copy link

3point2 commented May 18, 2020

Thanks for this Lennart.

I didn't have any luck reproducing the bug with a few reboots after removing my ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i workaround this evening, but I'm optimistic it will crop up again. Once it does I will try the patched version I have built here and report back (original repo here).

If any other Arch linux users here are also interested in testing, you can clone the repository linked above and use makepkg -s in the trunk directory to create a patched package of systemd 245.5-2 - Ideally you would first confirm that you can replicate the bug on 245.5-2 before using the patched version.

I've also uploaded the package I built into the dist directory.

@keszybz
Copy link
Member

keszybz commented May 19, 2020

Please test the linked PR, or systemd-246-rc1 when it comes out.

@3point2
Copy link

3point2 commented May 22, 2020

testing update: The issue just appeared again for me, so I've now installed the version with the fix that I linked earlier and will report back again in a week or so.

@3point2
Copy link

3point2 commented May 24, 2020

Hi again all, unfortunately I've just experienced another hang on boot using the version of systemd I built with Lennart's fix linked here, logs attached: journalctl-gh10179.log.

15:30:10 is when I give up waiting and hit alt-ctrl-delete.

@DemiMarie
Copy link

@oes placing the following file in /etc/systemd/system/systemd-cryptsetup@.service.d/override.conf fix the problem? I have used it for at least a year with no problems. @poettering since this solution is known to work reliably, would it be possible to include it?

[Unit]
Before=dev-mapper-%i.swap
Requires=systemd-random-seed.service
After=systemd-random-seed.service
[Service]
ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i

@DemiMarie
Copy link

I believe there is still a race condition even after the fix for this issue:

  1. systemd-udevd opens the device, probes it, and finds nothing.
  2. systemd-makefs opens the device, locks it, creates the header, and unlocks it.
  3. systemd-udevd establishes the inotify watch, but it is too late, as systemd-makefs has already run.

The following drop-in file, however, does solve the problem:

[Unit]
Before=dev-mapper-%i.swap
Requires=systemd-random-seed.service
After=systemd-random-seed.service
[Service]
ExecStartPost=/sbin/udevadm trigger /dev/mapper/%i

By forcing systemd-udevd to re-probe the block device after systemd-makefs has run, the changes made by systemd-makefs are guaranteed to be detected. This is one of two solutions I am aware of, the other being #15837

@poettering
Copy link
Member

@DemiMarie udevd opens the device, then locks it actually, and then installs inotify on it, and then unlocks it. if systemd-makefs then opens the device too, locks it, makes its changes and unlocks it, closes it, then udev will see the inotify close event, and retry. Key really here is that both udev and makefs take the lock

@DemiMarie
Copy link

@3point2 have you built updated versions of systemd-makefs?

@3point2
Copy link

3point2 commented May 28, 2020

Yes @DemiMarie the makepkg command used to build the patched Arch Linux package I'm testing with does a complete build of https://github.com/systemd/systemd-stable/tree/v245.5 with a few backports and three patches, the third being Lennart's fix for this issue (to view the patches see the 00*.patch files here). The PKGBUILD file in the same directory also includes the exact meson and ninja commands used to run the build. If you run a tar tf on the result you'll see that systemd-makefs is included in the final artifact.

@poettering If you'd like to add some additional logging to your makefs-lock branch I'd be happy to re-build and attach the output - This would give additional assurance that I'm building everything correctly and hopefully shed some light as to why I'm still getting hangs without the udevadm trigger workaround.

@DemiMarie
Copy link

@poettering does udev rescan all block devices if an inotify event is lost? Inotify is not a reliable protocol, so this can happen. My udevadm trigger workaround completely prevents this.

@DemiMarie
Copy link

@poettering this not fixed.

@dsigurds
Copy link

dsigurds commented Dec 9, 2020

I'm on a custom embedded linux build using systemd 241 and have a similar problem with an encrypted device that isn't swap. My crypttab will create a /dev/mapper/crypt device but it then doesn't mount with my /etc/fstab entry. If I change my fstab entry to be /dev/dm-0 rather than /dev/mapper/crypt it all works great, but I can't do that since /dev/dm-0 isn't a stable path.

@DemiMarie
Copy link

@poettering testing shows that this is fixed in systemd 246. @dsigurds systemd 241 is too old for this issue tracker; please discuss it with your distro maintainer.

@dsigurds
Copy link

dsigurds commented Dec 9, 2020

Okay, thank you for the information about version 246

@poettering
Copy link
Member

@poettering testing shows that this is fixed in systemd 246

Excellent, thanks for reporting back.

@fr3aker
Copy link

fr3aker commented Dec 30, 2020

I am still experiencing this problem with systemd 246.6 (gentoo linux). My boot process got stuck in four of four attempts at

Starting Cryptography Setup for swap...
Finished Cryptography Setup for swap.
Reached target Block De*ation for /dev/mapper/swap.
Reached target Local Encrypted Volumes.
A start job is running for /dev/mapper/swap (x min / no limit)

Commenting out the entry in /etc/fstab and booting shows that /dev/mapper/swap is indeed correctly created and everything.

Adding the udevadm trigger workaround described above does not fix the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing pid1
Development

Successfully merging a pull request may close this issue.