How can I stop microk8s or snap/snapd from running?

I have an installation of snap just to use microk8s for work.

However, I seem to have no control as to when microk8s is running and it uses a lot of resources on my laptop. And running sudo systemctl stop snapd snapd.socket seems to not do anything with those services.

Does anyone know why?

And how can I configure them in a way that only when I start them, they actually run?

Use sudo systemctl disable --now snapd.socket to stop snapd to start on boot. You can start the service whenever you need by sudo systemctl start snapd.socket. I am not sure but you can also stop kubelet.service if there’s any

Those are user-level services. You must issue those commands without sudo. :arrow_down:

systemctl disable --now snapd.service snapd.socket

The above command not only stops them but also prevents them from starting automatically. You can then start them manually with… :arrow_down:

systemctl start snapd.service snapd.socket

… whenever you need them, and you replace the start with stop for stopping them. You can even create an alias for that and add it to your ~/.bashrc or ~/.zshrc, depending on what shell you use. :arrow_down:

[...]

alias startsnap="systemctl start snapd.service snapd.socket"
alias stopsnap="systemctl stop snapd.service snapd.socket"

[...]

Note: You will have to log out and back in in order for those aliases to take effect.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.