1

A bit of background on what I'm trying to do: We are building an Ubuntu image that we deploy to thousands of workstations. We need to have MariaDB available on the workstations, but we only want it started when needed, to not negatively affect the boot time on machines that it is not needed.

So my plan was to do a systemctl disable mariadb.service when we build the image, and then start it via an agent that knows when it is needed. I've checked that systemctl disable mariadb.service removes the .wants symlink:

Removed /etc/systemd/system/multi-user.target.wants/mariadb.service.
Removed /etc/systemd/system/mysqld.service.
Removed /etc/systemd/system/mysql.service.

And I have confirmed that /etc/systemd/system/multi-user.target.wants/mariadb.service does not exist in the image.

However when we boot the image, the mariadb.service is enabled, as per the output of systemctl status mariadb and /etc/systemd/system/multi-user.target.wants/mariadb.service exist. There seems to something that enables it on first boot. I would like to know what does this, so I can disable it from happening.

I've had a look though the files listed in dpkg -L mariadb-server-10.3 mariadb-server-core-10.3 but have not found anything.

6
  • Hmm … this is unexpected behaviour for a modern release of Ubuntu. Which version are you imaging? I would assume it’s the Desktop build, but is it 20.04 or something else? 🤔
    – matigo
    Oct 4, 2021 at 11:33
  • 1
    1 thing to test: journalctl does that show what started it? :)
    – Rinzwind
    Oct 4, 2021 at 12:26
  • @matigo Yes, it's 20.04. It's not the desktop build. We create the image with debootstrap, and then running chroot image apt install ... and making a bunch of other changes. Oct 5, 2021 at 6:59
  • @Rinzwind I can see that systemd is starting mariadb: Oct 05 09:00:33 fnb-pop-image systemd[1]: Starting MariaDB 10.3.31 database server... I have searched the journal for what enabled it, but couldn't find anything. Oct 5, 2021 at 7:03
  • So it would be systemd that is starting it. Maybe installing mariadb sets systemd active; as in: "you installed it so you want it started". If that happens after you setting it inactive it would be active again. Could you try masking it instead of setting it disabled?
    – Rinzwind
    Oct 5, 2021 at 8:49

1 Answer 1

1

It was being enabled by systemd-preset

I was able prevent this from happening by adding this file:

# /etc/systemd/system-preset/10-mariadb.preset

disable mariadb.service
1
  • 1
    Excellent :-) Have 2 upvotes
    – Rinzwind
    Oct 5, 2021 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .