Swapfile
A swapfile is a regular file configured as a backing area for operating-system paging.
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. [1]
Btrfs 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. [2] [3]
A 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. [2]
Relations
- related
- File preallocation, Sparse file, Btrfs, zswap
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.
Citations
- util-linux: swapon(8), swapfile allocation restrictions
- Btrfs documentation: Swapfile, extent placement and active-file restrictions
- Linux v6.16: btrfs_swap_activate, profile and same-device checks
Sources & caveats
- Linux swapon and Btrfs documentation reviewed 2026-11-14. This is a source-based eligibility explanation, not an activation recipe or tested hibernation setup.