{"id":901,"date":"2026-10-22T18:00:00","date_gmt":"2026-10-22T18:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=901"},"modified":"2026-10-22T18:00:00","modified_gmt":"2026-10-22T18:00:00","slug":"add-swap-space-ubuntu-25-10","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/10\/22\/add-swap-space-ubuntu-25-10\/","title":{"rendered":"How to Add Swap Space on Ubuntu 25.10 (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Add swap space on Ubuntu 25.10 by creating a protected 1 GiB swap file and enabling it for the current session and future boots. You can finish in about five to ten minutes, giving a small VPS a disk-backed buffer for short memory spikes without restarting it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Ubuntu Server 25.10 (Questing) on a VPS or dedicated server, with at least 1.5 GiB of free space on <code>\/<\/code> for the example file.<\/li>\n\n\n<li>SSH access as <code>root<\/code>, or a regular user with working <code>sudo<\/code> privileges.<\/li>\n\n\n<li>The target path <code>\/swapfile<\/code> must not be an existing application file or an active swap area.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> if you need an Ubuntu server for this procedure.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 25.10 is an interim release. For a new internet-facing server, choose a currently supported Ubuntu release; use this procedure when maintaining an existing 25.10 system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Swap is slower than RAM, so use it as protection against short-lived pressure rather than as a replacement for memory. No inbound port is opened by this guide, so there is no firewall rule to add.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Inspect Ubuntu 25.10, storage, and existing swap<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the release, root filesystem, free disk space, and current swap before creating anything so you do not duplicate swap or fill the system disk.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E '^(PRETTY_NAME|VERSION_ID)=' \/etc\/os-release\nfindmnt -no FSTYPE \/\ndf -h \/\nfree -h\nswapon --show\ntest -e \/swapfile &amp;&amp; ls -lh \/swapfile || echo \"\/swapfile is available\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a clean Ubuntu 25.10 VPS, the release identifies <code>25.10<\/code>, <code>swapon --show<\/code> has no data rows, and the final check confirms that the path is available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRETTY_NAME=\"Ubuntu 25.10 (Questing Quokka)\"\nVERSION_ID=\"25.10\"\next4\nFilesystem      Size  Used Avail Use% Mounted on\n\/dev\/vda1        40G  6.4G   32G  17% \/\n               total        used        free      shared  buff\/cache   available\nMem:            2.0Gi       420Mi       1.0Gi        12Mi       580Mi       1.4Gi\nSwap:              0B          0B          0B\n\/swapfile is available<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your device names and memory values will differ. If any swap device or file is already listed, keep it and decide whether extra capacity is actually needed. If <code>\/swapfile<\/code> exists, choose another unused name instead of overwriting it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Create a protected 1 GiB swap file<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Prepare the file and restrict it to root before Linux uses it, which prevents ordinary users from reading memory pages that may be written to disk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For an <code>ext4<\/code>, <code>xfs<\/code>, or other normal root filesystem, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fallocate -l 1G \/swapfile\nsudo chmod 0600 \/swapfile\nsudo mkswap \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mkswap<\/code> should report a 1 GiB area and print a generated UUID:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Setting up swapspace version 1, size = 1 GiB\nno label, UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Step 1 reported <code>btrfs<\/code>, do not use the <code>fallocate<\/code> block by itself. Mark the empty file as non-copy-on-write before allocating it, then format it as swap:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo truncate -s 0 \/swapfile\nsudo chattr +C \/swapfile\nsudo fallocate -l 1G \/swapfile\nsudo chmod 0600 \/swapfile\nsudo mkswap \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/manpages.ubuntu.com\/manpages\/noble\/man8\/btrfs-filesystem.8.html\" target=\"_blank\" rel=\"noopener\">Ubuntu Btrfs manual<\/a> documents why a swap file needs preallocated, non-copy-on-write extents. Run only one creation method, and never replace an existing active file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Enable swap now and at boot<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Formatting the file only adds its swap signature; <code>swapon<\/code> activates it immediately, while the <code>\/etc\/fstab<\/code> entry restores it after a reboot.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapon \/swapfile\nif ! sudo grep -qE '^[[:space:]]*\/swapfile[[:space:]]' \/etc\/fstab; then\n  echo '\/swapfile none swap sw 0 0' | sudo tee -a \/etc\/fstab\nfi\nsudo systemctl daemon-reload\nsudo swapon --show<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The last command should show <code>\/swapfile<\/code> as an active file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NAME      TYPE  SIZE USED PRIO\n\/swapfile file    1G   0B   -2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The priority can differ when another swap area is already enabled. The guard prevents this command from adding a second identical line to <code>\/etc\/fstab<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Review memory pressure before tuning swappiness<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>vm.swappiness<\/code> influences how readily Ubuntu moves inactive memory pages to disk, so inspect real pressure before changing the distribution default.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysctl vm.swappiness\nfree -h\nvmstat 1 5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see the current swappiness value, a nonzero <code>Swap<\/code> total, and usually zero <code>si<\/code>\/<code>so<\/code> on an idle server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vm.swappiness = 60\nSwap:          1.0Gi          0B     1.0Gi\nprocs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----\n              si   so\n              0    0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>vmstat<\/code> columns <code>si<\/code> and <code>so<\/code> show swap-in and swap-out activity. A quiet server can legitimately show zero swap use; an unused swap file is not a setup failure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If this VPS should strongly prefer RAM and you have a workload reason to test a lower value, apply 10 for the current boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl vm.swappiness=10<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If monitoring supports that choice, make it persistent in a separate file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf '%s\\n' 'vm.swappiness = 10' | sudo tee \/etc\/sysctl.d\/60-swap.conf\nsudo sysctl -p \/etc\/sysctl.d\/60-swap.conf\nsysctl vm.swappiness<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vm.swappiness = 10<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Do not set swappiness to zero just to eliminate disk activity. Repeated swapping usually means the server needs more RAM or the application needs tighter memory limits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the persistent swap setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run one final check for activation, capacity, permissions, and the boot entry; together these prove the file works now and is configured for the next restart.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapon --show\nfree -h\nsudo stat -c '%A %U:%G %s %n' \/swapfile\nsudo grep -nE '^[[:space:]]*\/swapfile[[:space:]]' \/etc\/fstab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Successful output includes a 1 GiB active file, root-only permissions, and one matching <code>fstab<\/code> line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NAME      TYPE  SIZE USED PRIO\n\/swapfile file    1G   0B   -2\nSwap:          1.0Gi          0B     1.0Gi\n-rw------- root:root 1073741824 \/swapfile\n1:\/swapfile none swap sw 0 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Ubuntu\u2019s explanation of swap files, sizing, and activation, see the <a href=\"https:\/\/help.ubuntu.com\/community\/SwapFaq\" target=\"_blank\" rel=\"noopener\">Ubuntu Swap FAQ<\/a>.<\/p>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Add memory headroom\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">Linux VPS<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Add memory headroom<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Deploy an Ubuntu VPS with room for applications and a protected swap file.<\/p>\n\t<\/div>\n\t<a class=\"vl-cta-banner__button\" href=\"\/buy-vps\" aria-label=\"View Linux VPS plans\">View Linux VPS plans<\/a>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><code>swapon: \/swapfile: swapon failed: Invalid argument<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The file is often sparse or a copy-on-write file on Btrfs. Confirm the filesystem with <code>findmnt -no FSTYPE \/<\/code>; if it is Btrfs, remove only an inactive failed file and rerun the Btrfs sequence from Step 2. On a normal filesystem, recreate the inactive file with <code>fallocate<\/code>, <code>chmod<\/code>, and <code>mkswap<\/code> again.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fallocate: fallocate failed: No space left on device<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The root filesystem cannot provide 1 GiB. Check <code>df -h \/<\/code>, preserve room for Ubuntu updates and logs, and use a smaller inactive file such as 512 MiB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo swapon --show\nsudo rm \/swapfile\nsudo fallocate -l 512M \/swapfile\nsudo chmod 0600 \/swapfile\nsudo mkswap \/swapfile\nsudo swapon \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run the <code>rm<\/code> command only when <code>swapon --show<\/code> confirms that <code>\/swapfile<\/code> is not active. The existing <code>\/etc\/fstab<\/code> path does not need to change.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>swapon: \/swapfile: swapon failed: Device or resource busy<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The path is already active or another process has it open. Run <code>sudo swapon --show<\/code> and <code>ls -l \/swapfile<\/code>; if it is listed as active, keep it and remove any duplicate <code>fstab<\/code> entry instead of overwriting the file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>swapon: \/swapfile: swapon failed: Operation not permitted<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some container-based VPS environments do not allow the guest to manage swap. This is a virtualization policy, not a missing Ubuntu package; ask the provider for host-managed swap or use a plan that permits guest swap files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Is 1 GiB enough swap for Ubuntu 25.10?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It is a reasonable starting point for a small VPS with enough disk space, especially when swap is only meant to absorb brief memory spikes. Size it around the workload and keep free storage for system updates, logs, and application data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I create <code>\/swapfile<\/code> if Ubuntu already has <code>\/swap.img<\/code>?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Usually not. Check the size and usage with <code>swapon --show<\/code> first; an existing active swap file already provides the feature. Add a second file only when you have a clear capacity requirement, and use a different path.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can a VPS hibernate with a swap file?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Hibernation requires enough swap for the system\u2019s memory and support from the kernel, boot configuration, and virtualization platform. Most hosted VPS plans do not expose suspend-to-disk, so this guide targets memory headroom rather than hibernation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need to reboot after adding swap on Ubuntu 25.10?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. <code>swapon \/swapfile<\/code> enables it immediately, and the <code>fstab<\/code> record handles future boots. A reboot is only useful if you want to test the boot path during a maintenance window.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Is 1 GiB enough swap for Ubuntu 25.10?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"It is a reasonable starting point for a small VPS with enough disk space, especially when swap is only meant to absorb brief memory spikes. Size it around the workload and keep free storage for system updates, logs, and application data.\"}}, {\"@type\": \"Question\", \"name\": \"Should I create `\/swapfile` if Ubuntu already has `\/swap.img`?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Usually not. Check the size and usage with `swapon --show` first; an existing active swap file already provides the feature. Add a second file only when you have a clear capacity requirement, and use a different path.\"}}, {\"@type\": \"Question\", \"name\": \"Can a VPS hibernate with a swap file?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Hibernation requires enough swap for the system\u2019s memory and support from the kernel, boot configuration, and virtualization platform. Most hosted VPS plans do not expose suspend-to-disk, so this guide targets memory headroom rather than hibernation.\"}}, {\"@type\": \"Question\", \"name\": \"Do I need to reboot after adding swap on Ubuntu 25.10?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. `swapon \/swapfile` enables it immediately, and the `fstab` record handles future boots. A reboot is only useful if you want to test the boot path during a maintenance window.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Add swap space on Ubuntu 25.10 with a protected 1 GiB file, Btrfs-safe setup, persistent boot configuration, verification, and common fixes.","protected":false},"author":1,"featured_media":902,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[5,9],"tags":[93,92,103],"class_list":["post-901","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-vps-hosting","tag-linux-vps","tag-swap","tag-ubuntu-25-10","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/comments?post=901"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/901\/revisions"}],"predecessor-version":[{"id":3691,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/901\/revisions\/3691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/902"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}