$linuxjunkies
>

swap unit

also: swap service, .swap unit

A swap unit is a systemd service unit that manages swap space (virtual memory) on a Linux system, typically representing a swap partition or swap file that extends available memory.

A swap unit in systemd is a unit file with a .swap extension that describes and manages swap space resources. Swap allows the kernel to move less-frequently used memory pages to disk, freeing up physical RAM for active processes when memory pressure is high.

Swap units are automatically generated by systemd for swap devices found in /etc/fstab, or can be explicitly defined in /etc/systemd/system/. For example, a swap partition might be represented as dev-sda2.swap if located at /dev/sda2, while a swap file might be swapfile.swap.

You can view active swap units with systemctl list-units --type swap, and control them like other systemd units using systemctl start, stop, or enable commands. Modern systems often prefer swap files over partitions since they're more flexible and easier to resize.

Related terms