- Published on
Unmask a Masked Service in Systemd
- Authors
- Name
- Ruan Bekker
- @ruanbekker
Systemd is a powerful system and service manager for Linux operating systems. Sometimes, services can become masked, preventing them from starting or running properly. In this tutorial, we will walk you through the steps to unmask a masked service in systemd on Ubuntu Linux.
Checking the Status of the Masked Service
I was busy setting up a docker-volume-netshare
plugin to use NFS Volumes for Docker, which relies on the nfs-utils/nfs-common
package, and when trying to start the service, I found that the nfs-common
service is masked
:
$ sudo systemctl start docker-volume-netshare.service
Failed to start docker-volume-netshare.service: Unit nfs-common.service is masked.
Unmasking the Service
Looking at the nfs-common
service:
$ sudo systemctl is-enabled nfs-common
masked
$ sudo systemctl enable nfs-common
Synchronizing state of nfs-common.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nfs-common
Failed to enable unit: Unit file /lib/systemd/system/nfs-common.service is masked.
It appears that the unit file has a symbolic link to /dev/null:
$ file /lib/systemd/system/nfs-common.service
/lib/systemd/system/nfs-common.service: symbolic link to /dev/null
I was able to unmask the service by removing the file:
$ sudo rm /lib/systemd/system/nfs-common.service
Reloading the Systemd Daemon
Then reloading the daemon:
$ sudo systemctl daemon-reload
Starting and Enabling the Service
As we can see the nfs-common
service is not running:
$ sudo systemctl status nfs-common
● nfs-common.service - LSB: NFS support files common to client and server
Loaded: loaded (/etc/init.d/nfs-common; generated; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
Let's go ahead and start the service:
$ sudo systemctl start nfs-common
$ sudo systemctl status nfs-common
● nfs-common.service - LSB: NFS support files common to client and server
Loaded: loaded (/etc/init.d/nfs-common; generated; vendor preset: enabled)
Active: active (running) since Sat 2017-12-09 08:59:47 SAST; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 7382 ExecStart=/etc/init.d/nfs-common start (code=exited, status=0/SUCCESS)
CPU: 162ms
CGroup: /system.slice/nfs-common.service
└─7403 /usr/sbin/rpc.idmapd
Now we can see the serive is unmasked and started, also remember to enable to service on boot:
$ sudo systemctl enable nfs-common
nfs-common.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nfs-common
$ sudo systemctl is-enabled nfs-common
enabled
Conclusion
By following these steps, you can easily unmask a masked service in systemd on Ubuntu Linux. This ensures your services run as expected, improving your system's reliability.
Thanks for reading, feel free to check out my website, feel free to subscribe to my newsletter or follow me at @ruanbekker on Twitter.