SlideShare a Scribd company logo
1 of 102
Systemd
손승하
Contents
1. Systemd is..
2. Systemd Unit
3. Boot process with systemd
4. Service management
5. Resource management
6. Log management
7. Systemd Snapshots
8. Target
9. Timer
1. Systemd is..
1. systemd is …
• what is systemd?
- Already the basis of Fedora, RHEL, CentOS, OpenSUSE and much
embedded.
- Soon to be the basis of Debian and Ubuntu.
- after OpenStack and Docker, the most discussed new Linux
feature.
1. systemd is …
• what is systemd?
- System and Service manager.
- systemd is compatible with SysV and LSB init scripts.
- modular.
- asynchronous and concurrent.
- descripbed by declarative sets of properties.
- features a is independent of languages API.
1. systemd is …
• philosophy
Extract duplicate functionality from individual daemons
and move it to the systemd core or the Linux Kernel.
1. systemd is …
1. systemd is …
• What is systemd?
- Provides parallelization capabilities.
- Uses socket and D-Bus activation for starting services.
- Offers on-demand starting of daemons.
- Implements transactional dependency-based service control logic.
- Tracks processes using Linux cgroups.
- Supports snapshotting and restoring.
- Maintains mount and automount points.
2. Systemd Unit
2. Systemd Unit
• Units
- Units are the objects that systemd knows how to manage.
- systemd based around the notion of units.
- units have a name and a type.
2. Systemd Unit
• Units
- A unit configuration file encodes information about a service, a
socket, a device, a mount point, an automount point, a swap file
or partition, a start-up target, a watched file system path, a timer
controlled and supervised by systemd
2. Systemd Unit
• Unit path
- /usr/lib/systemd/system/: units provided by installed packages
- /etc/systemd/system/: units installed by the system administrator
• Unit file list
file describe
.service how to manage a service or application on the server.
.socket
A network or IPC socket, or a FIFO buffer that systemd uses for socket-
based activation.
.device
A device that has been designated as needing systemd management
by udev or the sysfs filesystem.
.mount defines a mountpoint on the system to be managed by systemd.
.automount configures a mountpoint that will be automatically mounted.
.swap swap space on the system.
2. Systemd Unit
• Unit file list
file describe
.target
Used to provide synchronization points for other units when booting
up or changing states.
.timer
Defines a timer that will be managed by systemd, similar to a cron job
for delayed or scheduled activation.
.snapshot Created automatically by the systemctl snapshot command.
.slice
Associated with Linux Control Group nodes, allowing resources to be
restricted or assigned to any processes associated with the slice.
.scope
Created automatically by systemd from information received from its
bus interfaces.
2. Systemd Unit
• General Characteristics of Unit Files
- Section names are well defined and case-sensitive.
- Within these sections, unit behavior and metadata is defined
through the use of simple directives using a key-value format.
[Section]
Directive1=value
Directive2=value
2. Systemd Unit
• Unit file structure
지시자 설명
[Unit]
- Unit의 type에 의존적이지 않는 일반적인 옵션을 포함.
- Init 을 설명하고 Unit의 동작을 정의.
- 다른 유닛과의 Dependency 설정.
[Unit type]
- 특정 유닛이 type-specific 지시자를 가지고 있다면 해당 옵션에 대한 항목
을 참조하여 유닛파일을 작성하거나 파악해야 함.
[Install]
- 인스톨 관련 정보.
- systemctl enable과 disasble에 의한 동작 기술되어 있음.
2. Systemd Unit
3. Boot process with systemd
3. Boot process with systemd
• SysVinit
- The init process is started by the kernel.
- Reads /etc/inittab to find the default run level.
- Reads the files starting with S in /etc/rc.d/rc${initdefault}.d
- Executes each one in order, on at a time.
3. Boot process with systemd
• upstart
- Makes booting faster by encoding dependencies between
modules.
- upstart then resolves these dependencies and start up as many
things as it can in parallel.
3. Boot process with systemd
• upstart - problem
- Encoding the dependencies.
- Still starting too much.
3. Boot process with systemd
• Systemd
- A new init system for Linux.
- Makes booting faster.
(Start processes in parallel, start fewer processes)
To start less.
And to start more in parallel.
3. Boot process with systemd
• Systemd
- Starting less means starting fewer services or deferring the
starting of services until they are actually needed.
- if we have to run something, we should not serialize its start-up
(as sysvinit does), but run it all at the same time, so that the
available CPU and disk IO bandwidth is maxed out, and hence the
overall start-up time minimized.
1. The BIOS initialization.
2. MBR reads information from Grub or LILO boot
loader and initializes the kernel.
3. The very first target executed by systemd
is default.target.
default.target is actually a symlink to
graphical.target.
4. multi-user.target has been invoked This target
sets the environment for multi user support.
multi-user.target passes control to another layer
basic.target.requirement
after
multi-user.target has been invoked and this target
keep its further sub-units.
5. "basic.target" unit is the one that starts usual
services specially graphical manager service.
basic.target passes on control to sysinit.target.
requirement
6. "sysinit.target" starts important system services
like file System mounting, swap spaces and devices,
kernel additional options etc.
sysinit.target passes on startup process to local-
fs.target.
after
requirement
after
7. local-fs.target , no user related services are started
by this target unit, it handles core low level services
only. This target is the one performing actions on
the basis of /etc/fstab and /etc/inittab files.
requirement
after
requirement
after
3. Boot process with systemd
• The minimum execution unit of systemd
- Various tasks in the SysVinit’s system initialization scripts are extracted and
defined as independent ‘Unit’s.
3. Boot process with systemd
• Socket Activation
- Socket activation makes it possible to start all services completely
simultaneously, without any kind of ordering.
- Much more powerful is socket activation when used for all local
services including those which need to be started anyway on
boot.
3. Boot process with systemd
• Socket Activation – Traditional SysV
- Traditional SysV-based system only
one service can be in the process of
getting started at a time.
- The following serialization of startup
would take place
3. Boot process with systemd
• Socket Activation – Upstart
upstart
- Certain distributions tried to improve
this strictly serialized start-up
- The parallelization is increased, the
overall startup time slightly smaller.
3. Boot process with systemd
• Socket Activation - Systemd
- Socket activation makes it possible to start
all four services completely simultaneously,
without any kind of ordering.
- the creation of the listening sockets is
moved outside of the daemons themselves
we can start them all at the same time, and
they are able to connect to each other's
sockets right-away.
Syslog
D-bus
service
socket
3. Boot process with systemd
• a number of other benefits
- no longer need to configure dependencies.
- If a service dies its listening socket stays around, not losing a
message.
- Not a single connection is lost during the upgrade.
- We can even replace a service during runtime in a way that is
invisible to the client.
3. Boot process with systemd
- Modern daemons on Linux tend to provide services via D-Bus
instead of AF_UNIX sockets.
- Using bus activation a service can be started the first time it is
accessed.
- Bus activation gives us the minimal per-request synchronisation we
need for starting up the providers and the consumers of D-Bus
services at the same time
• Parallelizing Bus Service
3. Boot process with systemd
CUPS
Avahi
CUPSAvahi
D-Bus
D-bus Queue
If CUPS is quicker than Avahi via the bus activation logic we can get D-
Bus to queue the request until Avahi manages to establish its service
name.
• Parallelizing Bus Service
3. Boot process with systemd
- File-system related jobs: mounting, fscking, quota.
- A lot of time is spent idling to wait until all devices that are listed in
/etc/fstab show up in the device tree and are then fsck'ed, mounted,
quota checked (if enabled).
- After that is fully finished we go on and boot the actual services.
- Improve this using the venerable autofs system.
• Parallelizing File system
3. Boot process with systemd
• Parallelizing File system - autofs
- autofs is a program for automatically mounting directories on an
as-needed basis.
open()
wait.. All Filesystem ready
File 1
autofs
Service A
open()
File 1
Service A
All filesystem
File system
ready
3. Boot process with systemd
• Parallelizing File system - autofs
- This way we can begin starting our daemons even before all file
systems have been fully made available -- without them missing
any files, and maximizing parallelization.
4. Service Managemant
4. Service Management
• Service Management
- For service management tasks, the target unit will be service units.
- These are the most obvious kind of unit: daemons that can be started,
stopped, restarted, reloaded
4. Service Management
• Starting and Stopping Services
- To start a systemd service, executing instructions in the service's
unit file, use the start command.
$sudo systemctl start application.service
$sudo systemctl start application
4. Service Management
• Starting and Stopping Services
- To stop a currently running service, can use the stop command
instead.
$sudo systemctl stop application
4. Service Management
• Restarting and Reloading
- To restart a currently running service, can use the restart command.
$sudo systemctl restart application.service
4. Service Management
• Restarting and Reloading
- If the application in question is able to reload its configuration
files (without restarting), can issue the reload command to initiate
that process:
$sudo systemctl reload application.service
4. Service Management
• Enabling and Disabling
- To start services automatically at boot, must enable them.
- This will create a symbolic link from the system's copy of the service file
into the location on disk where systemd looks for autostart files
$sudo systemctl enable application.service
4. Service Management
• Enabling and Disabling
- To disable the service from starting automatically.
- This will remove the symbolic link that indicated that the service should
be started automatically.
$sudo systemctl disable application.service
4. Service Management
• Checking the Status of Services
- To check the status of a service on your system, you can use the status
command.
$systemctl status application.service
4. Service Management
• Listing Current Units
- To see a list of all of the active units that systemd knows about, we can
use the list-units command.
$systemctl list-units
4. Service Management
• Listing Current Units
- The output has the following columns.
UNIT The systemd unit name.
LOAD Whether the unit's configuration has been parsed by systemd.
ACTIVE A summary state about whether the unit is active.
SUB
This is a lower-level state that indicates more detailed information
about the unit.
DESCRIPTION A short textual description of what the unit is/does.
5. Resource Managemant
5. Resource management
• Cgroup
- According to the Linux kernel documentation
: "Control Groups provide a mechanism for aggregating/partitioning
sets of tasks, and all their future children, into hierarchical groups
with specialized behaviour.“
- cgroups is a Linux kernel feature that limits, accounts for, and
isolates the resource usage (CPU, memory, disk I/O, network, etc.) of
a collection of processes.
5. Resource management
• Cgroup
- Isolate a set of processes that tend to manage resource
consumption, restricting resource use to a preconfigured limit.
- Assign sufficient memory or processing resources.
- Allocate network or storage bandwidth.
- Track assigned resources.
- Restrict device access to specific users or groups
5. Resource management
• Cgroup
5. Resource management
• systemd’s Resource Control Concepts
- systemd organizes processes with cgroups.
- systemd provides three unit types that are useful for the purpose of
resource control.
Service
a number of processes that are started and stopped by
systemd based on configuration.
Scope
a number of processes that are started and stopped by
arbitrary processes via fork(), and then registered at
runtime with PID1.
Slices
be used to group a number of services and scopes
together in a hierarchical tree.
5. Resource management
• systemd’s Resource Control Concepts
- Service, scope and slice units directly map to objects in the
cgroup tree.
5. Resource management
• Previously, with sysVinit
- No tracking of which service started which processes.
- Hard to completely terminate a service.
- No resources limitation, which is per-process, not per-service.
5. Resource management
• Cgroup and Systemd
- Tracking and killing all processes created by each service.
- Per-service accounting and resources allocation/limitation.
- Isolate user sessions – Kill all user processes.
- A central part of a system that starts up and maintains services
should be process babysitting.
- It should watch services.
- If they crash it should collect information about them.
• Keeping Track of Processes
5. Resource management
6. Log management
6. Log management
• Log management mechanism of systemd
- systemd intercepts messages to stdout/stderr and rsyslogd
- The message are sent to its own logging service.
- “systemd-journald.service” or “journald”
6. Log management
• Traditional system log flow
Process
/dev/log
rsyslogd
6. Log management
• System log flow under systemd
Process
/dev/log
systemd /run/systemd/journal/syslog
rsyslogd
6. Log management
• Imjournal: Systemd Journal Input Module
Process
/dev/log
systemd /run/systemd/journal/syslog
rsyslogd
- The latest rsyslogd can directly access journald’s database using
‘imjournal’ module.
6. Log management
• Journal
- systemd has its own logging system called the journal
- Show all messages from this boot :
$ journalctl -b
- Show all messages from date :
$ journalctl --since="2016-01-30 18:17:16"
6. Log management
• Journal
- Show all messages since 20 minutes ago :
$ journalctl --since "20 min ago"
- Follow new messages :
$ journalctl -f
- Show all messages by a specific executable :
$ journalctl /usr/lib/systemd/systemd
6. Log management
• Journal
- Show all messages by a specific process :
$ journalctl _PID=1
- Show all messages by a specific unit :
$ journalctl -u netcfg
- Show kernel ring buffer :
$ journalctl -k
7. Systemd Snapshots
7. Systemd Snapshots
• Systemd Snapshots
- Snapshots can be used to save or rollback the state of all services
and units of the system.
- Systemd snapshots have two inteded use cases :
To allow a user to temporarily enter a specific state such as “Emergency Shell”,
terminating current services, and provide an easy way to return to the state
before, pulling up all services again that got temporarily pulled down.
7. Systemd Snapshots
• Systemd Snapshots
- Snapshot units are not configured via unit configuration files.
- A unit whose name ends in ".snapshot" refers to a dynamic
snapshot of the systemd runtime state.
- Snapshots are not configured on disk but created dynamically.
$ systemd snapshot name
7. Systemd Snapshots
• Systemd Snapshots
- When created, they will automatically get dependencies on the
currently activated units.
- They act as saved runtime state of the systemd manager.
8. Target
8. Target
• Target
- systemd uses targets which serve a similar purpose as runlevels.
- Each target is named instead of numbered and is intended to
serve a specific purpose with the possibility of having multiple
ones active at the same time.
- Get current targets :
$systemctl list-units –type=target
8. Target
• Target table
8. Target
• Target
- The standard target is default.target, which is aliased by default
to graphical.target.
- Change current target :
- This will only change the current target, and has no effect on the
next boot.
$systemctl isolate xxx.target
8. Target
• Target
- Leave the bootloader alone and change default.target. This can
be done using systemctl:
$systemctl set-default xxx.target
• Power management
- Shut down and reboot the system:
$systemctl reboot
- Shut down and power-off the system :
$systemctl poweroff
8. Target
8. Target
• Power management
- Suspend the system :
$systemctl suspend
- Put the system into hibernation
$systemctl hibernate
- Put the system into hybrid-sleep state(or suspend-to both)
$systemctl hybrid-sleep
9. Timer
9. Timer
• Timer
- Although cron is arguably the most well-known job scheduler,
systemd timers can be an alternative.
- Monotonic timers :
activate after a time span relative to a varying starting point.
- Realtime timers :
activate on a calendar event (like cronjobs).
9. Timer
• Timer
- To view all started timers :
$systemctl list-timers
9. Timer
• Timer benefits
- Jobs can be easily started independently of their timers.
- Each job can be configured to run in a specific environment.
- Jobs can be attached to cgroups.
- Jobs can be set up to depend on other systemd units.
- Jobs are logged in the systemd journal for easy debugging.
9. Timer
• Example
- Monotonic timer : A timer which will start 15 minutes after boot
and again every week while the system is running.
[Unit]
Description=Run foo weekly and on boot
[Timer]
OnBootSec=15min
OnUnitActiveSec=1w
[Install]
WantedBy=timers.target
9. Timer
• Example
- Realtime timer : A timer which starts once a week (at 12:00am on
Monday).
[Unit]
Description=Run foo weekly
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
Q & A
감사합니다.
참고 정보
- Your first dive into systemd | Etsufi Nakai
- Systemd with RHEL 7 | 박현익
- https://fedoraproject.org/wiki/Packaging:Systemd
- http://0pointer.de/blog/projects/systemd.html
- http://linoxide.com/linux-how-to/systemd-boot-process/
- https://www.digitalocean.com/community/tutorials/understanding-systemd-units-
and-unit-files
- http://blog.fpmurphy.com/2013/09/systemd-snapshots.html#ixzz46tOBI500
• [Unit] Section
Appendix
• [Unit type] Section
Appendix
• [Install] Section
Appendix
• [Service] Section
- simple: The main process of the service is specified in the start line. This is the default if
the Type= and Busname= directives are not set, but the ExecStart= is set. Any
communication should be handled outside of the unit through a second unit of the
appropriate type (like through a .socket unit if this unit must communicate using
sockets).
- forking: This service type is used when the service forks a child process, exiting the
parent process almost immediately. This tells systemd that the process is still running
even though the parent exited.
- oneshot: This type indicates that the process will be short-lived and that systemd
should wait for the process to exit before continuing on with other units. This is the
default Type= and ExecStart= are not set. It is used for one-off tasks.
Appendix
• [Service] Section
- dbus: This indicates that unit will take a name on the D-Bus bus. When this happens,
systemd will continue to process the next unit.
- notify: This indicates that the service will issue a notification when it has finished
starting up. The systemd process will wait for this to happen before proceeding to
other units.
- idle: This indicates that the service will not be run until all jobs are dispatched.
- RemainAfterExit=: This directive is commonly used with the oneshot type. It indicates
that the service should be considered active even after the process exits.
- PIDFile=: If the service type is marked as "forking", this directive is used to set the path
of the file that should contain the process ID number of the main child that should be
monitored.
Appendix
• [Service] Section
- BusName=: This directive should be set to the D-Bus bus name that the service will
attempt to acquire when using the "dbus" service type.
- NotifyAccess=: This specifies access to the socket that should be used to listen for
notifications when the "notify" service type is selected This can be "none", "main", or
"all. The default, "none", ignores all status messages. The "main" option will listen to
messages from the main process and the "all" option will cause all members of the
service's control group to be processed.
- ExecStart=: This specifies the full path and the arguments of the command to be
executed to start the process. This may only be specified once (except for "oneshot"
services). If the path to the command is preceded by a dash "-" character, non-zero exit
statuses will be accepted without marking the unit activation as failed.
Appendix
• [Service] Section
- ExecStartPre=: This can be used to provide additional commands that should be
executed before the main process is started. This can be used multiple times. Again,
commands must specify a full path and they can be preceded by "-" to indicate that
the failure of the command will be tolerated.
- ExecStartPost=: This has the same exact qualities as ExecStartPre= except that it
specifies commands that will be run after the main process is started.
- ExecReload=: This optional directive indicates the command necessary to reload the
configuration of the service if available.
- ExecStop=: This indicates the command needed to stop the service. If this is not given,
the process will be killed immediately when the service is stopped.
Appendix
• [Service] Section
- ExecStopPost=: This can be used to specify commands to execute following the stop
command.
- RestartSec=: If automatically restarting the service is enabled, this specifies the amount
of time to wait before attempting to restart the service.
- Restart=: This indicates the circumstances under which systemd will attempt to
automatically restart the service. This can be set to values like "always", "on-success",
"on-failure", "on-abnormal", "on-abort", or "on-watchdog". These will trigger a restart
according to the way that the service was stopped.
- TimeoutSec=: This configures the amount of time that systemd will wait when stopping
or stopping the service before marking it as failed or forcefully killing it. You can set
separate timeouts with TimeoutStartSec= and TimeoutStopSec= as well.
Appendix
• [Socket] Section
- ListenStream=: This defines an address for a stream socket which supports sequential,
reliable communication. Services that use TCP should use this socket type.
- ListenDatagram=: This defines an address for a datagram socket which supports fast,
unreliable communication packets. Services that use UDP should set this socket type.
- ListenSequentialPacket=: This defines an address for sequential, reliable communication
with max length datagrams that preserves message boundaries. This is found most
often for Unix sockets.
- ListenFIFO: Along with the other listening types, you can also specify a FIFO buffer
instead of a socket.
Appendix
• [Socket] Section
- Accept=: This determines whether an additional instance of the service will be started
for each connection. If set to false (the default), one instance will handle all connections.
- SocketUser=: With a Unix socket, specifies the owner of the socket. This will be the root
user if left unset.
- SocketGroup=: With a Unix socket, specifies the group owner of the socket. This will be
the root group if neither this or the above are set. If only the SocketUser= is set,
systemd will try to find a matching group.
- SocketMode=: For Unix sockets or FIFO buffers, this sets the permissions on the created
entity.
- Service=: If the service name does not match the .socket name, the service can be
specified with this directive.
Appendix
• [Mount] Section
- What=: The absolute path to the resource that needs to be mounted.
- Where=: The absolute path of the mount point where the resource should be mounted.
This should be the same as the unit file name, except using conventional filesystem
notation.
- Type=: The filesystem type of the mount.
- Options=: Any mount options that need to be applied. This is a comma-separated list.
- SloppyOptions=: A boolean that determines whether the mount will fail if there is an
unrecognized mount option.
- DirectoryMode=: If parent directories need to be created for the mount point, this
determines the permission mode of these directories.
- TimeoutSec=: Configures the amount of time the system will wait until the mount
operation is marked as failed.
Appendix
• [Automount] Section
- Where=: The absolute path of the automount point on the filesystem. This will match
the filename except that it uses conventional path notation instead of the translation.
- DirectoryMode=: If the automount point or any parent directories need to be created,
this will determine the permissions settings of those path components.
Appendix
• [Swap] Section
- What=: The absolute path to the location of the swap space, whether this is a file or a
device.
- Priority=: This takes an integer that indicates the priority of the swap being configured.
- Options=: Any options that are typically set in the /etc/fstab file can be set with this
directive instead. A comma-separated list is used.
- TimeoutSec=: The amount of time that systemd waits for the swap to be activated
before marking the operation as a failure.
Appendix
• [Path] Section
- PathExists=: This directive is used to check whether the path in question exists. If it
does, the associated unit is activated.
- PathExistsGlob=: This is the same as the above, but supports file glob expressions for
determining path existence.
- PathChanged=: This watches the path location for changes. The associated unit is
activated if a change is detected when the watched file is closed.
- PathModified=: This watches for changes like the above directive, but it activates on file
writes as well as when the file is closed.
- DirectoryNotEmpty=: This directive allows systemd to activate the associated unit when
the directory is no longer empty.
Appendix
• [Path] Section
- Unit=: This specifies the unit to activate when the path conditions specified above are
met. If this is omitted, systemd will look for a .service file that shares the same base
unit name as this unit.
- MakeDirectory=: This determines if systemd will create the directory structure of the
path in question prior to watching.
- DirectoryMode=: If the above is enabled, this will set the permission mode of any path
components that must be created.
Appendix
• [Timer] Section
- OnActiveSec=: This directive allows the associated unit to be activated relative to
the .timer unit's activation.
- OnBootSec=: This directive is used to specify the amount of time after the system is
booted when the associated unit should be activated.
- OnStartupSec=: This directive is similar to the above timer, but in relation to when the
systemd process itself was started.
- OnUnitActiveSec=: This sets a timer according to when the associated unit was last
activated.
- OnUnitInactiveSec=: This sets the timer in relation to when the associated unit was last
marked as inactive.
- OnCalendar=: This allows you to activate the associated unit by specifying an absolute
instead of relative to an event.
Appendix
• [Timer] Section
- AccuracySec=: This unit is used to set the level of accuracy with which the timer should
be adhered to. By default, the associated unit will be activated within one minute of the
timer being reached. The value of this directive will determine the upper bounds on the
window in which systemd schedules the activation to occur.
- Unit=: This directive is used to specify the unit that should be activated when the timer
elapses. If unset, systemd will look for a .service unit with a name that matches this unit.
- Persistent=: If this is set, systemd will trigger the associated unit when the timer
becomes active if it would have been triggered during the period in which the timer
was inactive.
- WakeSystem=: Setting this directive allows you to wake a system from suspend if the
timer is reached when in that state.
Appendix

