{"id":1069,"date":"2020-09-30T14:33:47","date_gmt":"2020-09-30T14:33:47","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=1069"},"modified":"2020-09-30T14:33:47","modified_gmt":"2020-09-30T14:33:47","slug":"systemd-mother-of-all-processes","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2020\/09\/30\/systemd-mother-of-all-processes\/","title":{"rendered":"SYSTEMD: Mother of all processes"},"content":{"rendered":"<p><code>systemd<\/code> is the replacement system for System V and with the primary goal of starting services in parallel.<\/p>\n<blockquote>\n<p>Remember <code>init<\/code> levels?<\/p>\n<\/blockquote>\n\n\n<figure class=\"wp-block-pullquote has-background has-luminous-vivid-orange-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>GRUB: Grand Unified Boot Loader<\/p><cite>\/boot\/grub\/grub.conf<\/cite><\/blockquote><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/opensource.com\/sites\/default\/files\/uploads\/systemd-architecture.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Some key points<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><code>systemd<\/code> is PID 1<\/li><li> Major points in a boot-up process<ul><li>There are two sequences of events that are required to boot a Linux computer and make it usable: <em>boot<\/em> and <em>startup<\/em>.<\/li><li>The <em>boot<\/em> sequence starts when the computer is turned on, and is completed when the <code>kernel<\/code> is initialized and <strong>systemd<\/strong> is launched. <\/li><li><em>startup<\/em> process takes over after <code>boot<\/code> is complete and finishes the task of getting the Linux computer into an operational state.<\/li><li>BIOS &#8211; Power on self test<ul><li>BIOS POST checks the basic operability of the hardware and then it issues an interrupt, which locates the boot sectors on any attached bootable devices<\/li><\/ul><\/li><\/ul><ul><li>Boot loader<ul><li>First stage &#8211; The first boot sector with valid boot record (MBR) is loaded into RAM and control is then transferred to the code that was loaded from the boot sector.<\/li><\/ul><\/li><li>Kernel Initialization<ul><li>The primary function of  boot loader like GRUB is to get the Linux kernel loaded into memory and running.<\/li><li>Once the kernel has extracted itself, it loads systemd, and turns control over to it.<\/li><\/ul><\/li><li>Start <code>systemd<\/code> &#8211; mother of all processes.<ul><li>It is responsible for bringing the Linux host up to a state in which productive work can be done.<\/li><li>First <code>systemd<\/code> mounts the filesystems as defined by <strong>\/etc\/fstab<\/strong><\/li><\/ul><\/li><\/ul><\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">ls \/etc\/systemd<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>total 40\n 0 drwxr-xr-x.   4 root root  151 Aug 31 08:45 .\n12 drwxr-xr-x. 145 root root 8192 Aug 31 08:46 ..\n 4 -rw-r--r--.   1 root root  720 Aug  6 17:30 bootchart.conf\n 4 -rw-r--r--.   1 root root  615 Aug  6 17:30 coredump.conf\n 4 -rw-r--r--.   1 root root  983 Aug  6 17:30 journald.conf\n 4 -rw-r--r--.   1 root root  968 Jan 28  2019 logind.conf\n 4 drwxr-xr-x.  19 root root 4096 Aug  6 17:30 system\n 4 -rw-r--r--.   1 root root 1552 Aug  6 17:30 system.conf\n 0 drwxr-xr-x.   2 root root    6 Aug  6 17:30 user\n 4 -rw-r--r--.   1 root root 1127 Aug  6 17:30 user.conf<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-luminous-vivid-orange-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>If POST fails, the computer may not be usable and so the boot process does not continue.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Example: \/etc\/fstab<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n#\n# \/etc\/fstab\n# Created by anaconda on Mon Jan 28 20:51:49 2019\n#\n# Accessible filesystems, by reference, are maintained under '\/dev\/disk'\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info\n#\nUUID=f41e390f-835b-4223-a9bb-9b45984ddf8d \/                       xfs     defaults        0 0<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-luminous-vivid-orange-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p>Note that targets and services are <code>systemd<\/code> units.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Targets: \/etc\/systemd\/system<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>root@docker>ls -als system\ntotal 16\n4 drwxr-xr-x. 19 root root 4096 Aug  6 17:30 .\n0 drwxr-xr-x.  4 root root  151 Aug 31 08:45 ..\n0 drwxr-xr-x.  2 root root   57 Jan 28  2019 basic.target.wants\n0 drwxr-xr-x.  2 root root   31 Mar 18  2019 bluetooth.target.wants\n0 drwxr-xr-x.  2 root root  119 Jul 28 07:54 cloud-init.target.wants\n0 lrwxrwxrwx.  1 root root   41 Mar 18  2019 dbus-org.bluez.service -> \/usr\/lib\/systemd\/system\/bluetooth.service\n0 lrwxrwxrwx.  1 root root   41 Mar 18  2019 dbus-org.fedoraproject.FirewallD1.service -> \/usr\/lib\/systemd\/system\/firewalld.service\n0 lrwxrwxrwx.  1 root root   44 Mar 18  2019 dbus-org.freedesktop.Avahi.service -> \/usr\/lib\/systemd\/system\/avahi-daemon.service\n0 lrwxrwxrwx.  1 root root   44 Mar 18  2019 dbus-org.freedesktop.ModemManager1.service -> \/usr\/lib\/systemd\/system\/ModemManager.service\n0 lrwxrwxrwx.  1 root root   46 Mar 18  2019 dbus-org.freedesktop.NetworkManager.service -> \/usr\/lib\/systemd\/system\/NetworkManager.service\n0 lrwxrwxrwx.  1 root root   57 Mar 18  2019 dbus-org.freedesktop.nm-dispatcher.service -> \/usr\/lib\/systemd\/system\/NetworkManager-dispatcher.service\n0 lrwxrwxrwx.  1 root root   37 Jan 28  2019 default.target -> \/lib\/systemd\/system\/multi-user.target\n0 drwxr-xr-x.  2 root root  111 Mar 18  2019 default.target.wants\n0 drwxr-xr-x.  2 root root   38 Jan 28  2019 dev-virtio\\x2dports-org.qemu.guest_agent.0.device.wants\n0 lrwxrwxrwx.  1 root root   35 Mar 18  2019 display-manager.service -> \/usr\/lib\/systemd\/system\/gdm.service\n0 drwxr-xr-x.  2 root root   32 Jan 28  2019 getty.target.wants\n0 drwxr-xr-x.  2 root root  133 Mar 18  2019 graphical.target.wants\n4 -rwxr-xr-x.  1 root root  435 Mar 18  2019 ir_agent.service\n0 drwxr-xr-x.  2 root root   35 Jan 28  2019 local-fs.target.wants\n4 drwxr-xr-x.  2 root root 4096 Jul 30 11:02 multi-user.target.wants\n0 drwxr-xr-x.  2 root root   48 Mar 18  2019 network-online.target.wants\n0 drwxr-xr-x.  2 root root   26 Mar 18  2019 printer.target.wants\n0 drwxr-xr-x.  2 root root   31 Jan 28  2019 remote-fs.target.wants\n0 drwxr-xr-x.  2 root root  217 Mar 18  2019 sockets.target.wants\n4 drwxr-xr-x.  2 root root 4096 Mar 18  2019 sysinit.target.wants\n0 drwxr-xr-x.  2 root root   44 Jan 28  2019 system-update.target.wants\n0 drwxr-xr-x.  2 root root   34 Mar 18  2019 timers.target.wants\n0 lrwxrwxrwx.  1 root root    9 Jan 28  2019 tmp.mount -> \/dev\/null\n0 drwxr-xr-x.  2 root root   29 Mar 18  2019 vmtoolsd.service.requires<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\/etc\/systemd\/system\/default.target<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#  This file is part of systemd.\n#\n#  systemd is free software; you can redistribute it and\/or modify it\n#  under the terms of the GNU Lesser General Public License as published by\n#  the Free Software Foundation; either version 2.1 of the License, or\n#  (at your option) any later version.\n\n&#91;Unit]\nDescription=Multi-User System\nDocumentation=man:systemd.special(7)\nRequires=basic.target\nConflicts=rescue.service rescue.target\nAfter=basic.target rescue.service rescue.target\nAllowIsolate=yes<\/code><\/pre>\n\n\n\n<p>The <code>After<\/code> &amp; <code>Requires<\/code> defines the dependencies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>systemd is the replacement system for System V and with the primary goal of starting services in parallel. Remember init levels? GRUB: Grand Unified Boot Loader \/boot\/grub\/grub.conf Some key points systemd is PID 1 Major points in a boot-up process There are two sequences of events that are required to boot a Linux computer and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1076,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[112,113],"class_list":["post-1069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical","tag-linux","tag-systemd"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=1069"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1069\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/1076"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=1069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=1069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=1069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}