How To Enable Linux Swapfile Instead of Partition Ubuntu Mint Debian Centos

This may be necessary if you have a VM or if for some reason you just want to be more efficient with your space and have the flexibility of changing your swap space at will.

What we mean is the ability to use a "swap file" or similar to the Windows "pagefile" that normally resides on the root or c: partition of Windows.

Here's all you have to do and then you to can have a single partiton with everything, including the swap file on the root partition if you desire.

1.) Create the swapfile and allocate the size you want for it (eg. 1G, 10G etc..)

fallocate -l 1G /rttswapfile
 

2.) We then change permissions so only the root user can read and write to it.

chmod 600 /rttswapfile

3.) Now turn the "swapfle" into an actual swapspace partition.


mkswap /rttswapfile

Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=2a8fea79-1fd7-4241-b57f-867be99abb1e

4.) Enable the swap file

swapon /rttswapfile

 

5.) Make it permanent by adding it to /etc/fstab

 

#add this to /etc/fstab

/rttswapfile swap swap defaults 0 0

6.) Confirm the /etc/fstab is good and does not throw any errors.
 

mount -a

#there should be no output, if you get an error there is an issue with your fstab entry for the swapfile.


Tags:

enable, linux, swapfile, partition, ubuntu, mint, debian, centos, vm, efficient, flexibility, swap, quot, pagefile, resides, partiton, allocate, eg, etc, fallocate, rttswapfile, permissions, user, chmod, swapfle, swapspace, mkswap, mib, bytes, label, uuid, fea, fd, abb, swapon, adding, fstab, defaults, errors, mount, output, entry,

Latest Articles

  • LXC Containers LXD How to Install and Configure Tutorial Ubuntu Debian Mint
  • Ubuntu Mint audio output not working pulseaudio "pulseaudio[13710]: [pulseaudio] sink-input.c: Failed to create sink input: too many inputs per sink."
  • How To Shrink Dynamically Allocated VM QEMU KVM VMware Disk Image File
  • How To Enable Linux Swapfile Instead of Partition Ubuntu Mint Debian Centos
  • 404 Not Found [IP: 151.101.194.132 80] apt update Debian 11 Bullseye Solution The repository 'http://security.debian.org bullseye/updates Release' does not have a Release file.
  • WARNING: Can't download daily.cvd from db.local.clamav.net freshclam clamav error solution
  • (firefox:9562): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Failed to execute child process "dbus-launch" (No such file or directory) Solution
  • Debian Mint Ubuntu Which Package Provides missing top, ps and w Solution
  • Vbox Virtualbox DNS NAT Network Mode NOT working
  • Docker Tutorial HowTo Install Docker, Use and Create Docker Container Images Clustering Swarm Mode Monitoring Service Hosting Provider
  • Zoom Password Error 'That passcode was incorrect' - Solution Wrong Passcode Wrong Meeting Name
  • How To Startup and Open Remote/Local Folder/Directory in Ubuntu Linux Mint automatically upon login
  • How To Reset Windows Server Password 2019, 2022, 7, 8, 10, 11 Recovery and Removal Guide Using Linux Ubuntu Mint Debian
  • How To Create OpenVPN Server for Secure Remote Corporate Access in Linux Debian/Mint/Ubuntu with client public key authentication
  • HongKong VPS Server, Cloud, Dedicated Server, Co-Location, Datacenter The Best Guide on Hong Kong, China Internet IT/Computing
  • ssh-keygen id_rsa private key howto remove the passphrase so no password is required and no encryption is used
  • Package wget is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source. E: Package 'wget' has no installation candidate. Solution
  • tag#4 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE tag#4 Sense Key : Illegal Request [current] res 40/00:b4:98:02:00/00:00:00:00:00/40 Emask 0x10 (ATA bus error) solution
  • Wazuh Install and Configuration Howto Tutorial Guide for Monitoring Agents
  • Linux Debian How To Enable Sudo/Sudoers for User "User not in sudoers file" Solution