More Related Content

What's hot

LAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLinaro
 
Memory consistency models and basics
Memory consistency models and basicsMemory consistency models and basics
Memory consistency models and basicsRamdas Mozhikunnath
 
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ ClustersIBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ ClustersDavid Ware
 
Tutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting routerTutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting routerShu Sugimoto
 
Lisa 2015-gluster fs-hands-on
Lisa 2015-gluster fs-hands-onLisa 2015-gluster fs-hands-on
Lisa 2015-gluster fs-hands-onGluster.org
 
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
BPF  & Cilium - Turning Linux into a Microservices-aware Operating SystemBPF  & Cilium - Turning Linux into a Microservices-aware Operating System
BPF & Cilium - Turning Linux into a Microservices-aware Operating SystemThomas Graf
 
Dave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMUDave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMUDanny Abukalam
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)William Liang
 
Proxmox Talk - Linux Fest Northwest 2018
Proxmox Talk - Linux Fest Northwest 2018Proxmox Talk - Linux Fest Northwest 2018
Proxmox Talk - Linux Fest Northwest 2018Richard Clark
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI IntroductionRohit Banga
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPTQUONTRASOLUTIONS
 
File replication
File replicationFile replication
File replicationKlawal13
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsNational Cheng Kung University
 

What's hot (20)

Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
LAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg development
 
