{
  "slug": "swapfile",
  "term": "Swapfile",
  "aliases": [
    "swap file",
    "file-backed swap"
  ],
  "definition": "A swapfile is a regular file configured as a backing area for operating-system paging.",
  "note": "Linux activation is a separate operation from creating or allocating the file. swapon rejects holes; whether fallocate-created extents are usable depends on the filesystem. Allocation success alone does not prove swap eligibility. [swap-activation]\n\nBtrfs supports swapfiles since Linux 5.0, requiring preallocation without holes and NODATACOW, also excluding data checksums and compression. Its one-device placement and SINGLE data profile requirements concern the swapfile extents and their placement, not an unconditional ban on multi-device filesystems. [btrfs-swap] [btrfs-swap-kernel]\n\nA subvolume containing an active Btrfs swapfile cannot be snapshotted. Hibernation also needs the correct device-specific resume offset; the Btrfs documentation warns against using filefrag output for it. [btrfs-swap]",
  "advantages": [
    "Provides a file-based paging area without requiring a dedicated swap partition."
  ],
  "limitations": [
    "Apparent file length is not evidence of successful swap activation.",
    "Filesystem, extent placement and active-use restrictions must be checked for the deployed configuration."
  ],
  "related": [
    "file-preallocation",
    "sparse-file",
    "btrfs",
    "zswap"
  ],
  "citations": [
    {
      "id": "swap-activation",
      "title": "util-linux: swapon(8), swapfile allocation restrictions",
      "url": "https://man7.org/linux/man-pages/man8/swapon.8.html",
      "accessed": "2026-11-14"
    },
    {
      "id": "btrfs-swap",
      "title": "Btrfs documentation: Swapfile, extent placement and active-file restrictions",
      "url": "https://btrfs.readthedocs.io/en/latest/Swapfile.html",
      "accessed": "2026-11-14"
    },
    {
      "id": "btrfs-swap-kernel",
      "title": "Linux v6.16: btrfs_swap_activate, profile and same-device checks",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/fs/btrfs/inode.c",
      "accessed": "2026-11-14"
    }
  ],
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-14",
  "provenance": [
    "Linux swapon and Btrfs documentation reviewed 2026-11-14. This is a source-based eligibility explanation, not an activation recipe or tested hibernation setup."
  ]
}
