You are not logged in.

#1 2015-11-03 11:59:00

vanquish
Member
Registered: 2013-12-28
Posts: 49

[SOLVED] Systemd proper order shutdown/reboot (zfs on luks/dm-crypt)

Hi,

I'm facing a problem on shutdown/rebooting my server:

System configuration:

- latest arch (x64)
- 1 system disk
- 3 disks bound in a crypted zfs-raid (zfs-raidz1 over three luks/dm-crypt devices)

All works fine expect the shutdown/reboot.

There is a timing issue in the systemd-chain on shutdown/reboot. The current order looks like that:

1. services shutdown (mysql, httpd) - o.k.
2. umount (other) filesystems - o.k.
3. cryptsetup luksClose - wrong!
--> Error/Fail (Screen getting cluttered by: "device-mapper: remove ioctl on xxxx failed: Device or resource busy"). After about a half minute the system is going down.

So before cryptsetup/luksClose there must be a "zpool export" executed. I've tried this by adding a script to systemd. But I failed. I cannot track down on which point I have to insert this script respectively I have not enough knowledge about the before/after/requires and so on. So I need help. smile

My understanding is that there is a missing dependency/link between zfs-systemd-scripts and cryptsetup-systemd-scripts. How I could solve this?

Kind regards.


Edit:

I have solved this issue by adding a new file to /usr/lib/systemd/system-shutdown/zfs.shutdown

#!/bin/sh
/sbin/zpool export -a

It seems logical to me. I don't know if this is the way it has to be done. I've found this option after reading this: http://www.freedesktop.org/software/sys … rvice.html
Maybe it help others to umount filesystems properly.

Thanks for reading this post anyway. smile

Edit2:

Well the message flood is gone ... The error is still there ... -.- ... But I don't care anymore ...

Nov 03 15:07:57 arch systemd[1]: Stopping Cryptography Setup for p1...
Nov 03 15:07:57 arch systemd[1]: Stopping Cryptography Setup for p2...
Nov 03 15:07:58 arch systemd[1]: Stopping Cryptography Setup for p3...
...

Nov 03 15:07:58 arch systemd[1]: Unmounting /boot/efi...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /snapshots/boot...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/xxx...
Nov 03 15:07:58 arch systemd[1]: Unmounting /arch/iscsi...
Nov 03 15:07:58 arch systemd[1]: Unmounting /home...
...

Nov 03 15:08:02 arch systemd-cryptsetup[2815]: Failed to deactivate: Device or resource busy
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p1.service: Control process exited, code=ex
Nov 03 15:08:02 arch systemd[1]: Stopped Cryptography Setup for p1.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p1.service: Unit entered failed state.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p1.service: Failed with result 'exit-code'.
Nov 03 15:08:02 arch systemd-cryptsetup[2818]: Failed to deactivate: Device or resource busy
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p2.service: Control process exited, code=ex
Nov 03 15:08:02 arch systemd[1]: Stopped Cryptography Setup for p2.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p2.service: Unit entered failed state.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p2.service: Failed with result 'exit-code'.
Nov 03 15:08:02 arch systemd-cryptsetup[2816]: Failed to deactivate: Device or resource busy
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p3.service: Control process exited, code=ex
Nov 03 15:08:02 arch systemd[1]: Stopped Cryptography Setup for p3.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p3.service: Unit entered failed state.
Nov 03 15:08:02 arch systemd[1]: systemd-cryptsetup@p3.service: Failed with result 'exit-code'.

It seems cryptsetup is not waiting for umount ...

Last edited by vanquish (2015-11-03 14:53:46)

Offline

Board footer

Powered by FluxBB