Introduction to OpenCL
Introduction to OpenCLIntroduction to OpenCL
Introduction to OpenCL
 
Pthread
PthreadPthread
Pthread
 
Memory consistency models and basics
Memory consistency models and basicsMemory consistency models and basics
Memory consistency models and basics
 
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ ClustersIBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM WebSphere MQ: Managing Workloads, Scaling and Availability with MQ Clusters
 
Tutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting routerTutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting router
 
Lisa 2015-gluster fs-hands-on
Lisa 2015-gluster fs-hands-onLisa 2015-gluster fs-hands-on
Lisa 2015-gluster fs-hands-on
 
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
BPF  & Cilium - Turning Linux into a Microservices-aware Operating SystemBPF  & Cilium - Turning Linux into a Microservices-aware Operating System
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
 
Dave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMUDave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMU
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
 
Proxmox Talk - Linux Fest Northwest 2018
Proxmox Talk - Linux Fest Northwest 2018Proxmox Talk - Linux Fest Northwest 2018
Proxmox Talk - Linux Fest Northwest 2018
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
File replication
File replicationFile replication
File replication
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
 

Similar to Systemd overview

Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!Etsuji Nakai
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 
Systemd mlug-20140614
Systemd mlug-20140614Systemd mlug-20140614
Systemd mlug-20140614Susant Sahani
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager Alison Chaiken
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administratorsSusant Sahani
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administratorsSusant Sahani
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1Susant Sahani
 
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemProcess, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemLieYah Daliah
 
Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)WajeehaBaig
 
Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Neeraj Shrimali
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.pptshreesha16
 
