Score:1

What is enabling mariadb on first boot

lk flag

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.

in flag
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?
cn flag
1 thing to test: journalctl does that show what started it? :)
lk flag
@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.
lk flag
@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.
cn flag
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?
lk flag
@Rinzwind Correct s/active/enabled/. Most services are enabled after doing an `apt install`, we disable it after we do the `apt install`, but it gets enabled on first boot. Masking works, but that also prevents manual starting. Masking in the image, and then unmasking and starting manually would work, but that feels messy. I would like to try find what is enabling it on first boot.
Score:1
lk flag

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
cn flag
Excellent :-) Have 2 upvotes
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.