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

  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist
  • How to Install Any OS on a Physical Drive from Windows Using VMware Workstation (Linux, Windows, BSD)
  • CDN Cloudflare how to set and preserve the real IP of the client without modifying application code on Apache
  • CentOS 7 fix Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 14: curl#6 -
  • Ubuntu Debian How To Install Recommended Packages Automatically
  • How to set Linux Ubuntu Redhat Debian Command Line http https socks proxy for yum apt