Linux Du Jour
Linux Du JourLinux Du Jour
Linux Du Jourmwedgwood
 
Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Akshata Sawant
 
Meeting 9 nfs network file system
Meeting 9   nfs network file systemMeeting 9   nfs network file system
Meeting 9 nfs network file systemSyaiful Ahdan
 

Similar to Systemd overview (20)

Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Daemons
DaemonsDaemons
Daemons
 
Wissbi osdc pdf
Wissbi osdc pdfWissbi osdc pdf
Wissbi osdc pdf
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 
Systemd mlug-20140614
Systemd mlug-20140614Systemd mlug-20140614
Systemd mlug-20140614
 
systemd
systemdsystemd
systemd
 
4.Process.ppt
4.Process.ppt4.Process.ppt
4.Process.ppt
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating SystemProcess, Threads, Symmetric Multiprocessing and Microkernels in Operating System
Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System
 
Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)
 
Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup.
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.ppt
 
Linux Du Jour
Linux Du JourLinux Du Jour
Linux Du Jour
 
Os
OsOs
Os
 
Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11
 
Meeting 9 nfs network file system
Meeting 9   nfs network file systemMeeting 9   nfs network file system
Meeting 9 nfs network file system
 

Recently uploaded

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Systemd overview

  • 2. Contents 1. Systemd is.. 2. Systemd Unit 3. Boot process with systemd 4. Service management 5. Resource management 6. Log management 7. Systemd Snapshots 8. Target 9. Timer
  • 4. 1. systemd is … • what is systemd? - Already the basis of Fedora, RHEL, CentOS, OpenSUSE and much embedded. - Soon to be the basis of Debian and Ubuntu. - after OpenStack and Docker, the most discussed new Linux feature.
  • 5. 1. systemd is … • what is systemd? - System and Service manager. - systemd is compatible with SysV and LSB init scripts. - modular. - asynchronous and concurrent. - descripbed by declarative sets of properties. - features a is independent of languages API.
  • 6. 1. systemd is … • philosophy Extract duplicate functionality from individual daemons and move it to the systemd core or the Linux Kernel.
  • 8. 1. systemd is … • What is systemd? - Provides parallelization capabilities. - Uses socket and D-Bus activation for starting services. - Offers on-demand starting of daemons. - Implements transactional dependency-based service control logic. - Tracks processes using Linux cgroups. - Supports snapshotting and restoring. - Maintains mount and automount points.
  • 10. 2. Systemd Unit • Units - Units are the objects that systemd knows how to manage. - systemd based around the notion of units. - units have a name and a type.
  • 11. 2. Systemd Unit • Units - A unit configuration file encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start-up target, a watched file system path, a timer controlled and supervised by systemd
  • 12. 2. Systemd Unit • Unit path - /usr/lib/systemd/system/: units provided by installed packages - /etc/systemd/system/: units installed by the system administrator
  • 13. • Unit file list file describe .service how to manage a service or application on the server. .socket A network or IPC socket, or a FIFO buffer that systemd uses for socket- based activation. .device A device that has been designated as needing systemd management by udev or the sysfs filesystem. .mount defines a mountpoint on the system to be managed by systemd. .automount configures a mountpoint that will be automatically mounted. .swap swap space on the system. 2. Systemd Unit
  • 14. • Unit file list file describe .target Used to provide synchronization points for other units when booting up or changing states. .timer Defines a timer that will be managed by systemd, similar to a cron job for delayed or scheduled activation. .snapshot Created automatically by the systemctl snapshot command. .slice Associated with Linux Control Group nodes, allowing resources to be restricted or assigned to any processes associated with the slice. .scope Created automatically by systemd from information received from its bus interfaces. 2. Systemd Unit
  • 15. • General Characteristics of Unit Files - Section names are well defined and case-sensitive. - Within these sections, unit behavior and metadata is defined through the use of simple directives using a key-value format. [Section] Directive1=value Directive2=value 2. Systemd Unit
  • 16. • Unit file structure 지시자 설명 [Unit] - Unit의 type에 의존적이지 않는 일반적인 옵션을 포함. - Init 을 설명하고 Unit의 동작을 정의. - 다른 유닛과의 Dependency 설정. [Unit type] - 특정 유닛이 type-specific 지시자를 가지고 있다면 해당 옵션에 대한 항목 을 참조하여 유닛파일을 작성하거나 파악해야 함. [Install] - 인스톨 관련 정보. - systemctl enable과 disasble에 의한 동작 기술되어 있음. 2. Systemd Unit
  • 17. 3. Boot process with systemd
  • 18. 3. Boot process with systemd • SysVinit - The init process is started by the kernel. - Reads /etc/inittab to find the default run level. - Reads the files starting with S in /etc/rc.d/rc${initdefault}.d - Executes each one in order, on at a time.
  • 19. 3. Boot process with systemd • upstart - Makes booting faster by encoding dependencies between modules. - upstart then resolves these dependencies and start up as many things as it can in parallel.
  • 20. 3. Boot process with systemd • upstart - problem - Encoding the dependencies. - Still starting too much.
  • 21. 3. Boot process with systemd • Systemd - A new init system for Linux. - Makes booting faster. (Start processes in parallel, start fewer processes) To start less. And to start more in parallel.
  • 22. 3. Boot process with systemd • Systemd - Starting less means starting fewer services or deferring the starting of services until they are actually needed. - if we have to run something, we should not serialize its start-up (as sysvinit does), but run it all at the same time, so that the available CPU and disk IO bandwidth is maxed out, and hence the overall start-up time minimized.
  • 23. 1. The BIOS initialization. 2. MBR reads information from Grub or LILO boot loader and initializes the kernel. 3. The very first target executed by systemd is default.target. default.target is actually a symlink to graphical.target.
  • 24. 4. multi-user.target has been invoked This target sets the environment for multi user support. multi-user.target passes control to another layer basic.target.requirement after multi-user.target has been invoked and this target keep its further sub-units.
  • 25. 5. "basic.target" unit is the one that starts usual services specially graphical manager service. basic.target passes on control to sysinit.target. requirement 6. "sysinit.target" starts important system services like file System mounting, swap spaces and devices, kernel additional options etc. sysinit.target passes on startup process to local- fs.target. after requirement after
  • 26. 7. local-fs.target , no user related services are started by this target unit, it handles core low level services only. This target is the one performing actions on the basis of /etc/fstab and /etc/inittab files. requirement after requirement after
  • 27. 3. Boot process with systemd • The minimum execution unit of systemd - Various tasks in the SysVinit’s system initialization scripts are extracted and defined as independent ‘Unit’s.
  • 28. 3. Boot process with systemd • Socket Activation - Socket activation makes it possible to start all services completely simultaneously, without any kind of ordering. - Much more powerful is socket activation when used for all local services including those which need to be started anyway on boot.
  • 29. 3. Boot process with systemd • Socket Activation – Traditional SysV - Traditional SysV-based system only one service can be in the process of getting started at a time. - The following serialization of startup would take place
  • 30. 3. Boot process with systemd • Socket Activation – Upstart upstart - Certain distributions tried to improve this strictly serialized start-up - The parallelization is increased, the overall startup time slightly smaller.
  • 31. 3. Boot process with systemd • Socket Activation - Systemd - Socket activation makes it possible to start all four services completely simultaneously, without any kind of ordering. - the creation of the listening sockets is moved outside of the daemons themselves we can start them all at the same time, and they are able to connect to each other's sockets right-away. Syslog D-bus service socket
  • 32. 3. Boot process with systemd • a number of other benefits - no longer need to configure dependencies. - If a service dies its listening socket stays around, not losing a message. - Not a single connection is lost during the upgrade. - We can even replace a service during runtime in a way that is invisible to the client.
  • 33. 3. Boot process with systemd - Modern daemons on Linux tend to provide services via D-Bus instead of AF_UNIX sockets. - Using bus activation a service can be started the first time it is accessed. - Bus activation gives us the minimal per-request synchronisation we need for starting up the providers and the consumers of D-Bus services at the same time • Parallelizing Bus Service
  • 34. 3. Boot process with systemd CUPS Avahi CUPSAvahi D-Bus D-bus Queue If CUPS is quicker than Avahi via the bus activation logic we can get D- Bus to queue the request until Avahi manages to establish its service name. • Parallelizing Bus Service
  • 35. 3. Boot process with systemd - File-system related jobs: mounting, fscking, quota. - A lot of time is spent idling to wait until all devices that are listed in /etc/fstab show up in the device tree and are then fsck'ed, mounted, quota checked (if enabled). - After that is fully finished we go on and boot the actual services. - Improve this using the venerable autofs system. • Parallelizing File system
  • 36. 3. Boot process with systemd • Parallelizing File system - autofs - autofs is a program for automatically mounting directories on an as-needed basis. open() wait.. All Filesystem ready File 1 autofs Service A open() File 1 Service A All filesystem File system ready
  • 37. 3. Boot process with systemd • Parallelizing File system - autofs - This way we can begin starting our daemons even before all file systems have been fully made available -- without them missing any files, and maximizing parallelization.
  • 39. 4. Service Management • Service Management - For service management tasks, the target unit will be service units. - These are the most obvious kind of unit: daemons that can be started, stopped, restarted, reloaded
  • 40. 4. Service Management • Starting and Stopping Services - To start a systemd service, executing instructions in the service's unit file, use the start command. $sudo systemctl start application.service $sudo systemctl start application
  • 41. 4. Service Management • Starting and Stopping Services - To stop a currently running service, can use the stop command instead. $sudo systemctl stop application
  • 42. 4. Service Management • Restarting and Reloading - To restart a currently running service, can use the restart command. $sudo systemctl restart application.service
  • 43. 4. Service Management • Restarting and Reloading - If the application in question is able to reload its configuration files (without restarting), can issue the reload command to initiate that process: $sudo systemctl reload application.service
  • 44. 4. Service Management • Enabling and Disabling - To start services automatically at boot, must enable them. - This will create a symbolic link from the system's copy of the service file into the location on disk where systemd looks for autostart files $sudo systemctl enable application.service
  • 45. 4. Service Management • Enabling and Disabling - To disable the service from starting automatically. - This will remove the symbolic link that indicated that the service should be started automatically. $sudo systemctl disable application.service
  • 46. 4. Service Management • Checking the Status of Services - To check the status of a service on your system, you can use the status command. $systemctl status application.service
  • 47. 4. Service Management • Listing Current Units - To see a list of all of the active units that systemd knows about, we can use the list-units command. $systemctl list-units
  • 48. 4. Service Management • Listing Current Units - The output has the following columns. UNIT The systemd unit name. LOAD Whether the unit's configuration has been parsed by systemd. ACTIVE A summary state about whether the unit is active. SUB This is a lower-level state that indicates more detailed information about the unit. DESCRIPTION A short textual description of what the unit is/does.
  • 50. 5. Resource management • Cgroup - According to the Linux kernel documentation : "Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour.“ - cgroups is a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes.
  • 51. 5. Resource management • Cgroup - Isolate a set of processes that tend to manage resource consumption, restricting resource use to a preconfigured limit. - Assign sufficient memory or processing resources. - Allocate network or storage bandwidth. - Track assigned resources. - Restrict device access to specific users or groups
  • 53. 5. Resource management • systemd’s Resource Control Concepts - systemd organizes processes with cgroups. - systemd provides three unit types that are useful for the purpose of resource control. Service a number of processes that are started and stopped by systemd based on configuration. Scope a number of processes that are started and stopped by arbitrary processes via fork(), and then registered at runtime with PID1. Slices be used to group a number of services and scopes together in a hierarchical tree.
  • 54. 5. Resource management • systemd’s Resource Control Concepts - Service, scope and slice units directly map to objects in the cgroup tree.
  • 55. 5. Resource management • Previously, with sysVinit - No tracking of which service started which processes. - Hard to completely terminate a service. - No resources limitation, which is per-process, not per-service.
  • 56. 5. Resource management • Cgroup and Systemd - Tracking and killing all processes created by each service. - Per-service accounting and resources allocation/limitation. - Isolate user sessions – Kill all user processes.
  • 57. - A central part of a system that starts up and maintains services should be process babysitting. - It should watch services. - If they crash it should collect information about them. • Keeping Track of Processes 5. Resource management
  • 59. 6. Log management • Log management mechanism of systemd - systemd intercepts messages to stdout/stderr and rsyslogd - The message are sent to its own logging service. - “systemd-journald.service” or “journald”
  • 60. 6. Log management • Traditional system log flow Process /dev/log rsyslogd
  • 61. 6. Log management • System log flow under systemd Process /dev/log systemd /run/systemd/journal/syslog rsyslogd
  • 62. 6. Log management • Imjournal: Systemd Journal Input Module Process /dev/log systemd /run/systemd/journal/syslog rsyslogd - The latest rsyslogd can directly access journald’s database using ‘imjournal’ module.
  • 63. 6. Log management • Journal - systemd has its own logging system called the journal - Show all messages from this boot : $ journalctl -b - Show all messages from date : $ journalctl --since="2016-01-30 18:17:16"
  • 64. 6. Log management • Journal - Show all messages since 20 minutes ago : $ journalctl --since "20 min ago" - Follow new messages : $ journalctl -f - Show all messages by a specific executable : $ journalctl /usr/lib/systemd/systemd
  • 65. 6. Log management • Journal - Show all messages by a specific process : $ journalctl _PID=1 - Show all messages by a specific unit : $ journalctl -u netcfg - Show kernel ring buffer : $ journalctl -k
  • 67. 7. Systemd Snapshots • Systemd Snapshots - Snapshots can be used to save or rollback the state of all services and units of the system. - Systemd snapshots have two inteded use cases : To allow a user to temporarily enter a specific state such as “Emergency Shell”, terminating current services, and provide an easy way to return to the state before, pulling up all services again that got temporarily pulled down.
  • 68. 7. Systemd Snapshots • Systemd Snapshots - Snapshot units are not configured via unit configuration files. - A unit whose name ends in ".snapshot" refers to a dynamic snapshot of the systemd runtime state. - Snapshots are not configured on disk but created dynamically. $ systemd snapshot name
  • 69. 7. Systemd Snapshots • Systemd Snapshots - When created, they will automatically get dependencies on the currently activated units. - They act as saved runtime state of the systemd manager.
  • 71. 8. Target • Target - systemd uses targets which serve a similar purpose as runlevels. - Each target is named instead of numbered and is intended to serve a specific purpose with the possibility of having multiple ones active at the same time. - Get current targets : $systemctl list-units –type=target
  • 73. 8. Target • Target - The standard target is default.target, which is aliased by default to graphical.target. - Change current target : - This will only change the current target, and has no effect on the next boot. $systemctl isolate xxx.target
  • 74. 8. Target • Target - Leave the bootloader alone and change default.target. This can be done using systemctl: $systemctl set-default xxx.target
  • 75. • Power management - Shut down and reboot the system: $systemctl reboot - Shut down and power-off the system : $systemctl poweroff 8. Target
  • 76. 8. Target • Power management - Suspend the system : $systemctl suspend - Put the system into hibernation $systemctl hibernate - Put the system into hybrid-sleep state(or suspend-to both) $systemctl hybrid-sleep
  • 78. 9. Timer • Timer - Although cron is arguably the most well-known job scheduler, systemd timers can be an alternative. - Monotonic timers : activate after a time span relative to a varying starting point. - Realtime timers : activate on a calendar event (like cronjobs).
  • 79. 9. Timer • Timer - To view all started timers : $systemctl list-timers
  • 80. 9. Timer • Timer benefits - Jobs can be easily started independently of their timers. - Each job can be configured to run in a specific environment. - Jobs can be attached to cgroups. - Jobs can be set up to depend on other systemd units. - Jobs are logged in the systemd journal for easy debugging.
  • 81. 9. Timer • Example - Monotonic timer : A timer which will start 15 minutes after boot and again every week while the system is running. [Unit] Description=Run foo weekly and on boot [Timer] OnBootSec=15min OnUnitActiveSec=1w [Install] WantedBy=timers.target
  • 82. 9. Timer • Example - Realtime timer : A timer which starts once a week (at 12:00am on Monday). [Unit] Description=Run foo weekly [Timer] OnCalendar=weekly Persistent=true [Install] WantedBy=timers.target
  • 83. Q & A
  • 85. 참고 정보 - Your first dive into systemd | Etsufi Nakai - Systemd with RHEL 7 | 박현익 - https://fedoraproject.org/wiki/Packaging:Systemd - http://0pointer.de/blog/projects/systemd.html - http://linoxide.com/linux-how-to/systemd-boot-process/ - https://www.digitalocean.com/community/tutorials/understanding-systemd-units- and-unit-files - http://blog.fpmurphy.com/2013/09/systemd-snapshots.html#ixzz46tOBI500
  • 87. • [Unit type] Section Appendix
  • 89. • [Service] Section - simple: The main process of the service is specified in the start line. This is the default if the Type= and Busname= directives are not set, but the ExecStart= is set. Any communication should be handled outside of the unit through a second unit of the appropriate type (like through a .socket unit if this unit must communicate using sockets). - forking: This service type is used when the service forks a child process, exiting the parent process almost immediately. This tells systemd that the process is still running even though the parent exited. - oneshot: This type indicates that the process will be short-lived and that systemd should wait for the process to exit before continuing on with other units. This is the default Type= and ExecStart= are not set. It is used for one-off tasks. Appendix
  • 90. • [Service] Section - dbus: This indicates that unit will take a name on the D-Bus bus. When this happens, systemd will continue to process the next unit. - notify: This indicates that the service will issue a notification when it has finished starting up. The systemd process will wait for this to happen before proceeding to other units. - idle: This indicates that the service will not be run until all jobs are dispatched. - RemainAfterExit=: This directive is commonly used with the oneshot type. It indicates that the service should be considered active even after the process exits. - PIDFile=: If the service type is marked as "forking", this directive is used to set the path of the file that should contain the process ID number of the main child that should be monitored. Appendix
  • 91. • [Service] Section - BusName=: This directive should be set to the D-Bus bus name that the service will attempt to acquire when using the "dbus" service type. - NotifyAccess=: This specifies access to the socket that should be used to listen for notifications when the "notify" service type is selected This can be "none", "main", or "all. The default, "none", ignores all status messages. The "main" option will listen to messages from the main process and the "all" option will cause all members of the service's control group to be processed. - ExecStart=: This specifies the full path and the arguments of the command to be executed to start the process. This may only be specified once (except for "oneshot" services). If the path to the command is preceded by a dash "-" character, non-zero exit statuses will be accepted without marking the unit activation as failed. Appendix
  • 92. • [Service] Section - ExecStartPre=: This can be used to provide additional commands that should be executed before the main process is started. This can be used multiple times. Again, commands must specify a full path and they can be preceded by "-" to indicate that the failure of the command will be tolerated. - ExecStartPost=: This has the same exact qualities as ExecStartPre= except that it specifies commands that will be run after the main process is started. - ExecReload=: This optional directive indicates the command necessary to reload the configuration of the service if available. - ExecStop=: This indicates the command needed to stop the service. If this is not given, the process will be killed immediately when the service is stopped. Appendix
  • 93. • [Service] Section - ExecStopPost=: This can be used to specify commands to execute following the stop command. - RestartSec=: If automatically restarting the service is enabled, this specifies the amount of time to wait before attempting to restart the service. - Restart=: This indicates the circumstances under which systemd will attempt to automatically restart the service. This can be set to values like "always", "on-success", "on-failure", "on-abnormal", "on-abort", or "on-watchdog". These will trigger a restart according to the way that the service was stopped. - TimeoutSec=: This configures the amount of time that systemd will wait when stopping or stopping the service before marking it as failed or forcefully killing it. You can set separate timeouts with TimeoutStartSec= and TimeoutStopSec= as well. Appendix
  • 94. • [Socket] Section - ListenStream=: This defines an address for a stream socket which supports sequential, reliable communication. Services that use TCP should use this socket type. - ListenDatagram=: This defines an address for a datagram socket which supports fast, unreliable communication packets. Services that use UDP should set this socket type. - ListenSequentialPacket=: This defines an address for sequential, reliable communication with max length datagrams that preserves message boundaries. This is found most often for Unix sockets. - ListenFIFO: Along with the other listening types, you can also specify a FIFO buffer instead of a socket. Appendix
  • 95. • [Socket] Section - Accept=: This determines whether an additional instance of the service will be started for each connection. If set to false (the default), one instance will handle all connections. - SocketUser=: With a Unix socket, specifies the owner of the socket. This will be the root user if left unset. - SocketGroup=: With a Unix socket, specifies the group owner of the socket. This will be the root group if neither this or the above are set. If only the SocketUser= is set, systemd will try to find a matching group. - SocketMode=: For Unix sockets or FIFO buffers, this sets the permissions on the created entity. - Service=: If the service name does not match the .socket name, the service can be specified with this directive. Appendix
  • 96. • [Mount] Section - What=: The absolute path to the resource that needs to be mounted. - Where=: The absolute path of the mount point where the resource should be mounted. This should be the same as the unit file name, except using conventional filesystem notation. - Type=: The filesystem type of the mount. - Options=: Any mount options that need to be applied. This is a comma-separated list. - SloppyOptions=: A boolean that determines whether the mount will fail if there is an unrecognized mount option. - DirectoryMode=: If parent directories need to be created for the mount point, this determines the permission mode of these directories. - TimeoutSec=: Configures the amount of time the system will wait until the mount operation is marked as failed. Appendix
  • 97. • [Automount] Section - Where=: The absolute path of the automount point on the filesystem. This will match the filename except that it uses conventional path notation instead of the translation. - DirectoryMode=: If the automount point or any parent directories need to be created, this will determine the permissions settings of those path components. Appendix
  • 98. • [Swap] Section - What=: The absolute path to the location of the swap space, whether this is a file or a device. - Priority=: This takes an integer that indicates the priority of the swap being configured. - Options=: Any options that are typically set in the /etc/fstab file can be set with this directive instead. A comma-separated list is used. - TimeoutSec=: The amount of time that systemd waits for the swap to be activated before marking the operation as a failure. Appendix
  • 99. • [Path] Section - PathExists=: This directive is used to check whether the path in question exists. If it does, the associated unit is activated. - PathExistsGlob=: This is the same as the above, but supports file glob expressions for determining path existence. - PathChanged=: This watches the path location for changes. The associated unit is activated if a change is detected when the watched file is closed. - PathModified=: This watches for changes like the above directive, but it activates on file writes as well as when the file is closed. - DirectoryNotEmpty=: This directive allows systemd to activate the associated unit when the directory is no longer empty. Appendix
  • 100. • [Path] Section - Unit=: This specifies the unit to activate when the path conditions specified above are met. If this is omitted, systemd will look for a .service file that shares the same base unit name as this unit. - MakeDirectory=: This determines if systemd will create the directory structure of the path in question prior to watching. - DirectoryMode=: If the above is enabled, this will set the permission mode of any path components that must be created. Appendix
  • 101. • [Timer] Section - OnActiveSec=: This directive allows the associated unit to be activated relative to the .timer unit's activation. - OnBootSec=: This directive is used to specify the amount of time after the system is booted when the associated unit should be activated. - OnStartupSec=: This directive is similar to the above timer, but in relation to when the systemd process itself was started. - OnUnitActiveSec=: This sets a timer according to when the associated unit was last activated. - OnUnitInactiveSec=: This sets the timer in relation to when the associated unit was last marked as inactive. - OnCalendar=: This allows you to activate the associated unit by specifying an absolute instead of relative to an event. Appendix
  • 102. • [Timer] Section - AccuracySec=: This unit is used to set the level of accuracy with which the timer should be adhered to. By default, the associated unit will be activated within one minute of the timer being reached. The value of this directive will determine the upper bounds on the window in which systemd schedules the activation to occur. - Unit=: This directive is used to specify the unit that should be activated when the timer elapses. If unset, systemd will look for a .service unit with a name that matches this unit. - Persistent=: If this is set, systemd will trigger the associated unit when the timer becomes active if it would have been triggered during the period in which the timer was inactive. - WakeSystem=: Setting this directive allows you to wake a system from suspend if the timer is reached when in that state. Appendix

