Disable a standard systemd service in Yocto build

11,573

Solution 1

If the system runs fine with the other package removed, then removing the package is a preferred solution. Fewer packages means a simpler system.

Solution 2

How about adding a .bbappend recipe for the conflicting service you want disabled. In it, you would add: SYSTEMD_AUTO_ENABLE_${PN} = "disable"

Solution 3

Usually you would set SYSTEMD_AUTO_ENABLE_${PN} = "disable" and that would let the service be part of image but disabled on boot. However for systemd which provides a lot of default service units this may not be a solution you might want to deploy. You could surgically delete the symlink in etc which will ensure that service is not started automatically on boot but the .service file is still part of image. So add following to systemd_%.bbappend file in your layer

do_install_append() {
        rm -rf ${D}${sysconfdir}/systemd/system/sysinit.target.wants/systemd-timesyncd.service
} 

There are other ways to disable this e.g. using systemd presets as described here

Share:
11,573

Related videos on Youtube

ilya1725
Author by

ilya1725

C/C++ from 1996 LabVIEW Tcl

Updated on June 04, 2022

Comments

  • ilya1725
    ilya1725 almost 2 years

    I need to start my own systemd service, let's call it custom.service. I know how to write a recipe for it to be added and enabled on boot:

    SYSTEMD_SERVICE_${PN} = "custom.service"
    SYSTEMD_AUTO_ENABLE_${PN} = "enable"
    

    However, it conflicts with one of the default systemd services - systemd-timesyncd.service.

    Is there a nice preferred way to disable that default systemd service in my bitbake file even though the systemd_XX.bb actually enables it?

    I can create a systemd_%.bbappend file to modify the systemd settings, but I can't locate the place where one service can be disabled leaving all others enabled.


    The working solution I found is to remove the timesyncd altogether using

    PACKAGECONFIG_remove = "timesyncd"
    

    But I wonder if this is a appropriate way and if there is a way to just disable it, but leave in the system.

  • ilya1725
    ilya1725 almost 6 years
    Sorry @Caspar, I've tried this and the service was still there running.
  • kcstrom
    kcstrom over 5 years
    WARNING: systemd-1_230+gitAUTOINC+3a74d4fc90-r0 do_configure: QA Issue: systemd: invalid PACKAGECONFIG: --disable-timesyncd [invalid-packageconfig]