Cryptsetup - sda3_crypt is still in use at shutdown and reboot

Hi!

When I shutdown or reboot my system, systemd (cryptsetup) says

"cryptsetup - sda3_crypt is still in use... device is busy".

Shutdown and reboot are fast, nothing hangs at the shutdown or reboot procedure.

cryptsetup: "2:2.1.0-1ubuntu1"

I've changed in the file: "/lib/cryptsetup/cryptdisks-functions":

Removes all mappings in crypttab

do_stop() {
dmsetup mknodes
log_action_begin_msg "Stopping $INITSTATE crypto disks"

crypttab_foreach_entry _do_stop_callback
log_action_end_msg 0

}

to

Removes all mappings in crypttab

do_stop() {
dmsetup remove_all
local dst src key opts opencount major minor

dmsetup mknodes
log_action_begin_msg "Stopping $INITSTATE crypto disks"

crypttab_foreach_entry _do_stop_callback
log_action_end_msg 0

}

...but that didn't help.

Is there a way to fix that or hide the message from cryptsetup?

System: U-M 19.04

tl;dr: append the x-initrd.attach option in /etc/crypttab to the line starting with sda3_crypt

Explanation:

This will make systemd aware that sda3_crypt contains the root partition and will postpone closing sda3_crypt, see also https://www.freedesktop.org/software/systemd/man/crypttab.html#x-initrd.attach

1 Like