Score:0

CentOS 7 - disable all services, except ssh and networking

cn flag

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.

pt flag
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=`).
willdashwood avatar
cn flag
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`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.