Editor's Notes

  1. 개별 데몬으로부터 중복된 기능을 추출하고, systemd core 또는 Linux Kernel로 이동시키자!
  2. 병렬성 제공 서비스 시작을 위해 socket / D-Bus Actication을 사용하며, 주문형? 원하는 데몬을 제공하고 의존성 있는 서비스를 제어하기 위한 로직 구현, cgroup을 이용한 processes 추적과 snapshotting and restoring 지원 mount, automount 포인트 유지
  3. systemd는 unit 개념을 기반으로 하고 있다. units 은 name과 type을 가지고 있으며,
  4. systemd는 unit 개념을 기반으로 하고 있따. units 은 name과 type을 가지고 있으며,
  5. .service: A service unit describes how to manage a service or application on the server. This will include how to start or stop the service, under which circumstances it should be automatically started, and the dependency and ordering information for related software. .socket: A socket unit file describes a network or IPC socket, or a FIFO buffer that systemd uses for socket-based activation. These always have an associated .service file that will be started when activity is seen on the socket that this unit defines. .device: A unit that describes a device that has been designated as needing systemd management by udev or the sysfs filesystem. Not all devices will have .device files. Some scenarios where.device units may be necessary are for ordering, mounting, and accessing the devices. .mount: This unit defines a mountpoint on the system to be managed by systemd. These are named after the mount path, with slashes changed to dashes. Entries within /etc/fstab can have units created automatically. .automount: An .automount unit configures a mountpoint that will be automatically mounted. These must be named after the mount point they refer to and must have a matching .mount unit to define the specifics of the mount. .swap: This unit describes swap space on the system. The name of these units must reflect the device or file path of the space.
  6. .target: A target unit is used to provide synchronization points for other units when booting up or changing states. They also can be used to bring the system to a new state. Other units specify their relation to targets to become tied to the target's operations. .timer: A .timer unit defines a timer that will be managed by systemd, similar to a cron job for delayed or scheduled activation. A matching unit will be started when the timer is reached. .snapshot: A .snapshot unit is created automatically by the systemctl snapshot command. It allows you to reconstruct the current state of the system after making changes. Snapshots do not survive across sessions and are used to roll back temporary states. .slice: A .slice unit is associated with Linux Control Group nodes, allowing resources to be restricted or assigned to any processes associated with the slice. The name reflects its hierarchical position within the cgroup tree. Units are placed in certain slices by default depending on their type. .scope: Scope units are created automatically by systemd from information received from its bus interfaces. These are used to manage sets of system processes that are created externally.
  7. Section names are well defined and case-sensitive. So, the section [Unit] will not be interpreted correctly if it is spelled like [UNIT]. If you need to add non-standard sections to be parsed by applications other than systemd, you can add a X- prefix to the section name. Within these sections, unit behavior and metadata is defined through the use of simple directives using a key-value format with assignment indicated by an equal sign
  8. Unit Section - The first section found in most unit files is the [Unit] section. This is generally used for defining metadata for the unit and configuring the relationship of the unit to other units. Install Section This section is optional and is used to define the behavior or a unit if it is enabled or disabled. In essence, this is accomplished by latching the unit in question onto another unit that is somewhere in the line of units to be started at boot.
  9. Various tasks in the SysVinit’s system initializeation scripts are extracted and defined as independent ‘Unit’ SysVinit 시스템의 초기화 스크립트 내에 작성된 여러 작업들을 독립적인 Unit으로 추출하여 분리함.
  10. 1.  The very first steps when you power on your system is the  BIOS initialization. BIOS reads the boot device settings, locates and hands over control to MBR (assuming hard disk is set as first boot device). 2.  MBR reads information from Grub or LILO boot loader and initializes the kernel.  Grub or LILO will specify how to handle further system boot up. If you have specified systemd as boot manager in grub configuration file, then the further boot process will be handled by systemd. Systemd handles boot and services management process using “targets”. The ”target" files in systemd are used for grouping different boot units and start up synchronization processes. 3.  The very first target executed by systemd is default.target. But default.target is actually a symlink to graphical.target. Graphical.target file is located at /usr/lib/systemd/system/graphical.target path. We have shown the contents of graphical.target file in the following screenshot.
  11. 4. At this stage, multi-user.target has been invoked and  this target keeps its further sub-units inside  “/etc/systemd/system/multi-user.target.wants” directory. This target sets the environment for multi user support. None root users are enabled at this stage of boot up process. Firewall related services are started on this stage of boot as well.
  12. 5. "basic.target" unit is the one that starts usual services specially graphical manager service. It uses /etc/systemd/system/basic.target.wants directory to decide which services need to be started, basic.target passes on control to sysinit.target. 6. "sysinit.target" starts important system services like file System mounting, swap spaces and devices, kernel additional options etc. sysinit.target passes on startup process to local-fs.target. The contents of this target unit are shown in the following screenshot.
  13. Various tasks in the SysVinit’s system initializeation scripts are extracted and defined as independent ‘Unit’ SysVinit 시스템의 초기화 스크립트 내에 작성된 여러 작업들을 독립적인 Unit으로 추출하여 분리함.
  14. Consider the four services Syslog, D-Bus, Avahi and the Bluetooth daemon. D-Bus logs to Syslog, hence on traditional Linux systems it would get started after Syslog. Similarly, Avahi requires Syslog and D-Bus, hence would get started after both. Finally Bluetooth is similar to Avahi and also requires Syslog and D-Bus but does not interface at all with Avahi. Sinceoin a traditional SysV-based system only one service can be in the process of getting started at a time, the following serialization of startup would take place: Syslog → D-Bus → Avahi → Bluetooth (Of course, Avahi and Bluetooth could be started in the opposite order too, but we have to pick one here, so let's simply go alphabetically.).
  15. Certain distributions tried to improve this strictly serialized start-up: since Avahi and Bluetooth are independent from each other, they can be started simultaneously. The parallelization is increased, the overall startup time slightly smaller. (This is visualized in the middle part of the plot.)
  16. Socket activation makes it possible to start all four services completely simultaneously, without any kind of ordering. Since the creation of the listening sockets is moved outside of the daemons themselves we can start them all at the same time, and they are able to connect to each other's sockets right-away. I.e. in a single step the /dev/log and /run/dbus/system_bus_socket sockets are created, and in the next step all four services are spawned simultaneously. When D-Bus then wants to log to syslog, it just writes its messages to /dev/log. As long as the socket buffer does not run full it can go on immediately with what else it wants to do for initialization. As soon as the syslog service catches up it will process the queued messages. And if the socket buffer runs full then the client logging will temporarily block until the socket is writable again, and continue the moment it can write its log messages. That means the scheduling of our services is entirely done by the kernel: from the userspace perspective all services are run at the same time, and when one service cannot keep up the others needing it will temporarily block on their request but go on as soon as these requests are dispatched. All of this is completely automatic and invisible to userspace. Socket activation hence allows us to drastically parallelize start-up, enabling simultaneous start-up of services which previously were thought to strictly require serialization. Most Linux services use sockets as communication channel. Socket activation allows starting of clients and servers of these channels at the same time.
  17. 더 이상 디펜던시를 설정할 필요가 없다. 왜냐면, 동시에 실행되기 때문이다 서비스가 종료되더라도 이 서비스의 소켓은 그대로 존재하므로 메시지 손실이 없습니다. 다시 서비스가 재시작 후 지속적으로 동작할 수 있습니다. 서비스가 업그레이드 되는 동안에도 연결이 끊어지지 않습니다. 클라이언트가 알지 모소하게 서비스를 재시작 할 수 있습니다. ( systemd log daemon 예시) We no longer need to configure dependencies explicitly. Since the sockets are initialized before all services they are simply available, and no userspace ordering of service start-up needs to take place anymore. Socket activation hence drastically simplifies configuration and development of services. If a service dies its listening socket stays around, not losing a single message. After a restart of the crashed service it can continue right where it left off. If a service is upgraded we can restart the service while keeping around its sockets, thus ensuring the service is continously responsive. Not a single connection is lost during the upgrade. We can even replace a service during runtime in a way that is invisible to the client. For example, all systems running systemd start up with a tiny syslog daemon at boot which passes all log messages written to /dev/log on to the kernel message buffer. That way we provide reliable userspace logging starting from the first instant of boot-up. Then, when the actual rsyslog daemon is ready to start we terminate the mini daemon and replace it with the real daemon. And all that while keeping around the original logging socket and sharing it between the two daemons and not losing a single message. Since rsyslog flushes the kernel log buffer to disk after start-up all log messages from the kernel, from early-boot and from runtime end up on disk.
  18. Modern daemons on Linux tend to provide services via D-Bus instead of plain AF_UNIX sockets. Now, the question is, for those services, can we apply the same parallelizing boot logic as for traditional socket services? Yes, we can, D-Bus already has all the right hooks for it: using bus activation a service can be started the first time it is accessed. Bus activation also gives us the minimal per-request synchronisation we need for starting up the providers and the consumers of D-Bus services at the same time:
  19. : if we want to start Avahi at the same time as CUPS (side note: CUPS uses Avahi to browse for mDNS/DNS-SD printers), then we can simply run them at the same time, and if CUPS is quicker than Avahi via the bus activation logic we can get D-Bus to queue the request until Avahi manages to establish its service name. So, in summary: the socket-based service activation and the bus-based service activation together enable us to start all daemons in parallel, without any further synchronization. Activation also allows us to do lazy-loading of services: if a service is rarely used, we can just load it the first time somebody accesses the socket or bus name, instead of starting it during boot.
  20. there are more synchronisation points than just daemon start-ups: most prominently there are file-system related jobs: mounting, fscking, quota. Right now, on boot-up a lot of time is spent idling to wait until all devices that are listed in /etc/fstab show up in the device tree and are then fsck'ed, mounted, quota checked (if enabled). Only after that is fully finished we go on and boot the actual services.
  21. autofs is a program for automatically mounting directories on an as-needed basis. Auto-mounts are mounted only as they are accessed, and are unmounted after a period of inactivity. Because of this, automounting NFS/Samba shares conserves bandwidth and offers better overall performance compared to static mounts via fstab. Just like a connect() call shows that a service is interested in another service, an open() (or a similar call) shows that a service is interested in a specific file or file-system. So, in order to improve how much we can parallelize we can make those apps wait only if a file-system they are looking for is not yet mounted and readily available: we set up an autofs mount point, and then when our file-system finished fsck and quota due to normal boot-up we replace it by the real mount. While the file-system is not ready yet, the access will be queued by the kernel and the accessing process will block, but only that one daemon and only that one access. And this way we can begin starting our daemons even before all file systems have been fully made available -- without them missing any files, and maximizing parallelization.
  22. Just like a connect() call shows that a service is interested in another service, an open() (or a similar call) shows that a service is interested in a specific file or file-system. So, in order to improve how much we can parallelize we can make those apps wait only if a file-system they are looking for is not yet mounted and readily available: we set up an autofs mount point, and then when our file-system finished fsck and quota due to normal boot-up we replace it by the real mount. While the file-system is not ready yet, the access will be queued by the kernel and the accessing process will block, but only that one daemon and only that one access. And this way we can begin starting our daemons even before all file systems have been fully made available -- without them missing any files, and maximizing parallelization.
  23. For service management tasks, the target unit will be service units, which have unit files with a suffix of .service. However, for most service management commands, you can actually leave off the .service suffix, as systemd is smart enough to know that you probably want to operate on a service when using service management commands.
  24. This will create a symbolic link from the system's copy of the service file (usually in /lib/systemd/system or/etc/systemd/system) into the location on disk where systemd looks for autostart files (usually/etc/systemd/system/some_target.target.wants. We will go over what a target is later in this guide).
  25. Keep in mind that enabling a service does not start it in the current session. If you wish to start the service and enable it at boot, you will have to issue both the start and enable commands.
  26. This will provide you with the service state, the cgroup hierarchy, and the first few log lines.
  27. UNIT: The systemd unit name LOAD: Whether the unit's configuration has been parsed by systemd. The configuration of loaded units is kept in memory. ACTIVE: A summary state about whether the unit is active. This is usually a fairly basic way to tell if the unit has started successfully or not. SUB: This is a lower-level state that indicates more detailed information about the unit. This often varies by unit type, state, and the actual method in which the unit runs. DESCRIPTION: A short textual description of what the unit is/does.
  28. Cgroup은 테스크들의 합쳐지거나, 분할된 셋을 위한 메커니즘을 제공하는데요, According to the Linux kernel documentation, "Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour." This "behaviour" is defined by kernel subsystems—the actual resource controllers—that allocate system resources, track usage, and impose limits. Processes assigned to each group are then subject to the defined set of resource control parameters. An administrator assigns specific processes or system services to each group, adjusting resource parameters for the process group as needed.
  29. 프로세스 셋을 독립시키다. In practice, an administrator can use cgroups to: Isolate a set of processes that tend to dominate resource consumption, restricting resource use to a preconfigured limit Assign sufficient memory or processing resources (either by specific nodes or relative shares) for an application or set of applications Allocate network or storage bandwidth (I/O throttling) Track assigned resources Restrict device access to specific users or groups (device whitelisting)
  30. Scpoes는 시스템 프로세스에 등록된 프로세스들의 집합 Services encapsulate a number of processes that are started and stopped by systemd based on configuration. Services are named in the style of quux.service. Scopes encapsulate a number of processes that are started and stopped by arbitrary processes via fork(), and then registered at runtime with PID1. Scopes are named in the style of wuff.scope. Slices may be used to group a number of services and scopes together in a hierarchial tree. Slices do not contain processes themselves, but the services and slices contained in them do. Slices are named in the style of foobar-waldo.slice, where the path to the location of the slice in the tree is encoded in the name with "-" as separator for the path components (foobar-waldo.slice is hence a subslice of foobar.slice). There's one special slices defined, -.slice, which is the root slice of all slices (foobar.slice is hence subslice of -.slice). This is similar how in regular file paths, "/" denotes the root directory.
  31. A central part of a system that starts up and maintains services should be process babysitting: it should watch services. Restart them if they shut down. If they crash it should collect information about them, and keep it around for the administrator, and cross-link that information with what is available from crash dump systems such as abrt, and in logging systems like syslog or the audit system.
  32. systemd intercepts messages to stdout/stderr and rsyslogd from daemon processes which have been started as service units. The messages are sent to its own logging service “systemd-journald.service” or “journald” in short
  33. In the traditional environment, rsyslod receives processes’s system log messages through the unix socket ‘/dev/log’.
  34. rsyslogd should be configured accordingly. Under the systemd environment, systemd receives messages from ‘/dev/log’ and send it again to ‘/run/systemd/journal/syslog/syslog’. So rsyslogd needs to receive it through ‘/run/systemd/journal/syslog/syslog’.
  35. However, often one is interested in messages not from the current, but from the previous boot (e.g. if an unrecoverable system crash happened). This is possible through optional offset parameter of the -b flag: journalctl -b -0 shows messages from the current boot, journalctl -b -1 from the previous boot, journalctl -b -2 from the second previous and so on. See man 1 journalctl for full description, the semantics is much more powerful.
  36. However, often one is interested in messages not from the current, but from the previous boot (e.g. if an unrecoverable system crash happened). This is possible through optional offset parameter of the -b flag: journalctl -b -0 shows messages from the current boot, journalctl -b -1 from the previous boot, journalctl -b -2 from the second previous and so on. See man 1 journalctl for full description, the semantics is much more powerful.
  37. However, often one is interested in messages not from the current, but from the previous boot (e.g. if an unrecoverable system crash happened). This is possible through optional offset parameter of the -b flag: journalctl -b -0 shows messages from the current boot, journalctl -b -1 from the previous boot, journalctl -b -2 from the second previous and so on. See man 1 journalctl for full description, the semantics is much more powerful.
  38. Snapshot units are similar to target units in that they do not actually do anything themselves and their only purpose is to reference other units. Snapshots can be used to save or rollback the state of all services and units of the system. According to Pottering, systemd snapshots have two intended use cases: To allow a user to temporarily enter a specific state such as “Emergency Shell”, terminating current services, and provide an easy way to return to the state before, pulling up all services again that got temporarily pulled down.
  39. Snapshot units are not configured via unit configuration files. Nonetheless they are named similar to filenames. A unit whose name ends in ".snapshot" refers to a dynamic snapshot of the systemd runtime state. Snapshots are not configured on disk but created dynamically via systemctl snapshot (see systemctl(1) for details) or an equivalent command. When created, they will automatically get dependencies on the currently activated units. They act as saved runtime state of the systemd manager. Later on, the user may choose to return to the saved state via systemctl isolate. They are useful to roll back to a defined state after temporarily starting/stopping services or similar.
  40. Snapshot units are not configured via unit configuration files. Nonetheless they are named similar to filenames. A unit whose name ends in ".snapshot" refers to a dynamic snapshot of the systemd runtime state. Snapshots are not configured on disk but created dynamically via systemctl snapshot (see systemctl(1) for details) or an equivalent command. When created, they will automatically get dependencies on the currently activated units. They act as saved runtime state of the systemd manager. Later on, the user may choose to return to the saved state via systemctl isolate. They are useful to roll back to a defined state after temporarily starting/stopping services or similar.
  41. systemd uses targets which serve a similar purpose as runlevels but act a little different. Each target is named instead of numbered and is intended to serve a specific purpose with the possibility of having multiple ones active at the same time. Some targets are implemented by inheriting all of the services of another target and adding additional services to it. There are systemd targets that mimic the common SystemVinit runlevels so you can still switch targets using the familiar telinit RUNLEVEL command.
  42. Timers are systemd unit files with a suffix of .timer. Timers are like other unit configuration files and are loaded from the same paths but include a [Timer] section. The [Timer] section defines when and how the timer activates. Timers are defined as one of two types: Monotonic timers activate after a time span relative to a varying starting point. There are number of different monotonic timers but all have the form of: OnTypeSec=. OnBootSec and OnActiveSec are common monotonic timers. Realtime timers (a.k.a. wallclock timers) activate on a calendar event (like cronjobs). The option OnCalendar= is used to define them.
  43. The main benefits of using timers come from each job having its own systemd service. Some of these benefits are: Jobs can be easily started independently of their timers. This simplifies debugging. Each job can be configured to run in a specific environment (see the systemd.exec(5) man page). Jobs can be attached to cgroups. Jobs can be set up to depend on other systemd units. Jobs are logged in the systemd journal for easy debugging.
  44. A timer which starts once a week (at 12:00am on Monday). It starts once immediately if it missed the last start time (option Persistent=true), for example due to the system being powered off:
  45. Description=: This directive can be used to describe the name and basic functionality of the unit. It is returned by various systemd tools, so it is good to set this to something short, specific, and informative. Documentation=: This directive provides a location for a list of URIs for documentation. These can be either internally available man pages or web accessible URLs. The systemctl status command will expose this information, allowing for easy discoverability. Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default. Wants=: This directive is similar to Requires=, but less strict. Systemd will attempt to start any units listed here when this unit is activated. If these units are not found or fail to start, the current unit will continue to function. This is the recommended way to configure most dependency relationships. Again, this implies a parallel activation unless modified by other directives. BindsTo=: This directive is similar to Requires=, but also causes the current unit to stop when the associated unit terminates. Before=: The units listed in this directive will not be started until the current unit is marked as started if they are activated at the same time. This does not imply a dependency relationship and must be used in conjunction with one of the above directives if this is desired. After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required. Conflicts=: This can be used to list units that cannot be run at the same time as the current unit. Starting a unit with this relationship will cause the other units to be stopped. Condition...=: There are a number of directives that start with Condition which allow the administrator to test certain conditions prior to starting the unit. This can be used to provide a generic unit file that will only be run when on appropriate systems. If the condition is not met, the unit is gracefully skipped. Assert...=: Similar to the directives that start with Condition, these directives check for different aspects of the running environment to decide whether the unit should activate. However, unlike theCondition directives, a negative result causes a failure with this directive.