systemctl-freeze
Freeze system processes and services
TLDR
Freeze a specific unit
Freeze multiple units
Freeze all running units
SYNOPSIS
systemctl freeze [UNIT...]
systemctl thaw [UNIT...]
PARAMETERS
UNIT...
The name(s) of one or more systemd units (e.g., 'apache2.service', 'multi-user.target') whose processes are to be frozen or thawed. If no units are specified, the command will typically do nothing or report an error depending on systemd version.
DESCRIPTION
systemctl freeze is a subcommand of systemctl used to pause the execution of processes belonging to one or more specified systemd units. Conversely, systemctl thaw resumes their execution.
This functionality relies on the Linux kernel's cgroups freezer controller, which allows an administrator to stop all processes within a particular control group. When a unit is frozen, all processes that systemd manages for that unit are placed into a frozen state, preventing them from consuming CPU cycles or performing I/O operations.
The primary use cases for freezing services include preparing a system for a consistent snapshot or backup operation, performing maintenance on a dependent service without stopping the primary service entirely, or temporarily pausing a service for debugging purposes. It provides a mechanism to achieve a "quiesced" state for specific applications or services, which is crucial for data integrity during critical operations. It's important to note that systemctl freeze does not suspend the entire system, but only the processes within the designated systemd units' cgroups.
CAVEATS
Incomplete Freeze: The freezer only affects processes within the designated cgroup. Processes that fork and then escape the cgroup, or processes not managed by systemd, will not be affected.
Resource Dependency: Requires the Linux kernel's cgroup freezer controller to be available and enabled (either v1 or v2).
Application Behavior: Frozen applications might experience timeouts or become unresponsive, potentially leading to errors or crashes if not managed carefully. It's not suitable for all applications.
Not a System Suspend: This command does not suspend the entire operating system; it only targets specific service processes.
Potential for Deadlock: If core system services are frozen indiscriminately, it could lead to system instability or deadlocks.
<B>USE CASES</B>
- Snapshot Creation: Essential for creating consistent filesystem or VM snapshots, ensuring that services are paused and data is flushed to disk before the snapshot.
- Backup Operations: Facilitates hot backups by momentarily freezing services to ensure data integrity during the backup window.
- Maintenance & Debugging: Allows administrators to pause a service to perform dependent maintenance, inspect its state, or debug issues without shutting it down and restarting.
<B>CGROUP FREEZER CONTROLLER</B>
The command relies on the kernel's cgroup freezer controller, which provides a mechanism to set the state of all tasks in a cgroup to "frozen" or "thawed". This is a low-level kernel feature that systemd abstracts and makes accessible via systemctl freeze and thaw.
HISTORY
The systemctl freeze and systemctl thaw commands were introduced as part of systemd to leverage the Linux kernel's cgroups freezer controller functionality. This feature allows systemd to manage process states at a finer granularity, particularly useful for scenarios requiring process quiescence without full termination. Its development is intertwined with the evolution of systemd itself and the increasing adoption of cgroups for resource management and isolation in Linux systems.


