Systemd – How to Create a New .slice File in Debian

cgroupdebiansystemd

I'm struggling to understand how to set up a new slice on my debian 10 system. I have created a file, system-db.slice by copying system.slice and changing a couple of things:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=System DB Slice
Documentation=man:systemd.special(7)
DefaultDependencies=no
Before=slices.target
Requires=system.slice
After=system.slice

This doesn't appear to do anything at all; it doesn't show up in systemd-cgls, for example. On the other hand, systemctl finds it:

# systemctl status system-db.slice
● system-db.slice - System DB Slice
   Loaded: loaded (/etc/systemd/system/system-db.slice; static; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd.special(7)

Clearly there are some things I haven't done or done wrong. How should I have done this? And where can I learn more about this?

Best Answer

The slice is only started when a service that uses the slice is started. You do not start it manually. Rather, you add Slice=my.slice to the unit that you want to be restricted by this slice.