You are not logged in.

#1 2014-07-04 15:50:12

asg1448
Member
Registered: 2014-04-12
Posts: 74

[SOLVED] How do I start service in systemd right after cryptsetup?

This is a cross-post from http://unix.stackexchange.com/questions … cryptsetup

I have an ArchLinux installation with systemd. I am trying to run a hook immediately after my encrypted data device is mounted in order to put flashcache on top of it. The order in which boot happens is:

- cryptsetup prompt for password, and decrypts /dev/mapper/cdata
- LVM finds a volume group vg01 on /dev/maper/cdata and creates device /dev/vg01/data

what I am looking to do is:

- after device /dev/vg01/data is ready, to run flashcache on it and create device /dev/mapper/data_cached. --> I am aware of security concerns in this scenario, they are taken care of <---

I have scripts that work, however I cannot make them load in right order. Here's what I did:

file: /usr/lib/systemd/system/flashcache.service

[Unit]
Description=FlashCache
Requires=systemd-cryptsetup@cdata.service

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/flashcache_startup_script

[Install]
WantedBy=dev-mapper-data_cached.device

After creating file, I ran systemctl enable flashcache.service.

However, on boot flashcache_startup_script does not start, the dev-mapper-data_cached times out, after which I can get into a root shell and run flashcache_startup_script manually.

I examined output of journalctl -b, and determined that FlashCache service does not load before timeout occurs.

Another option I tried without success is Requires=dev-mapper-vg1-data.device

What am I doing wrong?

Last edited by asg1448 (2014-07-05 17:57:27)

Offline

#2 2014-07-04 21:23:22

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,487

Re: [SOLVED] How do I start service in systemd right after cryptsetup?

Have you tried ordering it with "After="?

Offline

#3 2014-07-05 05:54:46

asg1448
Member
Registered: 2014-04-12
Posts: 74

Re: [SOLVED] How do I start service in systemd right after cryptsetup?

Strike0 wrote:

Have you tried ordering it with "After="?

So, replace

Requires=systemd-cryptsetup@cdata.service

with

After=systemd-cryptsetup@cdata.service

and remove WantedBy line?

Offline

#4 2014-07-05 14:11:33

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,487

Re: [SOLVED] How do I start service in systemd right after cryptsetup?

Why? Have a look, if you have seen http://www.freedesktop.org/software/sys … .unit.html

Offline

#5 2014-07-05 17:57:11

asg1448
Member
Registered: 2014-04-12
Posts: 74

Re: [SOLVED] How do I start service in systemd right after cryptsetup?

Following unit worked for me:


[Unit]
Description=FlashCache
BindsTo=dev-vg1-data.device
After=dev-vg1-data.device
DefaultDependencies=no

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/flashcache_startup_script

[Install]
WantedBy=sysinit.target

Thanks to everyone who wrote

Offline

Board footer

Powered by FluxBB