{
    "mode": "info",
    "parameter": "systemd.swap",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/systemd.swap/json",
    "generated": "2026-07-05T02:25:22Z",
    "synopsis": "swap.swap",
    "sections": {
        "NAME": {
            "content": "systemd.swap - Swap unit configuration\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "swap.swap\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A unit configuration file whose name ends in \".swap\" encodes\ninformation about a swap device or file for memory paging controlled\nand supervised by systemd.\n\nThis man page lists the configuration options specific to this unit\ntype. See systemd.unit(5) for the common options of all unit\nconfiguration files. The common configuration items are configured in\nthe generic [Unit] and [Install] sections. The swap specific\nconfiguration options are configured in the [Swap] section.\n\nAdditional options are listed in systemd.exec(5), which define the\nexecution environment the swapon(8) program is executed in, in\nsystemd.kill(5), which define the way these processes are terminated,\nand in systemd.resource-control(5), which configure resource control\nsettings for these processes of the unit.\n\nSwap units must be named after the devices or files they control.\nExample: the swap device /dev/sda5 must be configured in a unit file\ndev-sda5.swap. For details about the escaping logic used to convert a\nfile system path to a unit name, see systemd.unit(5). Note that swap\nunits cannot be templated, nor is possible to add multiple names to a\nswap unit by creating additional symlinks to it.\n\nNote that swap support on Linux is privileged, swap units are hence\nonly available in the system service manager (and root's user service\nmanager), but not in unprivileged user's service manager.\n",
            "subsections": []
        },
        "AUTOMATIC DEPENDENCIES": {
            "content": "Implicit Dependencies\nThe following dependencies are implicitly added:\n\no   All swap units automatically get the BindsTo= and After=\ndependencies on the device units or the mount units of the files\nthey are activated from.\n\nAdditional implicit dependencies may be added as result of execution\nand resource control parameters as documented in systemd.exec(5) and\nsystemd.resource-control(5).\n\nDefault Dependencies\nThe following dependencies are added unless DefaultDependencies=no is\nset:\n\no   Swap units automatically acquire a Conflicts= and a Before=\ndependency on umount.target so that they are deactivated at\nshutdown as well as a Before=swap.target dependency.\n",
            "subsections": []
        },
        "FSTAB": {
            "content": "Swap units may either be configured via unit files, or via /etc/fstab\n(see fstab(5) for details). Swaps listed in /etc/fstab will be\nconverted into native units dynamically at boot and when the\nconfiguration of the system manager is reloaded. See systemd-fstab-\ngenerator(8) for details about the conversion.\n\nIf a swap device or file is configured in both /etc/fstab and a unit\nfile, the configuration in the latter takes precedence.\n\nWhen reading /etc/fstab, a few special options are understood by\nsystemd which influence how dependencies are created for swap units.\n\nnoauto, auto\nWith noauto, the swap unit will not be added as a dependency for\nswap.target. This means that it will not be activated automatically\nduring boot, unless it is pulled in by some other unit. The auto\noption has the opposite meaning and is the default.\n\nnofail\nWith nofail, the swap unit will be only wanted, not required by\nswap.target. This means that the boot will continue even if this\nswap device is not activated successfully.\n\nx-systemd.device-timeout=\nConfigure how long systemd should wait for a device to show up\nbefore giving up on an entry from /etc/fstab. Specify a time in\nseconds or explicitly append a unit such as \"s\", \"min\", \"h\", \"ms\".\n\nNote that this option can only be used in /etc/fstab, and will be\nignored when part of the Options= setting in a unit file.\n\nx-systemd.makefs\nThe swap structure will be initialized on the device. If the device\nis not \"empty\", i.e. it contains any signature, the operation will\nbe skipped. It is hence expected that this option remains set even\nafter the device has been initialized.\n\nNote that this option can only be used in /etc/fstab, and will be\nignored when part of the Options= setting in a unit file.\n\nSee systemd-mkswap@.service(8) and the discussion of wipefs(8) in\nsystemd.mount(5).\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Swap unit files must include a [Swap] section, which carries\ninformation about the swap device it supervises. A number of options\nthat may be used in this section are shared with other unit types.\nThese options are documented in systemd.exec(5) and systemd.kill(5).\nThe options specific to the [Swap] section of swap units are the\nfollowing:\n\nWhat=\nTakes an absolute path of a device node or file to use for paging.\nSee swapon(8) for details. If this refers to a device node, a\ndependency on the respective device unit is automatically created.\n(See systemd.device(5) for more information.) If this refers to a\nfile, a dependency on the respective mount unit is automatically\ncreated. (See systemd.mount(5) for more information.) This option\nis mandatory. Note that the usual specifier expansion is applied to\nthis setting, literal percent characters should hence be written as\n\"%%\".\n\nPriority=\nSwap priority to use when activating the swap device or file. This\ntakes an integer. This setting is optional and ignored when the\npriority is set by pri= in the Options= key.\n\nOptions=\nMay contain an option string for the swap device. This may be used\nfor controlling discard options among other functionality, if the\nswap backing device supports the discard or trim operation. (See\nswapon(8) for more information.) Note that the usual specifier\nexpansion is applied to this setting, literal percent characters\nshould hence be written as \"%%\".\n\nTimeoutSec=\nConfigures the time to wait for the swapon command to finish. If a\ncommand does not exit within the configured time, the swap will be\nconsidered failed and be shut down again. All commands still\nrunning will be terminated forcibly via SIGTERM, and after another\ndelay of this time with SIGKILL. (See KillMode= in\nsystemd.kill(5).) Takes a unit-less value in seconds, or a time\nspan value such as \"5min 20s\". Pass \"0\" to disable the timeout\nlogic. Defaults to DefaultTimeoutStartSec= from the manager\nconfiguration file (see systemd-system.conf(5)).\n\nCheck systemd.exec(5) and systemd.kill(5) for more settings.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "systemd(1), systemctl(1), systemd-system.conf(5), systemd.unit(5),\nsystemd.exec(5), systemd.kill(5), systemd.resource-control(5),\nsystemd.device(5), systemd.mount(5), swapon(8), systemd-fstab-\ngenerator(8), systemd.directives(7)\n\nsystemd 249                                                    SYSTEMD.SWAP(5)",
            "subsections": []
        }
    },
    "summary": "systemd.swap - Swap unit configuration",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "systemd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemd/1/json"
        },
        {
            "name": "systemctl",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemctl/1/json"
        },
        {
            "name": "systemd-system.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd-system.conf/5/json"
        },
        {
            "name": "systemd.unit",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.unit/5/json"
        },
        {
            "name": "systemd.exec",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.exec/5/json"
        },
        {
            "name": "systemd.kill",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.kill/5/json"
        },
        {
            "name": "systemd.resource-control",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.resource-control/5/json"
        },
        {
            "name": "systemd.device",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.device/5/json"
        },
        {
            "name": "systemd.mount",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.mount/5/json"
        },
        {
            "name": "swapon",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/swapon/8/json"
        },
        {
            "name": "generator",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/generator/8/json"
        },
        {
            "name": "systemd.directives",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.directives/7/json"
        },
        {
            "name": "SYSTEMD.SWAP",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/SYSTEMD.SWAP/5/json"
        }
    ]
}