# Linux swap Commands: Create and Manage Swap Files/Partitions

DevFeed: [Linux swap Commands: Create and Manage Swap Files/Partitions](<https://devfeed.tech/articles/linux-swap-commands-create-and-manage-swap-files-partitions-20882.md>)

Original publisher: [Read original article](<https://linuxblog.io/swap-command-create-manage-swap-files-partitions/>)

Author: Hayden James

Published: 2026-08-26T15:13:53Z

Content type: tutorial

Language: en

Sources: [Hayden James](<https://devfeed.tech/sources/hayden-james.md>)

Topics: [Linux](<https://devfeed.tech/topics/linux.md>), [btrfs](<https://devfeed.tech/topics/btrfs.md>), [XFS](<https://devfeed.tech/topics/xfs.md>), [Linux Kernel](<https://devfeed.tech/topics/linux-kernel.md>), [rhel](<https://devfeed.tech/topics/rhel.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [btrfs](<https://devfeed.tech/tags/btrfs.md>), [commands](<https://devfeed.tech/tags/commands.md>), [compression](<https://devfeed.tech/tags/compression.md>), [copy-on-write](<https://devfeed.tech/tags/copy-on-write.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [device](<https://devfeed.tech/tags/device.md>), [file](<https://devfeed.tech/tags/file.md>), [files](<https://devfeed.tech/tags/files.md>), [filesystem](<https://devfeed.tech/tags/filesystem.md>), [format](<https://devfeed.tech/tags/format.md>), [fstab](<https://devfeed.tech/tags/fstab.md>), [guide](<https://devfeed.tech/tags/guide.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [kernels](<https://devfeed.tech/tags/kernels.md>), [linux](<https://devfeed.tech/tags/linux.md>), [management](<https://devfeed.tech/tags/management.md>), [partition](<https://devfeed.tech/tags/partition.md>), [performance](<https://devfeed.tech/tags/performance.md>), [server](<https://devfeed.tech/tags/server.md>), [sysadmins](<https://devfeed.tech/tags/sysadmins.md>)

## AI overview

The excerpt outlines Linux swap management with `mkswap` to initialize a swap area, `swapon` to activate it, and `swapoff` to deactivate it. It recommends checking existing swap first and says swap files can be added or removed without repartitioning. `fallocate` is faster for creating a file, but `dd` is a portable fallback when `fallocate` is unavailable or creates holes; older kernels on XFS may reject its unwritten extents. Btrfs swap files require copy-on-write disabled, no compression, full preallocation, a single-device filesystem with one data profile, and placement outside snapshot-managed subvolumes. The excerpt does not include the detailed commands or troubleshooting steps promised by the source summary.

## Source excerpt

A practical guide to creating, managing, and tuning swap files and swap partitions on Linux using mkswap, swapon, and swapoff, with real commands and common troubleshooting fixes. Continue reading...