[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: systemd support for init level use case

On Jo, 24 iul 14, 19:44:20, Gregory Seidman wrote:
> I'm on stable, but I'm reading the threads about systemd and I want to be
> prepared for the next stable release. I run a RAID1 with an encryption loop
> and LVM on top of that for my home directories and a number of data volumes
> (i.e. nothing system-critical like /usr or /var).
> I boot into init level 2, which does not bring up the RAID, much less
> encryption, LVM, or mounted filesystems. I then log in as root on the
> console and run a script to bring up the additional filesystems,
> particularly the encryption. This requires interaction to supply the
> password. Once the filesystems are mounted, the script runs /sbin/telinit 3
> to start additional services which depend on those filesystems (apache2,
> exim4, fetchmail, etc.).

Well, systemd natively works with "targets" (see systemd.target(5)). For 
backwards compatibility it provides these symlinks:

$ ls -l /lib/systemd/system/runlevel?.target
lrwxrwxrwx 1 root root 15 iul 16 02:25 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root 13 iul 16 02:25 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx 1 root root 17 iul 16 02:25 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx 1 root root 17 iul 16 02:25 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx 1 root root 17 iul 16 02:25 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx 1 root root 16 iul 16 02:25 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx 1 root root 13 iul 16 02:25 /lib/systemd/system/runlevel6.target -> reboot.target

> I don't always want to bring everything up, and I certainly don't want boot
> to hang on user input waiting for the encryption password. Does systemd
> have some init level equivalent? Should I be modeling my script as several
> custom systemd services (which are not automatically started), including
> some virtual service that depends on all the ones I'm currently bringing up
> as init level 3?

It might be possible to integrate your scripts with systemd, but on such 
occasions I take the time to rethink my setup to use the native methods 
provided by the new system.

Based on the few things I know about systemd I'd say you need one or 
several mount units (see systemd.unit(5), systemd.mount(5)) that do all 
stuff needed to bring up the additional filesystems.

For the services (apache, exim, etc.) you will need to adjust the 
service units (see systemd.service(5)) to depend on your mount units. As 
far as I understand you just need to create files under 
/etc/systemd/system/ with just the additions you need and then include 
the package provided unit file.

In order to bring up everything with just one command you might also 
need to create your own target.

Hope this helps,
Offtopic discussions among Debian users and developers:

Attachment: signature.asc
Description: Digital signature

Reply to: