ERROR : "System has not been booted with systemd as init system (PID 1). Can't operate."

akshay_khoje

Akshay

Posted on December 19, 2023

ERROR : "System has not been booted with systemd as init system (PID 1). Can't operate."

I encountered this error when I was setting up docker on my recently installed MXLinux machine.
This fix is likely to work on Debian-based distros.

The command was simply to check if docker service is up or not.

sudo systemctl status docker
Enter fullscreen mode Exit fullscreen mode

It gave me the following error:

Error message

OR Is it really an error that needs fixing?

Try this command:

sudo service docker status
Enter fullscreen mode Exit fullscreen mode

Explain this to me

Temporary fix

I figured out a way to fix this temporarily by editing the grub command line arguments by adding the parameter
init=/lib/systemd/systemd besides splash quite. You can locate this on a line starting with the linux keyword. However, this turns out to be a temporary fix. So at every reboot, I needed to repeat this procedure of adding this init parameter to the grub edit menu.

Permanent fix

A little bit of time into fixing this and I learnt that those parameters are actually referenced from the /etc/default/grub file. This file is essentially a key-value pair required to generate the desired configuration during the booting process.

From the /etc/default/grub file, the key(variable) of our attention is GRUB_CMDLINE_LINUX_DEFAULT. This variable is passed to the kernel at boot-time. The famous quiet splash attributes to disable the log messages and enabling the splash screen are values to this variable.

/etc/default/grub file before changes

Now, we simply have to add the required library that will load the systemd process at every boot by default. Thus, we add a new attribute i.e. the path to the systemd file to the above mentioned variable as follows. Assuming quiet splash already exist there

GRUB_CMDLINE_LINUX_DEFAULT="splash quiet init=/lib/systemd/systemd"

/etc/default/grub file after changes

The final step is to reboot the system.

sudo reboot
Enter fullscreen mode Exit fullscreen mode

Try the systemctl command again:

Post reboot it works

See, it works on my machine ;)

💖 💪 🙅 🚩
akshay_khoje
Akshay

Posted on December 19, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related