0

This is a follow up question to Disable all services, except ssh. I want to achieve the same thing on CentOS 7 but I'm having trouble getting it to work.

I've created /usr/lib/systemd/system/maintenance.target and the contents are as follows:

[Unit]
Description=Maintenance Mode with Networking and SSH
Requires=maintenance.target systemd-networkd.service sshd.service
After=maintenance.target systemd-networkd.service sshd.service
AllowIsolate=yes

But when I run systemctl isolate maintenance.target I get:

Failed to start maintenance.target: Unit not found.

Not sure where to go from here. Any ideas? By the way, the purpose of this is to be able to run an clone of a live server to a new one with the minimum of downtime. Previously I've just been stopping all services manually but I'd like a more "catch all" approach.

willdashwood
  • 103
  • 1
  • 1
  • 5
  • I don't know if this is the problem, but you have a recursive dependency: it looks like you've specified that `maintenance.target` depends on itself (in both `Requires=` and `After=`). – larsks Oct 12 '22 at 12:57
  • Thanks for the comment. I did try removing "maintenance.target " from those lines but still no joy. If I run `systemd-analyze verify maintenance.target` I get: `Error: org.freedesktop.systemd1.NoSuchUnit: Unit not found. Failed to create maintenance.target/start: No such file or directory` – willdashwood Oct 12 '22 at 14:10

0 Answers0