Oracle Linux 8 - Managing Core System Configuration (OL8-OSMANAGE)
Oracle Linux 8 - Managing Core System Configuration (OL8-OSMANAGE)
F21492-26
May 2024
Oracle Linux 8 Managing Core System Configuration,
F21492-26
iii
About Service Unit Files 2-12
Configurable Options in Service Unit Files 2-12
Creating a User-Based systemd Service 2-15
Using Timer Units to Control Service Unit Runtime 2-16
Configuring a Realtime Timer Unit 2-16
Configuring a Monotonic Timer Unit 2-17
Running a Transient Timer Unit 2-18
iv
About Weak Update Modules 5-7
7 Managing Resources
About Control Groups 7-1
About Kernel Resource Controllers 7-2
About the Control Group File System 7-3
About Control Groups and systemd 7-4
About Resource Distribution Models 7-5
Using cgroups v2 to Manage Resources for Applications 7-6
Enabling cgroups v2 7-6
Preparing the Control Group for Distribution of CPU Time 7-7
Setting CPU Weight to Regulate Distribution of CPU Time 7-8
Using systemd to Manage cgroups v2 7-10
About Slices and Resource Allocation in systemd 7-11
Slices, Services, and Scopes in the cgroup Hierarchy 7-13
systemd Scopes 7-15
Setting Resource Controller Options and Creating Custom Slices 7-16
Using Service Unit Files 7-16
Using Drop-in Files 7-19
Using systemctl set-property 7-21
v
Using cgroups v2 to Manage Resources for Users 7-23
vi
Preface
Oracle Linux 8: Managing Core System Configuration provides information about configuring
Oracle Linux 8 systems, including the boot loader configuration and processes, system
devices, services and settings, as well as kernel parameters.
Documentation License
The content in this document is licensed under the Creative Commons Attribution–Share Alike
4.0 (CC-BY-SA) license. In accordance with CC-BY-SA, if you distribute this content or an
adaptation of it, you must provide attribution to Oracle and retain the original copyright notices.
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface
elements associated with an action, or terms
defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or
placeholder variables for which you supply
particular values.
monospace Monospace type indicates commands within a
paragraph, URLs, code in examples, text that
appears on the screen, or text that you enter.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility
Program website at https://www.oracle.com/corporate/accessibility/.
vii
Preface
mindful of the necessity to maintain compatibility with our customers' existing technologies and
the need to ensure continuity of service as Oracle's offerings and industry standards evolve.
Because of these technical constraints, our effort to remove insensitive terms is ongoing and
will take time and external cooperation.
viii
1
Managing Kernels and System Boot
This chapter describes the Oracle Linux boot process and how to configure and use the
GRand Unified Bootloader (GRUB) version 2 and boot-related kernel parameters.
Tip:
See Manage the Boot Kernel for Oracle Linux for a hands-on tutorial and video
demonstrations on configuring the boot kernel in Oracle Linux.
1-1
Chapter 1
About the GRUB 2 Bootloader
6. The kernel starts the systemd process with a process ID of 1 (PID 1). See About the
systemd Service Manager.
7. systemd runs any additional processes defined for it.
Note:
Specify any other actions to be processed during the boot process by defining
your own systemd unit. This method is the preferred approach than using
the /etc/rc.local file.
Note:
Specify any other actions to be processed during the boot process by defining
user systemd units. This method is the preferred approach than using the /etc/
rc.local file.
1-2
Chapter 1
About Linux Kernels
Note:
Don't edit the GRUB 2 configuration file directly.
The grub2-mkconfig command generates the configuration file using the template
scripts in /etc/grub.d and menu-configuration settings taken from the
configuration file, /etc/default/grub.
The default menu entry is set by the value of the GRUB_DEFAULT parameter in /etc/default/
grub. If GRUB_DEFAULT is set to saved, you can use the grub2-set-default and grub2-
reboot commands to specify the default entry. The command grub2-set-default sets the
default entry for all subsequent reboots, while grub2-reboot sets the default entry for the
next reboot only.
If you specify a numeric value as the value of GRUB_DEFAULT or as an argument to either
grub2-reboot or grub2-set-default, GRUB 2 counts the menu entries in the
configuration file starting at 0 for the first entry.
For more information about using, configuring, and customizing GRUB 2, see the GNU GRUB
Manual, which is also installed as /usr/share/doc/grub2-tools-2.00/grub.html.
1-3
Chapter 1
Managing Kernels in GRUB 2 Using grubby
Important:
Linux kernels are critical for running applications in the Oracle Linux user space.
Therefore, you must keep the kernel current with the latest bug fixes, enhancements,
and security updates provided by Oracle. To do so, implement a continuous update
and upgrade strategy. See Oracle Linux: Ksplice User's Guide for information on how
to keep the kernel updated without any requirement to reboot the system. See Oracle
Linux: Managing Software on Oracle Linux for general information about keeping
software on the system up-to-date.
See Unbreakable Enterprise Kernel documentation for more information about UEK.
Use the following command to display the kernels that are installed and configured on the
system:
You can also use the grubby command to update a kernel configuration entry to add or
remove kernel boot arguments, for example:
For more information about the grubby command, see the grubby(8) manual page.
For a hands-on tutorial on the use of grubby to manage kernels, see Manage the Boot Kernel
for Oracle Linux.
1-4
Chapter 1
Kernel Boot Parameters
Important:
Security scanners on the system might report CVEs for any kernel on the system
that's not used as the running or default kernel. As a good practice and to avoid
unnecessary noise and false positives that are being reported by the scanner,
remove unused kernels after you switch kernels.
For example, if you switch to RHCK from UEK, follow these steps to ensure a proper
transition:
1. Set the default kernel to RHCK with the appropriate grubby command.
See the preceding examples for the correct command syntax.
2. Reboot the system to ensure that you're now running RHCK.
3. Remove the UEK kernel.
Likewise, if you choose to use UEK as the standard kernel, consider removing
RHCK. For instructions to remove RHCK, see Remove the Red Hat Compatible
Kernel With the kernel-transition Package.
Option Description
0, 1, 2, 3, 4, 5, or 6, or Specifies the nearest systemd-equivalent
systemd.unit=runlevelN.target system-state target to match a legacy SysV run
level. N can take an integer value between 0
and 6.
Systemd maps system-state targets to mimic the
legacy SysV init system.
For a description of system-state targets, see
About System-State Targets.
1, s, S, single, or Specifies the rescue shell. The system boots to
systemd.unit=rescue.target single-user mode prompts for the root
password.
3 or systemd.unit=multi-user.target Specifies the systemd target for multiuser,
nongraphical login.
1-5
Chapter 1
Kernel Boot Parameters
Option Description
5 or systemd.unit=graphical.target Specifies the systemd target for multiuser,
graphical login.
-b, emergency, or Specifies emergency mode. The system boots to
systemd.unit=emergency.target single-user mode and prompts for the root
password. Fewer services are started than
when in rescue mode.
KEYBOARDTYPE=kbtype Specifies the keyboard type, which is written
to /etc/sysconfig/keyboard in the
initramfs.
KEYTABLE=kbtype Specifies the keyboard layout, which is written
to /etc/sysconfig/keyboard in the
initramfs.
LANG=language_territory.codeset Specifies the system language and code set,
which is written to /etc/sysconfig/i18n
in the initramfs.
max_loop=N Specifies the number of loop devices (/dev/
loop*) that are available for accessing files as
block devices. The default and maximum
values of N are 8 and 255.
nouptrack Disables Ksplice Uptrack updates from being
applied to the kernel.
quiet Reduces debugging output.
rd_LUKS_UUID=UUID Activates an encrypted Linux Unified Key Setup
(LUKS) partition with the specified UUID.
rd_LVM_VG=vg/lv_vol Specifies an LVM volume group and volume to
be activated.
rd_NO_LUKS Disables detection of an encrypted LUKS
partition.
rhgb Specifies to use the Red Hat graphical boot
display to indicate the progress of booting.
rn_NO_DM Disables Device-Mapper (DM) RAID detection.
rn_NO_MD Disables Multiple Device (MD) RAID detection.
ro root=/dev/mapper/vg-lv_root Specifies that the root file system is to be
mounted read-only, and specifies the root file
system by the device path of its LVM volume
(where vg is the name of the volume group).
rw root=UUID=UUID Specifies that the root (/) file system is to be
mounted read-writable at boot time, and
specifies the root partition by its UUID.
selinux=0 Disables SELinux.
SYSFONT=font Specifies the console font, which is written
to /etc/sysconfig/i18n in the initramfs.
1-6
Chapter 1
Modifying Kernel Boot Parameters Before Booting
The kernel boot parameters that were last used to boot a system are recorded in /proc/
cmdline, for example:
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-80.el8.x86_64 root=/dev/mapper/ol-root
ro \
crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/ol-swap
rd.lvm.lv=ol/root \
rd.lvm.lv=ol/swap rhgb quiet
GRUB_CMDLINE_LINUX="vconsole.font=latarcyrheb-sun16 vconsole.keymap=uk
crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.lvm.lv=ol/swap
rd.lvm.lv=ol/root biosdevname=0
rhgb quiet systemd.unit=runlevel3.target"
The change takes effect at the next system reboot of all configured kernels.
1-7
Chapter 1
Modifying GRUB 2 Default Kernel Boot Parameters
Note:
For systems that boot with UEFI, the grub.cfg file is located in the /
boot/efi/EFI/redhat directory because the boot configuration is stored on a
dedicated FAT32-formatted partition.
After the system has successfully booted, the EFI folder on that partition is mounted
inside the /boot/efi directory on the root file system for Oracle Linux.
1-8
2
Managing System Services With systemd
The systemd daemon is the system initialization and service manager in Oracle Linux. This
chapter describes how to use systemd to manage system processes, services and systemd
targets.
Tip:
See Use systemd on Oracle Linux for a hands-on tutorial and video demonstrations
on working with systemd in Oracle Linux.
The systemd daemon starts services during the boot process by reading the symbolic
link /etc/systemd/system/default.target. The following example shows the value
of /etc/systemd/system/default.target on a system configured to boot to a multiuser
mode without a graphical user interface, a target called multi-user.target:
sudo ls -l /etc/systemd/system/default.target
Note:
You can use a kernel boot parameter to override the default system target. See
Kernel Boot Parameters.
systemd Units
systemd organizes the different types of resources it manages into units. Most units are
configured in unit configuration files that enable you to configure these units according to
system needs. In addition to the files, you can also use systemd runtime commands to
configure the units.
2-1
Chapter 2
About the systemd Service Manager
The following list describes some system units that you can manage on an Oracle Linux
system by using systemd:
Services
Service unit configuration files have the filename format service_name.service, for example
sshd.service, crond.service, and httpd.service.
Service units start and control daemons and the processes of which the daemons consist.
The following example shows how you might start the systemd service unit for the Apache
HTTP server, httpd.service:
Targets
Target unit configuration files have the filename format target_name.target, for example
graphical.target.
Targets are similar to runlevels. A system reaches different targets during the boot process as
resources get configured. For example, a system reaches network-pre.target before it
reaches the target network-online.target.
Many target units have dependencies. For example, the activation of graphical.target (for a
graphical session) fails unless multi-user.target (for multiuser system) is also active.
Devices
Device unit configuration files have the filename format device_unit_name.device.
Device units are named after the /sys and /dev paths they control. For example, the
device /dev/sda5 is exposed in systemd as dev-sda5.device.
Device units enable you to implement device-based activation.
Sockets
Socket unit configuration files have the filename format socket_unit_name.socket.
Each "*.socket" file needs a corresponding "*.service" file to configure the service to start on
incoming traffic on the socket.
Socket units enable you to implement socket-based activation.
Timers
Timer unit configuration files have the filename format timer_unit_name.timer.
Each "*.timer" file needs a corresponding "*.service" file to configure the service to start at a
configured timer event. A Unit configuration entry can be used to specify a service that's
named differently to the timer unit, if required.
Timer units can control when service units are run and can act as an alternative to using the
cron daemon. Timer units can be configured for calendar time events, monotonic time events,
and can be run asynchronously.
Paths to systemd unit configuration files vary depending on their purpose and whether systemd
is running in 'user' or 'system' mode. For example, configuration for units that are installed from
packages might be available in /usr/lib/systemd/system or in /usr/local/lib/
systemd/system, while a user mode configuration unit is likely to be stored
in $HOME/.config/systemd/user. See the systemd.unit(5) manual page for more information.
2-2
Chapter 2
About System-State Targets
Table 2-1 shows the commonly used system-state targets and the equivalent runlevel targets.
graphical.target
2-3
Chapter 2
About System-State Targets
To display the active targets on a system, use the systemctl list-units --type
target command:
24 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
The output for a system with the graphical target active shows that this target depends on
other active targets, including network and sound to support networking and sound.
For more information, see the systemctl(1) and systemd.target(5) manual pages.
2-4
Chapter 2
About System-State Targets
Note:
Target is only one of systemd types of units. To display all the types of units, use the
following command:
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/
multi-user.target
Note:
This command changes the target to which the default target is linked, but doesn't
change the state of the system.
To change the current active system target, use the systemctl isolate command, for
example:
2-5
Chapter 2
Shutting Down, Suspending, and Rebooting the System
Managing Services
Services in an Oracle Linux system are managed by the systemctl subcommand command.
Examples of subcommands are enable, disable, stop, start, restart, reload, and status.
Changing the state of a service only lasts while the system remains at the same state. If you
stop a service and then change the system-state target to one in which the service is
configured to run (for example, by rebooting the system), the service restarts. Similarly, starting
a service doesn't enable the service to start following a reboot. See Enabling and Disabling
Services.
2-6
Chapter 2
Managing Services
The enable command activates a service by creating a symbolic link for the lowest-level
system-state target at which the service should start. In the previous example, the command
creates the symbolic link httpd.service for the multi-user target.
Removed /etc/systemd/system/multi-user.target.wants/httpd.service.
disabled
enabled
After running the systemctl disable command, the service can still be started or stopped
by user accounts, scripts, and other processes. However, if you need to ensure that the service
might be started inadvertently, for example, by a conflicting service, then use the systemctl
mask command as follows:
2-7
Chapter 2
Managing Services
The mask command sets the service reference to /dev/null. If you try to start a service that
has been masked, you will receive an error as shown in the following example:
To relink the service reference back to the matching service unit configuration file, use the
systemctl unmask command:
active
inactive
The status subcommand provides a detailed summary of the status of a service, including a
tree that displays the tasks in the control group (CGroup) that the service implements:
2-8
Chapter 2
Managing Services
A cgroup is a collection of processes that are bound together so that you can control their
access to system resources. In the example, the cgroup for the httpd service is
httpd.service, which is in the system slice.
Slices divide the cgroups on a system into different categories. To display the slice and cgroup
hierarchy, use the systemd-cgls command:
sudo systemd-cgls
Control group /:
-.slice
├─user.slice
│ └─user-1000.slice
│ ├─[email protected]
│ │ └─init.scope
│ │ ├─6488 /usr/lib/systemd/systemd --user
│ │ └─6492 (sd-pam)
│ └─session-7.scope
│ ├─6484 sshd: root [priv]
│ ├─6498 sshd: root@pts/0
│ ├─6499 -bash
│ ├─6524 sudo systemd-cgls
│ ├─6526 systemd-cgls
│ └─6527 less
├─init.scope
│ └─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 16
└─system.slice
├─rngd.service
│ └─1266 /sbin/rngd -f --fill-watermark=0
├─irqbalance.service
│ └─1247 /usr/sbin/irqbalance --foreground
├─libstoragemgmt.service
│ └─1201 /usr/bin/lsmd -d
├─systemd-udevd.service
│ └─1060 /usr/lib/systemd/systemd-udevd
├─polkit.service
│ └─1241 /usr/lib/polkit-1/polkitd --no-debug
├─chronyd.service
│ └─1249 /usr/sbin/chronyd
├─auditd.service
│ ├─1152 /sbin/auditd
│ └─1154 /usr/sbin/sedispatch
├─tuned.service
│ └─1382 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
├─systemd-journald.service
│ └─1027 /usr/lib/systemd/systemd-journald
├─atd.service
│ └─1812 /usr/sbin/atd -f
├─sshd.service
│ └─1781 /usr/sbin/sshd
2-9
Chapter 2
Managing Services
The system.slice contains services and other system processes. user.slice contains user
processes, which run within transient cgroups called scopes. In the example, the processes for
the user with ID 1000 are running in the scope session-7.scope under the slice /
user.slice/user-1000.slice.
You can use the systemctl command to limit the CPU, I/O, memory, and other resources
that are available to the processes in service and scope cgroups. See Controlling Access to
System Resources.
For more information, see the systemctl(1) and systemd-cgls(1) manual pages.
CPUShare controls access to CPU resources. As the default value is 1024, a value of 512
halves the access to CPU time that the processes in the cgroup have. Similarly, MemoryLimit
controls the maximum amount of memory that the cgroup can use.
Note:
You don't need to specify the .service extension to the name of a service.
If you specify the --runtime option, the setting doesn't persist across system
reboots.
Alternatively, you can change the resource settings for a service under the [Service] heading
in the service's configuration file in /usr/lib/systemd/system. After editing the file, make
systemd reload its configuration files and then restart the service:
You can run general commands within scopes and use systemctl to control the access that
these transient cgroups have to system resources. To run a command within in a scope, use
the systemd-run command:
If you don't want to create the group under the default system slice, you can specify another
slice or the name of a new slice. The following example runs a command named mymonitor
in mymon.scope under myslice.slice:
2-10
Chapter 2
Modifying systemd Service Unit Files
Note:
If you don't specify the --scope option, the control group is a created as a service
rather than as a scope.
You can then use systemctl to control the access that a scope has to system resources in
the same way as for a service. However, unlike a service, you must specify the .scope
extension, for example:
After you have copied the files, you can edit the versions in /etc/systemd/system. The files
in /etc/systemd/system take precedence over the versions in /usr/lib/systemd/
system. Files in /etc/systemd/system aren't overwritten when you update a package that
touches files in /usr/lib/systemd/system.
To revert to the default systemd configuration for a particular service, you can either rename or
delete the copies in /etc/systemd/system.
The following sections describe the different parts of a service unit file that you can edit and
customize for a system.
2-11
Chapter 2
Modifying systemd Service Unit Files
[Unit]
Contains information about the service.
[UnitType]:
Contains options that are specific to the unit type of the file. For example, in a service unit file
this section is titled [Service] and contains options that are specific to units of the service
type, such as ExecStart or StandardOutput.
Only those unit types that offer options specific to their type have such a section.
[Install]
Contains installation information for the specific unit. The information in this section is used by
the systemctl enable and systemctl disable commands.
A service unit file might contain the following configurations for a service.
[Unit]
Description=A test service used to develop a service unit file template
[Service]
Type=simple
StandardOutput=journal
ExecStart=/usr/lib/systemd/helloworld.sh
[Install]
WantedBy=default.target
Configurable Options in Service Unit Files describes some commonly used configured options
available under each section. A complete list is also available in the systemd.service(5) and
systemd.unit(5) manual pages.
Description
Provides information about the service. The information is displayed when you run the
systemctl status command on the unit.
Documentation
Contains a space-separated list of URIs referencing documentation for this unit or its
configuration.
2-12
Chapter 2
Modifying systemd Service Unit Files
After
Configures the unit to only run after the units listed in the option finish starting up.
In the following example, if the file var3.service has the following entry, then it's only started
after units var1.service and var2.service have started:
After=var1.service var2.service
Requires
Configures a unit to have requirement dependencies on other units. If a unit is activated, those
listed in its Requires option are also activated.
Wants
A less stringent version of the Requires option. For example, a specific unit can be activated
even if one of those listed in its Wants option fails to start.
Type
Configures the process start-up type for the service unit.
By default, this parameter's value is simple, which indicates that the service's main process is
that which is started by the ExecStart parameter.
Typically, if a service's type is simple, then the definition can be omitted from the file.
StandardOutput
Configures the how the service's events are logged. For example, consider a service unit file
has the following entry:
StandardOutput=journal
In the example, the value journal indicates that the events are recorded in the journal, which
can be viewed by using the journalctl command.
ExecStart
Specifies the full path and command that starts the service, for example, /usr/bin/npm
start.
ExecStop
Specifies the commands to run to stop the service started through ExecStart.
ExecReload
Specifies the commands to run to trigger a configuration reload in the service.
Restart
Configures whether the service is to be restarted when the service process exits, is stopped,
or when a timeout is reached.
2-13
Chapter 2
Modifying systemd Service Unit Files
Note:
This option doesn't apply when the process is stopped cleanly by a systemd
operation, for example a systemctl stop or systemctl restart. In these cases, the
service isn't restarted by this configuration option.
RemainAfterExit
A Boolean value that configures whether the service is to be considered active even when all
of its processes have exited. The default value is no.
Alias
A space-separated list of names for a unit.
At installation time, systemctl enable creates symlinks from these names to the unit
filename.
Aliases are only effective when the unit is enabled.
RequiredBy
Configures the service to be required by other units.
For example, consider a unit file var1.service that has the following configuration added to it:
RequiredBy=var2.service var3.service
WantedBy
Specifies a list of units that are to be granted a wants dependency upon the service whose file
you're editing.
For example, consider a unit file var1.service that has the following configuration added to it:
WantedBy=var2.service var3.service
When var1.service is enabled, both var2.service and var3.service are granted a Wants
dependency upon var1.service. This dependency is defined by a symbolic link that's created
in the “.wants” folder of each dependent service (var2.service and var3.service) that points
to the system unit file for var1.service .
Also
Lists additional units to install or remove when the unit is installed or removed.
DefaultInstance
The DefaultInstance option applies to template unit files only.
Template unit files enable the creation of multiple units from a single configuration file. The
DefaultInstance option specifies the instance for which the unit is enabled if the template is
enabled without any explicitly set instance.
2-14
Chapter 2
Creating a User-Based systemd Service
touch ~/.config/systemd/user/myservice.service
2. Open the unit file and specify the values to the options you want to use, such as
Description, ExecStart, WantedBy, and so on.
For reference, see Configurable Options in Service Unit Files and the systemd.service(5)
and systemd.unit(5) manual pages.
3. Enable the service to start automatically when you log in.
Note:
When you log out, the service is stopped unless the root user has enabled
processes to continue to run for the user.
See Use systemd on Oracle Linux for more information.
2-15
Chapter 2
Using Timer Units to Control Service Unit Runtime
Timer units are started, enabled, and stopped similarly to service units. For example, to enable
and start a timer unit immediately, type:
To list all existing timers on the system, to see when they last ran, and when they're next
configured to run, type:
systemctl list-timers
For more information about system timers, see the systemd.timer(5) and systemd.time(7)
manual pages.
• If needed, create a .service file that defines the service to be triggered by the timer unit.
In the following procedure, the sample service is /etc/systemd/system/
update.service which is a service unit that runs an update script.
For more information about creating service units, see Creating a User-Based systemd
Service.
• Decide the time and frequency for running the service. In this procedure, the timer is
configured to run the service every 2 hours from Monday to Friday.
This task shows you how to create a system timer to trigger a service to run based on a
calendar event. The definition of the calendar event is similar to entries that you put in a cron
job.
1. Create the /etc/systemd/system/update.timer with the following content:
[Unit]
Description="Run the update.service every two hours from Mon to Fri."
[Timer]
OnCalendar=Mon..Fri 00/2
Unit=update.service
[Install]
WantedBy=multi-user.target
2-16
Chapter 2
Using Timer Units to Control Service Unit Runtime
The following definition means "the first 4 days of each month at 12:00 o'clock noon, but
only if that day is either a Monday or a Tuesday":
For other ways to define OnCalendar and for more timer options that you can configure in
the system timer file, see the systemd.timer(5) and systemd.time(7) manual pages.
2. Check that all the files related to this timer are configured correctly.
This command starts the timer for the current session only.
4. Ensure that the timer starts when the system is booted.
• If needed, create a .service file that defines the service to be triggered by the timer unit.
In the following procedure, the sample service is /etc/systemd/system/
update.service which is a service unit that runs an update script.
For more information about creating service units, see Creating a User-Based systemd
Service.
• Decide the time and frequency for running the service. In this procedure, the timer is
configured to run the service 10 minutes after a system boot, and every 2 hours from when
the service is last activated.
This task shows you how to create a system timer to trigger a service to run at specific events,
which are when the system boots or after 2 hours have lapsed from the timer's activation.
2-17
Chapter 2
Using Timer Units to Control Service Unit Runtime
[Unit]
Description="Run the update.service every two hours from Mon to Fri."
[Timer]
OnBootSec=10min
OnUnitActiveSec=2h
Unit=update.service
[Install]
WantedBy=multi-user.target
For more timer options that you can configure in the system timer, see the
systemd.timer(5) and systemd.time(7) manual pages.
2. Check that all the files related to this timer are configured correctly.
This command starts the timer for the current session only.
4. Ensure that the timer starts when the system is booted.
The parameter options that you would add to the unit-file.timer file also serve as
arguments when you use systemd-run command to run a transient timer unit.
The following examples show how to use systemd-run to activate transient timers.
2-18
Chapter 2
Using Timer Units to Control Service Unit Runtime
• Run ~/myscripts/update.sh 5 minutes after the service manager is started. Use this
syntax to run a service after the service manager has started at user login.
2-19
3
Configuring System Settings
This chapter describes the files and virtual file systems that you can use to change the
configuration settings for the system.
Also see Configure System Settings on Oracle Linux for a hands-on tutorial on how to
configure system settings as described in this chapter.
atd
Specifies command line arguments for the atd daemon.
autofs
Defines custom options for automatically mounting devices and controlling the operation of the
automounter.
crond
Passes arguments to the crond daemon at boot time.
chronyd
Passes arguments to the chronyd daemon used for NTP services at boot time.
firewalld
Passes arguments to the firewall daemon (firewalld) at boot time.
grub
Specifies default settings for the GRUB 2 bootloader. This file is a symbolic link to /etc/
default/grub. For more information, see About the GRUB 2 Bootloader.
named
Passes arguments to the name service daemon at boot time. The named daemon is a Domain
Name System (DNS) server that's part of the Berkeley Internet Name Domain (BIND)
distribution. This server maintains a table that associates host names with IP addresses on
the network.
samba
Passes arguments to the smbd, nmbd, and winbindd daemons at boot time to support file-
sharing connectivity for Windows clients, NetBIOS-over-IP naming service, and connection
management to domain controllers.
selinux
Controls the state of SELinux on the system. This file is a symbolic link to /etc/selinux/
config.
For more information, see Oracle Linux: Administering SELinux.
3-1
Chapter 3
About the /proc Virtual File System
snapper
Defines a list of btrfs file systems and thinly provisioned LVM volumes whose contents can be
recorded as snapshots by the snapper utility.
For more information, see Oracle Linux 8: Managing Local File Systems .
sysstat
Configures logging parameters for system activity data collector utilities such as sar.
To examine virtual files, you can use commands such as cat, less, and view, as shown in
the following example:
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
stepping : 7
cpu MHz : 2393.714
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 5
3-2
Chapter 3
About the /proc Virtual File System
wp : yes
...
For files that contain nonhuman-readable content, you can use utilities such as lspci, free,
top, and sysctl to access information. For example, the lspci command lists PCI devices
on a system:
sudo lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox
Graphics Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet
Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest
Service
00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio
Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0b.0 USB controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB2 EHCI Controller
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA
Controller [AHCI mode]
(rev 02)
...
3-3
Chapter 3
About the /proc Virtual File System
Table 3-1 Useful Virtual Files and Directories Under the /proc Directory
cmdline
Command path.
cwd
Symbolic link to the process's current working
directory.
environ
Environment variables.
exe
Symbolic link to the command executable.
fd/N
File descriptors.
maps
Memory maps to executable and library files.
root
Symbolic link to the effective root directory for
the process.
stack
The contents of the kernel stack.
status
Run state and memory usage.
3-4
Chapter 3
About the /proc Virtual File System
Table 3-1 (Cont.) Useful Virtual Files and Directories Under the /proc Directory
3-5
Chapter 3
About the /proc Virtual File System
Table 3-1 (Cont.) Useful Virtual Files and Directories Under the /proc Directory
cpu
Total CPU time (measured in jiffies) spent in
user mode, low-priority user mode, system
mode, idle, waiting for I/O, handling hardirq
events, and handling softirq events.
cpuN
Times for CPU N.
3-6
Chapter 3
About the /proc Virtual File System
Table 3-1 (Cont.) Useful Virtual Files and Directories Under the /proc Directory
dev
Device parameters.
fs
File system parameters.
kernel
Kernel configuration parameters.
net
Networking parameters.
3-7
Chapter 3
About the /proc Virtual File System
Other files take binary or Boolean values, such as the setting of IP forwarding, which is defined
in /proc/sys/net/ipv4/ip_forward:
cat /proc/sys/net/ipv4/ip_forward
You can use the sysctl command to view or modify values under the /proc/sys directory.
Note:
Even root can't bypass the file access permissions of virtual file entries under /
proc. If you change the value of a read-only entry such as /proc/partitions, no
kernel code exists to service the write() system call.
sysctl -a
kernel.sched_child_runs_first = 0
kernel.sched_min_granularity_ns = 2000000
kernel.sched_latency_ns = 10000000
kernel.sched_wakeup_granularity_ns = 2000000
kernel.sched_shares_ratelimit = 500000
...
Note:
The delimiter character in the name of a setting is a period (.) rather than a slash (/)
in a path relative to /proc/sys, such as net.ipv4.ip_forward. This setting
represents net/ipv4/ip_forward. As another example, kernel.msgmax represents
kernel/msgmax.
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
3-8
Chapter 3
About the /proc Virtual File System
sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
Changes that you make in this way remain in force only until the system is rebooted. To make
configuration changes persist after the system is rebooted, you must add them to the /etc/
sysctl.d directory as a configuration file. Any changes that you make to the files in this
directory take effect when the system reboots or if you run the sysctl --system command,
for example:
/etc/sysctl.d/ip_forward.conf:net.ipv4.ip_forward=1
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
sysctl --system
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
For more information, see the sysctl(8) and sysctl.d(5) manual pages.
3-9
Chapter 3
About the /proc Virtual File System
fs.file-max
Specifies the maximum number of open files for all processes. Increase the value of this
parameter if you see messages about running out of file handles.
kernel.io_uring_disabled
Specifies the disabled setting for creating io_uring instances. io_uring provides an interface
to handle asynchronous I/O operations that can significantly improve performance for storage
and networking. io_uring is supported with UEK and is enabled by default when running UEK
on Oracle Linux.
You can set the following values for the io_uring parameter:
• kernel.io_uring_disabled=0 (default). This setting specifies all processes can create
io_uring instances.
• kernel.io_uring_disabled=1. This setting specifies only processes with CAP_SYS_ADMIN
privileges can create io_uring instances.
• kernel.io_uring_disabled=2. This setting specifies that io_uring instance creation is
disabled for all users.
net.core.netdev_max_backlog
Specifies the size of the receiver backlog queue, which is used if an interface receives packets
faster than the kernel can process them. If this queue is too small, packets are lost at the
receiver, rather than on the network.
net.core.rmem_max
Specifies the maximum read socket buffer size. To minimize network packet loss, this buffer
must be large enough to handle incoming network packets.
net.core.wmem_max
Specifies the maximum write socket buffer size. To minimize network packet loss, this buffer
must be large enough to handle outgoing network packets.
net.ipv4.tcp_available_congestion_control
Displays the TCP congestion avoidance algorithms that are available for use. Use the
modprobe command if you need to load additional modules such as tcp_htcp to implement
the htcp algorithm.
net.ipv4.tcp_congestion_control
Specifies which TCP congestion avoidance algorithm is used.
net.ipv4.tcp_max_syn_backlog
Specifies the number of outstanding SYN requests that are allowed. Increase the value of this
parameter if you see synflood warnings in the logs that are caused by the server being
overloaded by legitimate connection attempts.
net.ipv4.tcp_rmem
Specifies minimum, default, and maximum receive buffer sizes that are used for a TCP
socket. The maximum value can't be larger than net.core.rmem_max.
3-10
Chapter 3
About the /proc Virtual File System
net.ipv4.tcp_wmem
Specifies minimum, default, and maximum send buffer sizes that are used for a TCP socket.
The maximum value can't be larger than net.core.wmem_max.
vm.swappiness
Specifies how likely the kernel is to write loaded pages to swap rather than drop pages from
the system page cache. When set to 0, swapping only occurs to avoid an out of memory
condition. When set to 100, the kernel swaps aggressively. For a desktop system, setting a
lower value can improve system responsiveness by decreasing latency. The default value is
60.
Caution:
This parameter is intended for use with laptop computers to reduce power
consumption by the hard disk. Do not adjust this value on server systems.
kernel.hung_task_panic
If set to 1, the kernel panics if any kernel or user thread sleeps in the TASK_UNINTERRUPTIBLE
state (D state) for more than kernel.hung_task_timeout_secs seconds. A process remains in
D state while waiting for I/O to complete. You can't stop or interrupt a process in this state.
The default value is 0, which disables the panic.
Tip:
To diagnose a hung thread, you can examine /proc/PID/stack, which displays
the kernel stack for both kernel and user threads.
kernel.hung_task_timeout_secs
Specifies how long a user or kernel thread can remain in D state before a warning message is
generated or the kernel panics, if the value of kernel.hung_task_panic is 1. The default value
is 120 seconds. A value of 0 disables the timeout.
kernel.nmi_watchdog
If set to 1 (default), enables the nonmaskable interrupt (NMI) watchdog thread in the kernel. To
use the NMI switch or the OProfile system profiler to generate an undefined NMI, set the value
of kernel.nmi_watchdog to 0.
kernel.panic
Specifies the number of seconds after a panic before a system automatically resets itself.
If the value is 0, which is the default value, the system bcomes suspended, and you can
collect detailed information about the panic for troubleshooting.
To enable automatic reset, set a nonzero value. If you require a memory image (vmcore),
leave enough time for Kdump to create this image. The suggested value is 30 seconds,
although large systems require a longer time.
3-11
Chapter 3
About the /sys Virtual File System
kernel.panic_on_io_nmi
If set to 0 (default), the system tries to continue operations if the kernel detects an I/O channel
check (IOCHK) NMI that typically indicates a uncorrectable hardware error. If set to 1, the
system panics.
kernel.panic_on_oops
If set to 0, the system tries to continue operations if the kernel detects an oops or BUG
condition. If set to 1 (default), the system delays a few seconds to give the kernel log daemon,
klogd, time to record the oops output before the panic occurs.
In an OCFS2 cluster. set the value to 1 to specify that a system must panic if a kernel oops
occurs. If a kernel thread required for cluster operation fails, the system must reset itself.
Otherwise, another node might not detect whether a node is slow to respond or unable to
respond, causing cluster operations to halt.
kernel.panic_on_unrecovered_nmi
If set to 0 (default), the system tries to continue operations if the kernel detects an NMI that
usually indicates an uncorrectable parity or ECC memory error. If set to 1, the system panics.
kernel.softlockup_panic
If set to 0 (default), the system tries to continue operations if the kernel detects a soft-lockup
error that causes the NMI watchdog thread to fail to update its timestamp for more than twice
the value of kernel.watchdog_thresh seconds. If set to 1, the system panics.
kernel.unknown_nmi_panic
If set to 1, the system panics if the kernel detects an undefined NMI. You would usually
generate an undefined NMI by manually pressing an NMI switch. As the NMI watchdog thread
also uses the undefined NMI, set the value of kernel.unknown_nmi_panic to 0 if you set
kernel.nmi_watchdog to 1.
kernel.watchdog_thresh
Specifies the interval between generating an NMI performance monitoring interrupt that the
kernel uses to check for hard-lockup and soft-lockup errors. A hard-lockup error is assumed if
a CPU is unresponsive to the interrupt for more than kernel.watchdog_thresh seconds. The
default value is 10 seconds. A value of 0 disables the detection of lockup errors.
vm.panic_on_oom
If set to 0 (default), the kernel’s OOM-killer scans through the entire task list and stops a
memory-hogging process to avoid a panic. If set to 1, the kernel panics but can survive under
certain conditions. If a process limits allocations to certain nodes by using memory policies or
cpusets, and those nodes reach memory exhaustion status, the OOM-killer can stop one
process. No panic occurs in this case because other nodes’ memory might be free and the
system as a whole might not yet be out of memory. If set to 2, the kernel always panics when
an OOM condition occurs. Settings of 1 and 2 are for intended for use with clusters,
depending on the defined failover policy.
3-12
Chapter 3
About the /sys Virtual File System
Note:
/sys exposes kernel data structures and control points, which implies that the
directory contains circular references, where a directory links to an ancestor directory.
Thus, a find command used on /sys might never stop.
3-13
Chapter 3
Configuring System Language (Locale) and Keyboard Settings
Note:
System -wide preferences for language and keyboard are also configurable during
installation. For details on how to configure these settings at installation, see Oracle
Linux 9: Installing Oracle Linux or Oracle Linux 8: Installing Oracle Linux.
For example, the following system language locale output indicates: English (en) as the
language, US as the country code, and UTF-8 as the codeset.
System Locale: LANG=en_US.UTF-8
To search the output for a specific language locale, use the grep command. For example,
to list all possible English locales available for configuration, type:
localectl list-locales | grep en
3. To list all language packs already installed on your system and all language packs
available on the ol8_appstream repository, and type:
For example, the following shows that this system has Spanish, French, Japanese, and
Russian language packs installed followed by a truncated list of language packs available
on ol8_appstream.
3-14
Chapter 3
Configuring System Language (Locale) and Keyboard Settings
Installed Packages
langpacks-es.noarch 1.0-12.el8
@ol8_appstream
langpacks-fr.noarch 1.0-12.el8
@ol8_appstream
langpacks-ja.noarch 1.0-12.el8
@ol8_appstream
langpacks-ru.noarch 1.0-12.el8
@ol8_appstream
Available Packages
langpacks-af.noarch 1.0-12.el8
ol8_appstream
langpacks-am.noarch 1.0-12.el8
ol8_appstream
langpacks-ar.noarch 1.0-12.el8
ol8_appstream
...
4. Use dnf to install a language pack. For example, the following installs the Japanese
language pack:
Where:
• locale_name is replaced with the name retrieved earlier from the list-locales
output.
For example, to set British English as the system language locale, type:
sudo localectl set-locale LANG=en_GB.utf8
Note:
Locale options are typically listed in the following format:
LANGUAGE_COUNTRY.CODESET[@MODIFIERS]. The LANGUAGE is an ISO 639 language
code, for example, en for English and COUNTRY is an ISO 3166 country code. The
two letter country code in this example is GB for Great Britain and the United
Kingdom. The CODESET is the character set or encoding, for example, utf-8.
For more information on how to configure language locale options on the system, see the
locale manual page.
3-15
Chapter 3
Configuring System Date and Time Settings
In the previous command, language_code is the language code you want to install. For
example, the following example installs Japanese.
For example, the following keyboard layout output indicates a US country code for the
virtual console keymap and a US country code for the X11 layout.
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
To search the output for a specific keymap name, use the grep command. For example, to
list British compatible keyboard layouts, type:
localectl list-keymaps | grep gb
Where:
• keymap_name is replaced with the name of the keymap retrieved earlier from the
list-keymaps output.
Note that the keymap name change applies to both the virtual console and the x11 layout
settings. If you want the X11 layout to differ from the virtual console keymap, use the --
no-convert option, for example:
sudo localectl --no-convert set-x11-keymap keymap_name
The no-convert option retains the previous x11 keyboard layout setting.
For more information on how to use the localectl command line utility to change
keyboard system settings, see thelocalectl manual page.
3-16
Chapter 3
Configuring System Date and Time Settings
January 1, 1970. A day is defined as 86400 seconds and leap seconds are subtracted
automatically.
Date and time representation on a system can be set to match a specific timezone. To list the
available timezones, run:
timedatectl list-timezones
To set the system timezone to match a value returned from the available timezones, you can
run:
TZ="Asia/Tokyo" date
You can check the system's current date and time configuration by running the timedatectl
command on its own:
timedatectl
NTP service:
active
3-17
Chapter 3
Configuring the Watchdog Service
This command sets the current system time based on the time specified assuming the
currently set system timezone. The command also updates the system Real Time Clock
(RTC).
Tip:
See Learn How to Localize Your Installation on Oracle Linux for a hands-on tutorial
that describes how to use tools to configure system parameters such as date, time,
and locale.
Consider configuring the system to use network time synchronization for more accurate time-
keeping. Using network time synchronization is important especially when setting up high-
availability or when using network-based file systems.
For more information about configuring the network time services that use NTP, see Oracle
Linux 8: Setting Up Networking.
Tip:
See Configure Chrony on Oracle Linux for a hands-on tutorial on setting up and
configuring the chronyd service.
If you configure an NTP service, enable NTP by running the following command:
3-18
Chapter 3
Configuring the Watchdog Service
Note:
The Watchdog service starts and runs immediately after a power reset.
3-19
4
Managing System Devices
This chapter describes how the system uses device files and how the Udev device manager
dynamically creates or removes device node files.
Using the ls -l /dev command lists files, some of which are flagged as being either type b
(for block) or type c (for character). These devices have an associated pair of numbers that
identify the device to the system.
ls -l /dev
total 0
crw-r--r--. 1 root root 10, 235 Aug 20 08:36 autofs
drwxr-xr-x. 2 root root 240 Sep 20 07:37 block
drwxr-xr-x. 2 root root 100 Aug 20 08:36 bsg
drwxr-xr-x. 3 root root 60 Nov 4 2019 bus
lrwxrwxrwx. 1 root root 3 Aug 20 08:36 cdrom -> sr0
drwxr-xr-x. 2 root root 2720 Sep 20 07:37 char
crw-------. 1 root root 5, 1 Aug 20 08:36 console
lrwxrwxrwx. 1 root root 11 Aug 20 08:36 core -> /proc/kcore
drwxr-xr-x. 3 root root 60 Nov 4 2019 cpu
crw-------. 1 root root 10, 62 Aug 20 08:36 cpu_dma_latency
drwxr-xr-x. 7 root root 140 Aug 20 08:36 disk
brw-rw----. 1 root disk 253, 0 Aug 20 08:36 dm-0
brw-rw----. 1 root disk 253, 1 Aug 20 08:36 dm-1
brw-rw----. 1 root disk 253, 2 Aug 20 08:36 dm-2
lrwxrwxrwx. 1 root root 13 Aug 20 08:36 fd -> /proc/self/fd
crw-rw-rw-. 1 root root 1, 7 Aug 20 08:36 full
crw-rw-rw-. 1 root root 10, 229 Aug 20 08:36 fuse
crw-------. 1 root root 10, 228 Aug 20 08:36 hpet
drwxr-xr-x. 2 root root 0 Aug 20 08:36 hugepages
crw-------. 1 root root 10, 183 Aug 20 08:36 hwrng
lrwxrwxrwx. 1 root root 12 Aug 20 08:36 initctl -> /run/initctl
drwxr-xr-x. 3 root root 220 Aug 20 08:36 input
crw-r--r--. 1 root root 1, 11 Aug 20 08:36 kmsg
lrwxrwxrwx. 1 root root 28 Aug 20 08:36 log -> /run/systemd/journal/
dev-log
brw-rw----. 1 root disk 7, 0 Sep 23 01:28 loop0
4-1
Chapter 4
About Device Files
Block devices support random access to data, seeking media for data, and typically buffers
data while data is being written or read. Examples of block devices include hard disks, CD-
ROM drives, flash memory, and other addressable memory devices.
Character devices support the streaming of data to or from a device. The data isn't typically
buffered nor is random access granted to data on a device. The kernel writes data to or reads
data from a character device 1 byte at a time. Examples of character devices include
keyboards, mice, terminals, pseudo terminals, and tape drives. tty0 and tty1 are character
device files that correspond to terminal devices so users can log in from serial terminals or
terminal emulators.
Pseudo terminals secondary devices emulate real terminal devices to interact with software.
For example, a user might log in to a terminal device such as /dev/tty1, which then uses the
pseudo terminal primary device, /dev/pts/ptmx, to interact with an underlying pseudo
terminal device. The character device files for pseudo terminal secondary and primary devices
are located in the /dev/pts directory, as shown in the following example:
ls -l /dev/pts
total 0
crw--w----. 1 guest tty 136, 0 Mar 17 10:11 0
crw--w----. 1 guest tty 136, 1 Mar 17 10:53 1
crw--w----. 1 guest tty 136, 2 Mar 17 10:11 2
c---------. 1 root root 5, 2 Mar 17 08:16 ptmx
4-2
Chapter 4
About the Udev Device Manager
Some device entries, such as stdin for the standard input, are symbolically linked through the
self subdirectory of the proc file system. The pseudo-terminal device file to which they
actually point depends on the context of the process.
ls -l /proc/self/fd/[012]
Character devices, such as null, random, urandom, and zero are examples of pseudo devices
that provide access to virtual functionality implemented in software rather than to physical
hardware.
/dev/null is a data sink. Data that you write to /dev/null effectively disappears but the
write operation succeeds. Reading from /dev/null returns EOF (end-of-file).
/dev/random and /dev/urandom are data sources of streams of pseudo random bytes. To
maintain high-entropy output, /dev/random blocks if its entropy pool doesn't contain sufficient
bits of noise. /dev/urandom doesn't block and, thereforem, the entropy of its output might not
be as consistently high as that of /dev/random. However, neither /dev/random nor /dev/
urandom are considered to be truly random enough for the purposes of secure cryptography
such as military-grade encryption.
You can find out the size of the entropy pool and the entropy value for /dev/random from
virtual files under /proc/sys/kernel/random:
cat /proc/sys/kernel/random/poolsize
4096
cat /proc/sys/kernel/random/entropy_avail
3467
For more information, see the null(4), pts(4), and random(4) manual pages.
4-3
Chapter 4
About Udev Rules
The configuration file for udev is /etc/udev/udev.conf, in which you can define the
udev_log logging priority, which can be set to err, info and debug. Note that the default value
is err.
Multiple rules files exist in different directories. However, you only need to know about /etc/
udev/rules.d/*.rules files because these are the only rules files that you can modify. See
Modifying Udev Rules.
Udev processes the rules files in lexical order, regardless of the directory of the rule files. Rules
files in /etc/udev/rules.d override rules files of the same name in other locations.
SUBSYSTEM=="block", SYMLINK{unique}+="block/%M:%m"
SUBSYSTEM!="block", SYMLINK{unique}+="char/%M:%m"
# CPU
KERNEL=="cpu[0-9]*", MODE="0444"
...
# do not delete static device nodes
ACTION=="remove", NAME=="", TEST=="/lib/udev/devices/%k", \
OPTIONS+="ignore_remove"
ACTION=="remove", NAME=="?*", TEST=="/lib/udev/devices/$name", \
OPTIONS+="ignore_remove"
A rule either assigns a value to a key or it tries to find a match for a key by comparing its
current value with the specified value. The following table shows the assignment and
comparison operators that you can use.
4-4
Chapter 4
About Udev Rules
Operator Description
= Assign a value to a key, overwriting any
previous value.
+= Assign a value by appending it to the key's
current list of values.
:= Assign a value to a key. This value cannot be
changed by any further rules.
== Match the key's current value against the
specified value for equality.
!= Match the key's current value against the
specified value for equality.
Character Description
? Matches a single character.
* Matches any number of characters, including
zero.
[] Matches any single character or character from
a range of characters specified within the
brackets. For example, tty[sS][0-9] would
match ttys7 or ttyS7.
4-5
Chapter 4
About Udev Rules
cmdline
Import a single property from the boot kernel
command line. For simple flags, udev sets the
value of the property to 1. For example,
IMPORT{cmdline}="nodmraid".
db
Interpret the specified value as an index into
the device database and import a single
property, which must have already been set by
an earlier event. For example,
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG".
file
Interpret the specified value as the name of a
text file and import its contents, which must be
in environmental key format. For example,
IMPORT{file}="keyfile".
parent
Interpret the specified value as a key-name
filter and import the stored keys from the
database entry for the parent device. For
example IMPORT{parent}="ID_*".
program
Run the specified value as an external program
and imports its result, which must be in
environmental key format. For example
IMPORT{program}="usb_id --export %p".
4-6
Chapter 4
Querying Udev and Sysfs
Other assignment keys include ATTR{key}, GOTO, LABEL, RUN, and WAIT_FOR.
The following table describes the string substitutions that are commonly used with the GROUP,
MODE, NAME, OWNER, PROGRAM, RUN, and SYMLINK keys.
Udev expands the strings specified for RUN immediately before its program is run, which is after
udev has finished processing all other rules for the device. For the other keys, udev expands
the strings while it's processing the rules.
For more information, see the udev(7) manual page.
4-7
Chapter 4
Querying Udev and Sysfs
To query the sysfs device path relative to /sys that corresponds to the device file /dev/sda:
/devices/pci0000:00/0000:00:0d.0/host0/target0:0:0/0:0:0:0/block/sda
To query the symbolic links that point to /dev/sda, use the following command:
block/8:0
disk/by-id/ata-VBOX_HARDDISK_VB6ad0115d-356e4c09
disk/by-id/scsi-SATA_VBOX_HARDDISK_VB6ad0115d-356e4c09
disk/by-path/pci-0000:00:0d.0-scsi-0:0:0:0
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:0d.0/host0/target0:0:0/0:0:0:0/block/sda
MAJOR=8
MINOR=0
DEVNAME=/dev/sda
DEVTYPE=disk
SUBSYSTEM=block
ID_ATA=1
ID_TYPE=disk
ID_BUS=ata
ID_MODEL=VBOX_HARDDISK
ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.
..
ID_REVISION=1.0
ID_SERIAL=VBOX_HARDDISK_VB579a85b0-bf6debae
ID_SERIAL_SHORT=VB579a85b0-bf6debae
ID_ATA_WRITE_CACHE=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_ATA_SATA=1
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_SCSI_COMPAT=SATA_VBOX_HARDDISK_VB579a85b0-bf6debae
ID_PATH=pci-0000:00:0d.0-scsi-0:0:0:0
ID_PART_TABLE_TYPE=dos
LVM_SBIN_PATH=/sbin
UDISKS_PRESENTATION_NOPOLICY=0
UDISKS_PARTITION_TABLE=1
UDISKS_PARTITION_TABLE_SCHEME=mbr
UDISKS_PARTITION_TABLE_COUNT=2
UDISKS_ATA_SMART_IS_AVAILABLE=0
4-8
Chapter 4
Querying Udev and Sysfs
DEVLINKS=/dev/block/8:0 /dev/disk/by-id/ata-VBOX_HARDDISK_VB579a85b0-
bf6debae ...
To query the entire information for /dev/sda, use the following command:
P: /devices/pci0000:00/0000:00:0d.0/host0/target0:0:0/0:0:0:0/block/sda
N: sda
W: 37
S: block/8:0
S: disk/by-id/ata-VBOX_HARDDISK_VB579a85b0-bf6debae
S: disk/by-id/scsi-SATA_VBOX_HARDDISK_VB579a85b0-bf6debae
S: disk/by-path/pci-0000:00:0d.0-scsi-0:0:0:0
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/host0/target0:0:0/0:0:0:0/
block/sda
E: MAJOR=8
E: MINOR=0
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=VBOX_HARDDISK
E:
ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.
..
E: ID_SERIAL=VBOX_HARDDISK_VB579a85b0-bf6debae
E: ID_SERIAL_SHORT=VB579a85b0-bf6debae
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_ATA_FEATURE_SET_PM=1
E: ID_ATA_FEATURE_SET_PM_ENABLED=1
E: ID_ATA_SATA=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1
E: ID_SCSI_COMPAT=SATA_VBOX_HARDDISK_VB579a85b0-bf6debae
E: ID_PATH=pci-0000:00:0d.0-scsi-0:0:0:0
E: ID_PART_TABLE_TYPE=dos
E: LVM_SBIN_PATH=/sbin
E: UDISKS_PRESENTATION_NOPOLICY=0
E: UDISKS_PARTITION_TABLE=1
E: UDISKS_PARTITION_TABLE_SCHEME=mbr
E: UDISKS_PARTITION_TABLE_COUNT=2
E: UDISKS_ATA_SMART_IS_AVAILABLE=0
E: DEVLINKS=/dev/block/8:0 /dev/disk/by-id/ata-VBOX_HARDDISK_VB579a85b0-
bf6debae ...
4-9
Chapter 4
Querying Udev and Sysfs
To display all of the properties of /dev/sda, as well as the parent devices that udev has found
in /sys, use the following command:
...
looking at device '/devices/pci0000:00/0000:00:0d.0/host0/
target0:0:0/0:0:0:0/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{range}=="16"
ATTR{ext_range}=="256"
ATTR{removable}=="0"
ATTR{ro}=="0"
ATTR{size}=="83886080"
ATTR{alignment_offset}=="0"
ATTR{capability}=="52"
ATTR{stat}==" 20884 15437 1254282 338919 5743 8644
103994 109005 ...
ATTR{inflight}==" 0 0"
4-10
Chapter 4
Modifying Udev Rules
DRIVERS==""
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,0000
0000,00000003"
ATTRS{local_cpulist}=="0-1"
ATTRS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"
ATTRS{numa_node}=="-1"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""
ATTRS{msi_irqs}==""
The command starts at the device that's specified by the device path and walks the chain of
parent devices. For every device that the command finds, the command displays the possible
attributes for the device and its parent devices by using the match key format for udev rules.
1. Create a rule file under /etc/udev/rules.d with a file name such as 10-local.rules
that udev reads before any other rules file.
The following rule in 10-local.rules creates the symbolic link /dev/my_disk, which
points to /dev/sdb:
4-11
Chapter 4
Modifying Udev Rules
Listing the device files in /dev shows that udev hasn't yet applied the rule:
ls /dev/sd* /dev/my_disk
2. To simulate how udev applies its rules to create a device, you can use the udevadm test
command with the device path of sdb listed under the /sys/class/block hierarchy, for
example:
calling: test
version ...
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
...
LINK 'my_disk' /etc/udev/rules.d/10-local.rules:1
...
creating link '/dev/my_disk' to '/dev/sdb'
creating symlink '/dev/my_disk' to 'sdb
...
ACTION=add
DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB186e4ce2-f80f170d
/dev/disk/by-uuid/a7dc508d-5bcc-4112-b96e-f40b19e369fe
/dev/my_disk
...
After udev processes the rules files, the symbolic link /dev/my_disk has been added:
ls -F /dev/sd* /dev/my_disk
4-12
5
Managing Kernel Modules
This chapter describes how to load, unload, and modify the behavior of kernel modules.
Note:
From UEK R7 onward, kernel packaging changes are applied to provide a more
streamlined kernel. Kernel modules that are required for most server configurations
are provided in the kernel-uek-modules package, while optional kernel modules for
hardware less often found in server configurations, such as Bluetooth, Wi-Fi, and
video capture cards, can be found in the kernel-uek-modules-extra package. Note
that both of these packages require the kernel-uek-firmware package to be
installed.
You can view the contents of these packages by running:
Kernel modules can be signed to protect the system from running malicious code at boot time.
When UEFI Secure Boot is enabled, only kernel modules that contain the correct signature
information can be loaded. See Oracle Linux: Working With UEFI Secure Boot for more
information.
5-1
Chapter 5
Listing Information About Loaded Modules
lsmod
The output shows the module name, the amount of memory it uses, the number of processes
using the module and the names of other modules on which it depends. The module dm_log,
for example, depends on the dm_region_hash and dm_mirror modules. The example also
shows that two processes are using all three modules.
Show detailed information about a module by using the modinfo command:
modinfo ahci
filename: /lib/modules/5.4.17-2136.306.1.3.el8uek.x86_64/kernel/
drivers/ata/ahci.ko.xz
version: 3.0
license: GPL
description: AHCI SATA low-level driver
author: Jeff Garzik
srcversion: 3F4E4F52FD2D5F8BBD5F972
alias: pci:v*d*sv*sd*bc01sc06i01*
alias: pci:v00001C44d00008000sv*sd*bc*sc*i*
...
depends: libahci,libata
retpoline: Y
intree: Y
name: ahci
vermagic: 5.4.17-2136.306.1.3.el8uek.x86_64 SMP mod_unload modversions
sig_id: PKCS#7
signer: Oracle CA Server
sig_key: 22:07:CB:47:59:F3:50:A0:A2:FA:24:CE:B4:00:53:4E:C5:1D:C6:2A
sig_hashalgo: sha512
signature: 2F:AE:AF:6D:56:92:69:C4:77:AB:E1:3D:41:09:AF:A6:FC:1D:3B:A2:
9C:23:79:6F:17:82:D5:A3:9B:61:64:32:72:9B:98:C9:8C:89:73:FB:
A4:86:4F:B5:7D:DF:84:8E:05:26:4F:22:CB:02:41:38:7B:7C:CB:C2:
...
9F:FD:94:8F:35:9B:2A:89:3E:E1:17:40:49:79:30:8B:92:4D:3A:9A:
5-2
Chapter 5
Listing Information About Loaded Modules
F4:C7:82:8D:26:BE:6D:FB:71:C6:E5:FD
parm: marvell_enable:Marvell SATA via AHCI (1 = enabled) (int)
parm: mobile_lpm_policy:Default LPM policy for mobile chipsets (int)
...
filename
Absolute path of the kernel object file.
version
Version number of the module. Note that the version number might not be updated for patched
modules and might be missing or removed in newer kernels.
license
License information for the module.
description
Short description of the module.
author
Author credit for the module.
srcversion
Hash of the source code used to create the module.
alias
Internal alias names for the module.
depends
Comma-separated list of any modules on which this module depends.
retpoline
A flag indicating that the module is built that includes a mitigation against the Spectre security
vulnerability.
intree
A flag indicating that the module is built from the kernel in-tree source and isn't tainted.
vermagic
Kernel version that was used to compile the module, which is checked against the current
kernel when the module is loaded.
sig_id
The method used to store signing keys that might have been used to sign a module for Secure
Boot, typically PKCS#7
signer
The name of the signing key used to sign a module for Secure Boot.
sig_key
The signature key identifier for the key used to sign the module.
sig_hashalgo
The algorithm used to generate the signature hash for a signed module.
5-3
Chapter 5
Loading and Unloading Modules
signature
The signature data for a signed module.
parm
Module parameters and descriptions.
Modules are loaded into the kernel from kernel object files (/lib/modules/
kernel_version/kernel/*ko*). To display the absolute path of a kernel object file, specify
the -n option, for example:
modinfo -n parport
/lib/modules/5.4.17-2136.306.1.3.el8uek.x86_64/kernel/drivers/parport/
parport.ko.xz
For more information, see the lsmod(5) and modinfo(8) manual pages.
nfs 266415 0
lockd 66530 1 nfs
fscache 41704 1 nfs
nfs_acl 2477 1 nfs
auth_rpcgss 38976 1 nfs
sunrpc 204268 5 nfs,lockd,nfs_acl,auth_rpcgss
Include the -v (verbose) option to show whether any additional modules are loaded to resolve
dependencies.
insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/net/sunrpc/auth_gss/
auth_rpcgss.ko
insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/nfs_common/nfs_acl.ko
insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/fscache/fscache.ko
...
Note:
The modprobe command does not reload modules that are already loaded. You
must first unload a module before you can load it again.
5-4
Chapter 5
About Module Parameters
rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/nfs/nfs.ko
rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/lockd/lockd.ko
rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/fscache/fscache.ko
...
Modules are unloaded in reverse order in which they were first loaded. Modules aren't
unloaded if a process or another loaded module requires them.
For more information, see the modprobe(8) and modules.dep(5) manual pages.
Separate multiple parameter and value pairs with spaces. Array values are represented by a
comma-separated list, for example:
Alternatively, change the values of some parameters for loaded modules and built-in drivers by
writing the new value to a file under /sys/module/module_name/parameters, for
example:
alias
Creates an alternative name for a module. The alias can include shell wildcards. To create an
alias for the sd-mod module:
blacklist
Ignore a module's internal alias that's displayed by the modinfo command. This command is
typically used in the following conditions:
• The associated hardware isn't required.
5-5
Chapter 5
Specifying Modules To Be Loaded at Boot Time
blacklist cirrusfb
install
Runs a shell command instead of loading a module into the kernel. For example, load the
module snd-emu10k1-synth instead of snd-emu10k1:
options
Defines options for a module. For example, to define the nohwcrypt and qos options for the
b43 module, type:
remove
Runs a shell command instead of unloading a module. To unmount /proc/fs/nfsd before
unloading the nfsd module, type:
For example to force the bnxt_en.conf to load at boot time, run the following command:
5-6
Chapter 5
About Weak Update Modules
1. Create a configuration file to prevent the module from loading. For example:
sudo dracut -f -v
sudo reboot
WARNING:
Disabling modules can have unintended consequences and can prevent a system
from booting properly or from being fully functional after boot. As a best practice,
create a backup ramdisk image before making changes and ensure that the
configuration is correct.
For example, if a newer kernel is compatible with a module that was installed for the previous
kernel, an external module (such as kmod-kvdo) is automatically added as a symbolic link in
5-7
Chapter 5
About Weak Update Modules
the weak-updates directory as part of the installation process, as shown in the following
command output:
ls -l /lib/modules/4.18.0-80.el8.x86_64/weak-updates/kmod-kvdo/uds
ls -l /lib/modules/4.18.0-80.el8.x86_64/weak-updates/kmod-kvdo/vdo
The symbolic link enables the external module to loaded for kernel updates.
Weak updates are beneficial and ensure that no extra work is required to carry an external
module through kernel updates. Any potential driver-related boot issues after kernel upgrades
are prevented, thus provides a more predictable running of a system and its hardware.
In certain cases, you might remove weak update modules in place of a newer kernel, for
example, in the case where an issue with a shipped driver has been resolved in a newer
kernel. In this case, you might prefer to use the new driver rather than the external module that
you installed as part of a driver update.
To remove weak update modules, use the following command:
rm -rf /lib/modules/4.18.0-80.el8.x86_64/weak-updates/kmod-kvdo/
Running this command manually removes the symbolic links for each kernel.
Alternatively, you can use the weak-modules command, which safely removes the specified
weak update module for the compatible kernels or the command removes the weak update
modules for the current kernel. You can use the weak-modules command similarly to add
weak update modules.
You can also use the weak-modules command with the dry-run option to test the results
without making actual changes, for example:
For more information about external driver modules and driver update disks, see Oracle Linux
8: Installing Oracle Linux.
5-8
6
Configuring Huge Pages
In Oracle Linux, physical memory is managed in fixed-size blocks called pages. In the x86_64
architecture, the default size of each page is 4 KB.
The kernel stores virtual to physical address mappings for the pages in a data structure known
as the page table. However, page table lookups are resource-intensive, so the most recently
used addresses are cached in the CPU’s Translation Lookaside Buffer (TLB) for faster
retrieval. When the CPU needs to fulfill a request for an address-mapping, the CPU first
searches the TLB cache. A TLB hit describes the CPU finding the address in the TLB cache. A
TLB miss describes the CPU unable to find the requested address-mapping in the cache, in
which case the system would perform a resource intensive lookup on the page table to retrieve
the address information.
The default page size of 4 KB is suitable for most applications. However, for applications that
work with large amounts of memory, the number of 4 KB pages required can be large and can
lead to a high number of TLB misses and a performance overhead. Oracle Linux provides
huge page features so that applications requiring more memory can have their requirements
fulfilled with fewer pages.
HugeTLB Pages
HugeTLB pages are also called static huge pages.
With HugeTLB pages feature, you can reserve pools of huge pages, each of a specified
quantity, for each huge page size. The available huge page size options on x86_64 platforms
are 2 MB and 1 GB.
For more information about configuring HugeTLB pages, see Configuring HugeTLB Pages
Note:
Best Practices:
• Make requests to the kernel for static huge pages as close to boot time as
possible, when the occurrence of memory fragmentation is at a minimum.
• Huge pages can reduce the amount of memory available to the system.
Therefore, when requesting a reserved huge page pool, ensure the pool isn't
oversized and that the system’s access to memory isn't impacted.
6-1
Chapter 6
Configuring HugeTLB Pages
Transparent HugePages
The Transparent HugePages (THP) feature is enabled by default in Oracle Linux. With THP,
the kernel automatically assigns huge pages to processes. With THP, you can assign only 2
MB pages on x86_64 platforms.
THP can run in the following modes:
• system-wide (default): The kernel assigns huge pages to processes that use large
contiguous virtual memory areas whenever it's possible to do so.
• per-process: The kernel only assigns huge pages to application processes that explicitly
request huge pages through the madvise() system call.
For more information about configuring THP, see Configuring Transparent HugePages
Table 6-1 The Kernel Boot Command Line Parameters for Requesting HugeTLB Pages
6-2
Chapter 6
Configuring HugeTLB Pages
Table 6-1 (Cont.) The Kernel Boot Command Line Parameters for Requesting HugeTLB
Pages
hugepagesz=1G
hugepages=4
hugepagesz=2M
hugepages=1500
Note:
In a NUMA system, pages reserved with kernel command line options, as shown in
the previous table, are divided equally between the NUMA nodes.
If the requirement is to have a different number of pages on each node, you can use
the file-based HugeTLB parameters in the sysfs file system. See File-Based
Configuration Parameters for HugeTLB Pages and Requesting HugeTLB Pages
Using NUMA Node Specific Parameters Early in the Boot Process.
6-3
Chapter 6
Configuring HugeTLB Pages
Note:
In addition to accessing the settings at runtime, you can also initialize the parameters
early in the boot process, for example, by creating a start-up bash script or by setting
the parameters up in a local rc init script.
Multiple instances of each file-based parameter can be configured on a system. For example,
on a system that can handle both 2 MB and 1 GB HugeTLB page sizes, several nr_hugepages
settings can exist. This parameter defines the number of pages in a pool, including the
following:
• File /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages for the
number of pages in the pool of 2 MB pages.
• File /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages for the
number of pages in the pool of 1 GB pages.
The following table outlines commonly used HugeTLB configuration parameters and the
multiple file instances that you might find for each parameter.
6-4
Chapter 6
Configuring HugeTLB Pages
Note:
Use the NUMA
node specific
path format if
you need to
request different
quantities of
pages of
different sizes to
be supported on
specific NUMA
nodes. If you use
any other path
format (for
example, /
proc/sys/vm/
nr_hugepages
) to request
HugeTLB pages.
The pages are
divided equally
between the
NUMA nodes.
6-5
Chapter 6
Configuring HugeTLB Pages
6-6
Chapter 6
Configuring HugeTLB Pages
e
spe
cifi
c
file
exi
sts
for
this
sett
ing.
6-7
Chapter 6
Configuring HugeTLB Pages
The following sections show file branches under which different instances of the HugeTLB
parameters are stored:
/proc/sys/vm
All systems that support static huge pages contain HugeTLB parameter files under /
proc/sys/vm.
Note:
On many systems, including many Oracle database servers, the procfs file system is
the main parameter-set used.
The sysctl parameter vm.nr_hugepages that's commonly initialized in scripts that
request huge pages also writes to the procfs file /proc/sys/vm/nr_hugepages.
├── ...
├── ...
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
├── ...
6-8
Chapter 6
Configuring HugeTLB Pages
/sys/kernel/mm/hugepages/
Systems that support multiple size pools contain HugeTLB parameter files in size-specific
folders under /sys/kernel/mm/hugepages/.
└── hugepages-2048kB
├── free_hugepages
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
└── surplus_hugepages
└── hugepages-1048576kB
├── free_hugepages
├── nr_hugepages
├── ...
├── nr_overcommit_hugepages
├── ...
└── surplus_hugepages
/sys/devices/system/node/
Only NUMA systems contain HugeTLB parameter files under /sys/devices/system/node/.
├─ ...
├── node0
│ ├── ...
│ ├──hugepages
│ hugepages-2048kB
│ ├── free_hugepages
│ ├── nr_hugepages
│ └── surplus_hugepages
│
│ hugepages-1048576kB
│ ├── free_hugepages
│ ├── nr_hugepages
│ └── surplus_hugepages
├── node1
├── ...
├──hugepages
hugepages-2048kB
├── free_hugepages
├── nr_hugepages
└── surplus_hugepages
hugepages-1048576kB
├── free_hugepages
├── nr_hugepages
└── surplus_hugepages
6-9
Chapter 6
Configuring HugeTLB Pages
3. The next time the system boots, the two huge page pools are requested.
Requesting HugeTLB Pages Using NUMA Node Specific Parameters Early in the
Boot Process
Huge Pages requested by using the kernel boot-time parameters, as shown in the previous
example, are divided equally between the NUMA nodes.
However, you might need to request a different number of huge pages for specific nodes by
setting the configuration values in a node specific file path. The file path is defined as follows:.
/sys/devices/system/node/node{0,1,2…n}/hugepages/hugepages-<SIZE>kB/
The following procedure describes how to reserve 299 pages of 2 MB size on node 0, and 300
pages of 2 MB size on node 1 on a NUMA system.
Before beginning the following procedure, ensure that you have the administrative privileges
required for all of the steps.
6-10
Chapter 6
Configuring HugeTLB Pages
#!/bin/sh
nodes_path=/sys/devices/system/node/
if [ ! -d $nodes_path ]; then
echo "ERROR: $nodes_path does not exist"
exit 1
fi
#######################################################
# #
# FUNCTION #
# reserve_pages <number_of_pages> <node_id> #
# #
#######################################################
reserve_pages()
{
echo $1 > $nodes_path/$2/hugepages/hugepages-2048kB/nr_hugepages
}
[Unit]
Description=HugeTLB Gigantic Pages Reservation
DefaultDependencies=no
Before=dev-hugepages.mount
ConditionPathExists=/sys/devices/system/node
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/hugetlb-reserve-pages.sh
[Install]
WantedBy=sysinit.target
6-11
Chapter 6
Configuring Transparent HugePages
2. Add the required number of huge pages of a specified size to the selected node, for
example 20 pages of 2 MB size on node 2:
3. Run the numastat command again to ensure the request was successful and that the
requested memory (in our example 20 x 2 MB pages = 40 MB) has been added
HugePages_Total for node2:
6-12
Chapter 6
Configuring Transparent HugePages
6-13
Chapter 6
Configuring Transparent HugePages
6-14
Chapter 6
Configuring Transparent HugePages
The value inside the square brackets represents the current setting.
The value inside the square brackets represents the current setting.
2. Set THP mode to always.
3. Confirm the change has been successful by reading the enabled parameter.
6-15
Chapter 6
Configuring Transparent HugePages
Note:
Virtual file systems such as sysfs provide a file system interface to items that aren't
necessarily stored as files on disk. The sysfs files therefore don't always interact with
file commands in the same way that regular physical files on disk would. In the
previous example, the echo command used doesn't overwrite /sys/kernel/mm/
transparent_hugepage/enabled, as it would if used with a regular file, but
instead changes the selected option:
always
Note:
The best defrag setting varies from system to system. Reclaiming pages and
memory compaction can increase the number of THP pages available. However, the
process also uses CPU time. Therefore, you need to find the correct balance for a
specific system.
The following example shows you how to set the defrag setting to madvise.
6-16
Chapter 6
Configuring Transparent HugePages
6-17
7
Managing Resources
This chapter describes how to manage the use of resources in an Oracle Linux system.
You can also create cgroups of your own by creating your own folders under the /sys/fs/
cgroup virtual file system and assigning process IDs (PIDs) to different cgroups according to
your system needs. However, the recommended practice is to use systemd to configure
cgroups instead of creating the cgroups manually under /sys/fs/cgroup. See Using
systemd to Manage cgroups v2 for the recommended method of managing cgroups through
systemd.
7-1
Chapter 7
About Kernel Resource Controllers
Note:
Use systemd to configure cgroups.
Both versions are present in Oracle Linux. However, by default, the cgroups v1 functionality is
enabled and mounted on Oracle Linux 8 systems.
For more information about control groups of both versions, see the cgroups(7) and sysfs(5)
manual pages.
less /proc/cgroups
7-2
Chapter 7
About the Control Group File System
pids 0 103 1
rdma 0 103 1
misc 0 103 1
For a detailed explanation of the kernel resource controllers of both cgroups v1 and cgroups
v2, see the cgroups(7) manual page.
The directory /sys/fs/cgroup is also called the root control group. The contents of the root
control group directory differ depending on which cgroup version is mounted on the system.
For cgroups v2, the directory contents are as follows:
ls /sys/fs/cgroup
You can use the mkdir command to create your own cgroup subdirectories below the root
control group. For example, you might create the following cgroup subdirectories:
• /sys/fs/cgroup/MyGroups/
• /sys/fs/cgroup/MyGroups/cgroup1
• /sys/fs/cgroup/MyGroups/cgroup2
Note:
Best practice is to create child cgroups at least 2 levels deep inside the /sys/fs/
cgroup. The examples in the preceding list follow this practice by using the first child
group, MyGroups, as a parent that contains the different cgroups needed for the
system.
cgroup.controllers
This read-only file lists the controllers available in the current cgroup. The contents of this file
match the contents of the cgroup.subtree_control file in the parent cgroup.
7-3
Chapter 7
About Control Groups and systemd
cgroup.subtree_control
This file contains those controllers in the cgroup.controllers file that are enabled for the
current cgroup's immediate child cgroups.
When a controller (for example, pids) is present in the cgroup.subtree_control file, the
corresponding controller-interface files (for example, pids.max) are automatically created in
the immediate children of the current cgroup.
For a sample procedure that creates child groups where you can implement resource
management for an application, see Setting CPU Weight to Regulate Distribution of CPU Time.
To remove a cgroup, ensure that the cgroup doesn't contain other child groups, and then
remove the directory. For example, to remove child group /sys/fs/cgroup/MyGroups/cgroup1
you can run the following command:.
Systemd provides different unit types, three of which are for resource control purposes:
sudo systemd-cgls
7-4
Chapter 7
About Resource Distribution Models
For an example of how to use systemd commands such as systemctl to manage resources,
see Controlling Access to System Resources. For further technical details, see the
systemctl(1), systemd-cgls(1), and systemd.resource-control(5) manual pages.
Weights
In this model, the weights of all the control groups are totaled. Each group receives a fraction
of the resource based on the ratio of the group's weight against the total weight.
Consider 10 control groups, each with a weight of 100 for a combined total of 1000. In this
case, each group can use a tenth of a specified resource.
Weight is typically used to distribute stateless resources. To apply this resource, the
CPUWeight option is used.
7-5
Chapter 7
Using cgroups v2 to Manage Resources for Applications
Limits
A control group can use the configured amount of a resource. However, you can also
overcommit resources. Therefore, the sum of the subgroups limits can exceed the limit of the
parent group.
To implement this distribution model, the MemoryMax option is used.
Protections
In this model, a group is assigned a protected boundary. If the group's resource usage
remains within the protected amount, the kernel can't deprive the group of the use of the
resource in favor of other groups that are competing for the same resource. In this model, an
overcommitment of resources is allowed.
To implement this model, the MemoryLow option is used.
Allocations
In this model, a specific absolute amount is allocated for the use of finite type of resources,
such as real-time budget.
The sample procedure included in this section involves allocating CPU time between cgroups
that each have different application PIDs assigned to them. The CPU time and application PID
values are set in each group's cpu.weight and cgroup.procs files.
The section also includes the steps required to ensure the cpu controller and its associated
files, including the cpu.weight file, are available in the cgroups you need to create
under /sys/fs/cgroup when following the sample procedure.
Enabling cgroups v2
At boot time, Oracle Linux 8 mounts cgroups v1 by default. To use cgroups v2, you must
manually configure the system.
1. Verify that cgroups v2 is enabled and mounted on the system.
If the output of the command doesn't specify cgroup2, then do the following to enable
version 2.
a. Configure the system boot to mount cgroups v2 by default.
7-6
Chapter 7
Using cgroups v2 to Manage Resources for Applications
2. Optionally, check the contents of /sys/fs/cgroup directory, which is also called the root
control group.
ll /sys/fs/cgroup/
For cgroups v2, the files in the directory should have prefixes to their file names, for
example, cgroup.*, cpu.*, memory.*, and so on. See About the Control Group File System.
You can add any controllers listed in the cgroup.controllers file to the
cgroup.subtree_control file in the same directory to make them available to the group's
immediate child cgroups.
2. Add the cpu controller to the cgroup.subtree_control file to make it available to
immediate child cgroups of the root.
By default, only the memory and pids controllers are in the file. To add the cpu controller,
type:
3. Optionally, verify that the cpu controller has been added as expected.
4. Create a child group under the root control group to become the new control group for
managing CPU resources on applications.
7-7
Chapter 7
Using cgroups v2 to Manage Resources for Applications
5. Optionally, list the contents of the new subdirectory, or child group, and confirm that the cpu
controller is present as expected:
ll /sys/fs/cgroup/MyGroups
7. Optionally, verify that the cpu controller is enabled for child groups under MyGroups.
cpu
sudo top
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
33301 root 20 0 18720 1756 1468 R 99.0 0.0 0:31.09
sha1sum
7-8
Chapter 7
Using cgroups v2 to Manage Resources for Applications
• The sha1sum processes have PIDs 33301, 33302, and 33303, as listed in the preceding
sample output.
Important:
As a prerequisite to the following procedure, you must complete the preparations of
cgroup-v2 as described in Preparing the Control Group for Distribution of CPU Time.
If you skipped those preparations, you can't complete this procedure.
These commands set the selected applications to become members of the MyGroups/g*/
control groups. The CPU time for each sha1sum process depends on the CPU time
distribution as configured for each group.
The weights of the g1, g2, and g3 groups that have running processes are summed up at
the level of MyGroups, which is the parent control group.
With this configuration, when all processes run at the same time, the kernel allocates to
each of the sha1sum processes the proportionate CPU time based on their respective
cgroup's cpu.weight file, as follows:
7-9
Chapter 7
Using systemd to Manage cgroups v2
If one child group has no running processes, then the CPU time allocation for running
processes is recalculated based on the total weight of the remaining child groups with
running processes. For example, if the g2 child group doesn't have any running processes,
then the total weight becomes 200, which is the weight of g1+g3. In this case, the CPU
time for g1 becomes 150/200 (~75%) and for g3, 50/200 (~25%)
4. Check that the applications are running in the specified control groups.
0::/MyGroups/g1
0::/MyGroups/g2
0::/MyGroups/g3
5. Check the current CPU consumption after you have set the CPU weights.
top
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
33301 root 20 0 18720 1748 1460 R 49.5 0.0 415:05.87
sha1sum
33302 root 20 0 18720 1756 1464 R 32.9 0.0 412:58.33
sha1sum
33303 root 20 0 18720 1860 1568 R 16.3 0.0 411:03.12
sha1sum
760 root 20 0 416620 28540 15296 S 0.3 0.7 0:10.23
tuned
1 root 20 0 186328 14108 9484 S 0.0 0.4 0:02.00
systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01
kthread
...
Note:
For information on enabling cgroups v2 functionality on your system, see Enabling
cgroups v2
7-10
Chapter 7
Using systemd to Manage cgroups v2
By default, systemd creates a cgroup folder for each systemd service set up on the host.
systemd names these folders using the format servicename.service, where servicename is
the name of the service associated with the folder.
To see a list of the cgroup folders systemd creates for the services, run the ls command on the
system.slice branch of the cgroup file system as shown in the following sample code block:
ls /sys/fs/cgroup/system.slice/
... ... ...
app_service1.service cgroup.subtree_control httpd.service
app_service2.service chronyd.service ...
... crond.service ...
cgroup.controllers dbus-broker.service ...
cgroup.events dtprobed.service ...
cgroup.freeze firewalld.service ...
... gssproxy.service ...
... ... ...
ls /sys/fs/cgroup/user.slice/
cgroup.controllers cgroup.subtree_control user-1001.slice
cgroup.events cgroup.threads user-982.slice
cgroup.freeze cgroup.type ...
... ... ...
... ... ...
... ... ...
Thus, systemd enables you to manage resource distribution at an application level, rather than
the process PID level used when configuring cgroups without using systemd functionality.
7-11
Chapter 7
Using systemd to Manage cgroups v2
Note:
You can also create your own custom slices for resource distribution, as shown in
section Setting Resource Controller Options and Creating Custom Slices.
Figure 7-1 Pie chart illustrating distribution in a resource controller, such as CPU or
Memory
As the preceding pie chart shows, by default each resource controller is divided equally
between the following 3 slices:
• System (system.slice).
• User (user.slice).
• Machine (machine.slice).
The following list looks at each slice more closely. For the purposes of discussion, the
examples in the list focus on the CPU controller.
System (system.slice)
This resource slice is used for managing resource allocation amongst daemons and service
units.
7-12
Chapter 7
Using systemd to Manage cgroups v2
As shown in the preceding example pie chart, the system slice is divided into further sub-
slices. For example, in the case of CPU resources, we might have sub-slice allocations within
the system slice that include the following:
• httpd.service (CPUWeight=100)
• sshd.service (CPUWeight =100)
• crond.service (CPUWeight =100)
• app1.service (CPUWeight =100)
• app2.service (CPUWeight =100)
In the preceding list, app1.service and app2.service represent custom application services
you might have running on your system.
User (user.slice)
This resource slice is used for managing resource allocation amongst user sessions. A single
slice is created for each UID irrespective of how many logins the associated user has active on
the server. Continuing with our pie chart example, the sub-slices might be as follows:
• user1 (CPUWeight=100, UID=982)
• user2 (CPUWeight=100, UID=1001)
Machine (machine.slice)
This slice of the resource is used for managing resource allocation amongst hosted virtual
machines, such as KVM guests, and Linux Containers. The machine slice is only present on a
server if the server is hosting virtual machines or Linux Containers.
Note:
Share allocations do not set a maximum limit for a resource.
For instance, in the preceding examples, the slice user.slice has 2 users: user1
and user2. Each user is allocated an equal share of the CPU resource available to
the parent user.slice. However, if the processes associated with user1 are idle, and
do not require any CPU resource, then its CPU share is available for allocation to
user2 if needed. In such a situation, user2 might even be allocated the entire CPU
resource apportioned to the parent user.slice if it is required by other users.
To cap CPU resource, you would need to set the CPUQuota property to the required
percentage.
7-13
Chapter 7
Using systemd to Manage cgroups v2
Tip:
To see the entire cgroup hierarchy, starting from the root slice -.slice, as in the
following example, ensure you run systemd-cgls from outside of the control group
mount point /sys/fs/cgroup/. Otherwise, If you run the command from
within /sys/fs/cgroup/, the output starts from the cgroup location from which the
command was run. See systemd-cgls(1) for more information.
systemd-cgls
Control group /:
-.slice
...
├─user.slice (#1429)
│ → user.invocation_id: 604cf5ef07fa4bb4bb86993bb5ec15e0
│ ├─user-982.slice (#4131)
│ │ → user.invocation_id: 9d0d94d7b8a54bcea2498048911136c8
│ │ ├─session-c1.scope (#4437)
│ │ │ ├─2416 /usr/bin/sudo -u ocarun /usr/libexec/oracle-cloud-agent/plugins/
runcommand/runcommand
│ │ │ └─2494 /usr/libexec/oracle-cloud-agent/plugins/runcommand/runcommand
│ │ └─[email protected] … (#4199)
│ │ → user.delegate: 1
│ │ → user.invocation_id: 37c7aed7aa6e4874980b79616acf0c82
│ │ └─init.scope (#4233)
│ │ ├─2437 /usr/lib/systemd/systemd --user
│ │ └─2445 (sd-pam)
│ └─user-1001.slice (#7225)
│ → user.invocation_id: ce93ad5f5299407e9477964494df63b7
│ ├─session-2.scope (#7463)
│ │ ├─20304 sshd: oracle [priv]
│ │ ├─20404 sshd: oracle@pts/0
│ │ ├─20405 -bash
│ │ ├─20441 systemd-cgls
│ │ └─20442 less
│ └─[email protected] … (#7293)
│ → user.delegate: 1
│ → user.invocation_id: 70284db060c1476db5f3633e5fda7fba
│ └─init.scope (#7327)
│ ├─20395 /usr/lib/systemd/systemd --user
│ └─20397 (sd-pam)
├─init.scope (#19)
│ └─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 28
└─system.slice (#53)
...
├─dbus-broker.service (#2737)
│ → user.invocation_id: 2bbe054a2c4d49809b16cb9c6552d5a6
│ ├─1450 /usr/bin/dbus-broker-launch --scope system --audit
│ └─1457 dbus-broker --log 4 --controller 9 --machine-id
852951209c274cfea35a953ad2964622 --max-bytes 536870912 --max-fds 4096 --max-
matches 131072 --audit
...
7-14
Chapter 7
Using systemd to Manage cgroups v2
├─chronyd.service (#2805)
│ → user.invocation_id: e264f67ad6114ad5afbe7929142faa4b
│ └─1482 /usr/sbin/chronyd -F 2
├─auditd.service (#2601)
│ → user.invocation_id: f7a8286921734949b73849b4642e3277
│ ├─1421 /sbin/auditd
│ └─1423 /usr/sbin/sedispatch
├─tuned.service (#3349)
│ → user.invocation_id: fec7f73678754ed687e3910017886c5e
│ └─1564 /usr/bin/python3 -Es /usr/sbin/tuned -l -P
├─systemd-journald.service (#1837)
│ → user.invocation_id: bf7fb22ba12f44afab3054aab661aedb
│ └─1068 /usr/lib/systemd/systemd-journald
├─atd.service (#3961)
│ → user.invocation_id: 1c59679265ab492482bfdc9c02f5eec5
│ └─2146 /usr/sbin/atd -f
├─sshd.service (#3757)
│ → user.invocation_id: 57e195491341431298db233e998fb180
│ └─2097 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
├─crond.service (#3995)
│ → user.invocation_id: 4f5b380a53db4de5adcf23f35d638ff5
│ └─2150 /usr/sbin/crond -n
...
The preceding sample output shows how all "*.slice" control groups reside under the root
slice -.slice. Beneath the root slice you can see the user.slice and system.slice control
groups, each with their own child cgroup sub-slices.
Examining the systemd-cgls command output you can see how, with the exception of root
-.slice , all processes are on leaf nodes. This arrangement is enforced by cgroups v2, in a
rule called the "no internal processes" rule. See cgroups (7) for more information about the
"no internal processes" rule.
The output in the preceding systemd-cgls command example also shows how slices can
have descendent child control groups that are systemd scopes. systemd scopes are reviewed
in the following section.
systemd Scopes
systemd scope is a systemd unit type that groups together system service worker processes
that have been launched independently of systemd. The scope units are transient cgroups
created programmatically using the bus interfaces of systemd.
For example, in the following sample code, the user with UID 1001 has run the systemd-cgls
command, and the output shows session-2.scope has been created for processes the user
has spawned independently of systemd (including the process for the command itself , 21380
sudo systemd-cgls):
7-15
Chapter 7
Using systemd to Manage cgroups v2
Note:
In the following example, the command has been run from within the control group
mount point /sys/fs/cgroup/. Hence, instead of the root slice, the output starts from
the cgroup location from which the command was run.
sudo systemd-cgls
7-16
Chapter 7
Using systemd to Manage cgroups v2
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/generate_load.sh
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
2. The service created in the preceding step requires a bash script /usr/lib/systemd/
generate_load.sh. Create the file with the following content:
#!/bin/bash
for i in {1..4};do while : ; do : ; done & done
5. Run the systemd-cgls command and confirm the service myservice1 is running under
system.slice:
systemd-cgls
Control group /:
-.slice
...
├─user.slice (#1429)
...
└─system.slice (#53)
...
├─myservice1.service (#7939)
│ → user.invocation_id: e227f8f288444fed92a976d391e6a897
│ ├─22325 /bin/bash /usr/lib/systemd/generate_load.sh
│ ├─22326 /bin/bash /usr/lib/systemd/generate_load.sh
│ ├─22327 /bin/bash /usr/lib/systemd/generate_load.sh
│ └─22328 /bin/bash /usr/lib/systemd/generate_load.sh
├─pmie.service (#4369)
│ → user.invocation_id: 68fcd40071594481936edf0f1d7a8e12
...
7-17
Chapter 7
Using systemd to Manage cgroups v2
[Service]
Slice=my_custom_slice.slice
Type=oneshot
ExecStart=/usr/lib/systemd/generate_load.sh
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
NOT_SUPPORTED:
Use underscores instead of dashes to separate terms in slice names.
In systemd, a dash in a slice name is a special character: in systemd, dashes in
slice names are used to describe the full cgroup path to the slice (starting from
the root slice). For example, if you specify a slice name as "my-custom-
slice.slice", instead of creating a slice of that name, systemd creates the
following cgroups path underneath the root slice: my.slice/my-
custom.slice/my-custom-slice.slice.
7. After editing the file, ensure systemd reloads its configuration files and then restart the
service:
8. Run the systemd-cgls command and confirm the service myservice1 is now running under
custom slice my_custom_slice:
systemd-cgls
Control group /:
-.slice
...
├─user.slice (#1429)
...
├─my_custom_slice.slice (#7973)
│ → user.invocation_id: a8a493a8db1342be85e2cdf1e80255f8
│ └─myservice1.service (#8007)
│ → user.invocation_id: 9a4a6171f2844e479d4a0f347aac38ce
│ ├─22385 /bin/bash /usr/lib/systemd/generate_load.sh
│ ├─22386 /bin/bash /usr/lib/systemd/generate_load.sh
│ ├─22387 /bin/bash /usr/lib/systemd/generate_load.sh
│ └─22388 /bin/bash /usr/lib/systemd/generate_load.sh
├─init.scope (#19)
│ └─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 28
└─system.slice (#53)
7-18
Chapter 7
Using systemd to Manage cgroups v2
├─irqbalance.service (#2907)
│ → user.invocation_id: 00d64c9b9d224f179496a83536dd60bb
│ └─1464 /usr/sbin/irqbalance --foreground
...
Tip:
The "drop-in" directory for drop-in files for a service is located at /etc/
systemd/system/service_name.service.d where service_name is the
name of the service.
Continuing with our example with service myservice1, we would run the following
command:
Note:
• Multiple drop-in files with different names are applied in lexicographic order.
• These drop-in files take precedence over the service unit file.
[Service]
Slice=my_custom_slice2.slice
MemoryAccounting=yes
CPUAccounting=yes
[Service]
CPUWeight=200
4. Create a second service (myservice2) and assign it a different CPUWeight to that assigned
to myservice1:
a. Create file /etc/systemd/system/myservice2.service with the following contents:
[Service]
Slice=my_custom_slice2.slice
Type=oneshot
7-19
Chapter 7
Using systemd to Manage cgroups v2
ExecStart=/usr/lib/systemd/generate_load2.sh
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
b. The service created in the preceding step requires a bash script /usr/lib/
systemd/generate_load2.sh. Create the file with the following content:
#!/bin/bash
for i in {1..4};do while : ; do : ; done & done
[Service]
CPUWeight=400
5. Ensure systemd reloads its configuration files, and restart myservice1, and also enable
and start myservices2:
6. Run the systemd-cgtop command to display control groups ordered by their resource
usage. You can see from the following sample output how, in addition to the resource
usage of each slice, the systemd-cgtop command displays resource usage breakdown
within each slice, so you can use it to confirm your CPU weight has been divided as
expected.
systemd-cgtop
7-20
Chapter 7
Using systemd to Manage cgroups v2
9.4M - -
system.slice 60 0.0
690.8M - -
/etc/systemd/system.control
Caution:
You must not manually edit the files systemctl set-property command creates.
Note:
The systemctl set-property command does not recognize every resource-control
property used in the system-unit and drop-in files covered earlier in this topic.
The following procedure demonstrates how you can use the systemctl set-property
command to configure resource allocation:
1. Continuing with our example, create another service file at location /etc/systemd/
system/myservice3.service with the following content:
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/generate_load3.sh
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
2. Set the slice for the service to be my_custom_slice2 (the same slice used by the services
created in from earlier steps) by adding the following line to the [Service] section in the
myservice3.service file:
Slice=my_custom_slice2.slice
Note:
The slice must be set in the service-unit file because the systemctl set-
property command does not recognize the Slice property.
7-21
Chapter 7
Using systemd to Manage cgroups v2
3. The service created in the preceding step requires a bash script /usr/lib/systemd/
generate_load3.sh. Create the file with the following content:
#!/bin/bash
for i in {1..4};do while : ; do : ; done & done
5. Ensure systemd reloads its configuration files, and then enable and start the service:
6. Optionally run the to systemd-cgtop confirm all 3 services, , myservice1, myservice2, and
myservice3, are all running in the same slice.
7. Use systemctl set-property command to set the CPUWeight for myservice3 to 800:
8. You can optionally confirm that a drop-in file has been created for you under /etc/
systemd/system.control/myservice3.service.d. However, you must not edit the
file:
cat /etc/systemd/system.control/myservice3.service.d/50-CPUWeight.conf
Ensure systemd reloads its configuration files, and restart all the services:
9. Run the systemd-cgtop command to confirm your CPU weight has been divided as
expected:
systemd-cgtop
7-22
Chapter 7
Using cgroups v2 to Manage Resources for Users
my_custom_slice2.slice/myservice3.service 4 112.7
976.0K - -
my_custom_slice2.slice/myservice2.service 4 56.9
996.0K - -
my_custom_slice2.slice/myservice1.service 4 28.8
988.0K - -
user.slice 18 0.9
44.1M - -
user.slice/user-1001.slice 6 0.9
13.9M - -
user.slice/user-1001.slice/session-2.scope 4 0.9
9.5M - -
7-23