Introduction fc

position ease box interval due
front 2.50 2 1.00 2021-08-08T07:36:20Z

ref

What is init?

In Linux, init is a abbreviation for Initialization. The init is a daemon process which starts as soon as the computer starts and continue running till, it is shutdown. In-fact init is the first process that starts when a computer boots, making it the parent of all other running processes directly or indirectly and hence typically it is assigned “pid=1“.

If somehow init daemon could not start, no process will be started and the system will reach a stage called “Kernel Panic“.

On debian, buster 10, systemd is not the init daemon. ``` ➜ ps 1 PID TTY STAT TIME COMMAND 1 ? Ss 0:20 /sbin/init

```

The need to replace init with something more perfect was felt from a long time and several alternatives were developed from time-to-time, some of which became distribution’s native init replacement, some of which are:

  1. Upstart – A init replacement daemon implemented in Ubuntu GNU/Linux and designed to start process asynchronously.
  2. Epoch – A init replacement daemon built around simplicity and service management, designed to start process single-threaded.
  3. Mudar – A init replacement daemon written in Python, implemented on Pardus GNU/Linux and designed to start process asynchronously.
  4. systemd – A init replacement daemon designed to start process in parallel, implemented in a number of standard distribution – Fedora, OpenSuSE, Arch, RHEL, CentOS, etc.

What is systemd?

A systemd is a System Management Daemon named with UNIX convention to add ‘d‘ at the end of daemon. So, that they can be easily recognized. Initially it was released under GNU General Public License, but now the releases are made under GNU Lesser General Public License. Similar to init, systemd is the parent of all other processes directly or indirectly and is the first process that starts at boot hence typically assigned a “pid=1“.

A systemd, may refer to all the packages, utilities and libraries around daemon. *It was designed to overcome the shortcomings of init. It itself is a background processes which is designed to start processes in parallel, thus reducing the boot time and computational overhead. It has a lot other features as compared to init.

Why there was a need to replace init?

A init process starts serially i.e., one task starts only after the last task startup was successful and it was loaded in the memory. This often resulted into delayed and long booting time. However, systemd was not designed for speed but for getting the things done neatly which in turns avoid all the UN-necessary delay.

  • Features of systemd

    • Clean, stateforward and efficient design.
    • Simpler boot process.
    • Concurrent and parallel processing at boot.
    • Better API.
    • Simple Unit Syntax.
    • Ability to remove optional components.
    • Low memory footprints.
    • Improved technique to express dependencies.
    • Initialization instruction written in config file and not in shell script.
    • Make use of Unix Domain Socket.
    • Job Scheduling using systemd Calendar Timers.
    • Event Logging with journald.
    • Choice of logging System events with systemd as well as syslog.
    • Logs are stored in binary file.
    • systemd state can be preserved to be called later in future.
    • Track process using kernel’s cgroup and not PID.
    • Users login managed by systemd-logind.
    • Better integration with Gnome for
    • Bottlenecks systemd
    • Everything at one place.
    • Not POSIX standard.

Definition

ref systemd is a new init system and system manager that has become so popular that it has been widely transformed into the new standard init system by most Linux distributions.

Systemctl is a systemd application that allows you to manage the systemd system.

Evolve

https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files https://www.endpoint.com/blog/2018/06/systemd-primer-from-the-trenches/

Example

To mount a drive: `/etc/systemd/mnt-data.mount` Note: Where should be name of the unit

[Unit]
Description=Additional Hard Disk Drive

[Mount]
What=/dev/sdb1
Where=/mnt/data
Type=ext4
Options=defaults

[Install]
WantedBy=multi-user.target

Note: The Where path should not contain “/": details. In the example above the Where path `/mnt/data` should use `mnt-data.mount` as unit name. command used to generate it:

systemd-escape -p --suffix=mount "/mnt/data"

To reload the changes

sudo systemctl daemon-reload

Then enable

sudo systemctl status hdd-jak.mount