Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemctl disable on statically enabled units should log a useful message #9074

Closed
jsynacek opened this issue May 23, 2018 · 4 comments
Closed

Comments

@jsynacek
Copy link
Contributor

Description
Running systemctl disable sys-kernel-debug.mount does nothing. Expected behaviour is to remove all relevant symlinks as is expected from the disable operation.

Reproducible with the current master (commit da6c780).

Steps to reproduce

  1. Compile and install systemd.
  2. Check that the unit file is there.
# ls -la /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount
lrwxrwxrwx 1 root root 25 May 23 12:52 /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount -> ../sys-kernel-debug.mount
  1. Disable the mount unit.
# systemctl disable sys-kernel-debug.mount
  1. Nothing really happened. The symlink is still there.
# ls -la /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount
lrwxrwxrwx 1 root root 25 May 23 12:52 /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount -> ../sys-kernel-debug.mount

Maybe that's because the sys-kernel-debug.mount doesn't have the Install section. Let's try adding that to the unit file.

  1. Edit /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount and add the following content to the end of the file:
[Install]
WantedBy=sysinit.target
  1. Restart init.
    # init q

  2. Disable the mount unit.

# systemctl disable sys-kernel-debug.mount
  1. Nothing happened, again. The symlink is still there.
# ls -la /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount
lrwxrwxrwx 1 root root 25 May 23 12:52 /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount -> ../sys-kernel-debug.mount

After step 8), I expect that the symlink /usr/lib/systemd/system/sysinit.target.wants/sys-kernel-debug.mount should not exist, that is, it was removed by the disable operation.

@mbiebl
Copy link
Contributor

mbiebl commented May 23, 2018

sys-kernel-debug.mount is statically enabled. As you noticed the symlinks are in /usr, not /etc.
So an [Install] section will not help, as those symlinks are kept in /etc.
You could try to mask the mount unit though.

@poettering
Copy link
Member

yes, it's a statically enabled unit. If you really want to get rid of it, use "systemctl mask".

I figure we should output something more useful when one tries to disable a static unit though

@poettering poettering changed the title systemctl disable doesn't work on sys-kernel-debug.mount systemctl disable on statically enabled units should log a useful message May 23, 2018
@jsynacek
Copy link
Contributor Author

Also, you might consider changing the docs a bit, as it is not perfectly clear (to me, at least) why it's not working. The docs say the following about the disable operation (man systemctl):

This removes all symlinks to the unit files backing the specified units from the unit configuration directory, and hence undoes any changes made by enable or link.

Clearly, not all symlinks are removed and I count /usr/lib/systemd/system as a configuration directory.

@poettering
Copy link
Member

So, actually, this is a duplicate of #4012. Closing hence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants