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

  • CentOS 7 / 8 cannot boot with with mdadm RAID array solution
  • How To Add Default Gateway in Linux using the ip route command routing
  • Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist Solution for Centos8 yum package install error
  • md mdadm array inactive how to start and activate the RAID array
  • Loaded: masked (Reason: Unit hostapd.service is masked.) Solution in Linux Debian Mint Ubuntu
  • Linux Mint Ubuntu Ubiquity Installer Bug EFI Installed To Wrong Partition Solution
  • Libreoffice Impress How To Change The Color of Links
  • ecryptfs How To Backup / Migrate Linux Mint Ubuntu Debian system ecryptfs properly and restore access
  • i915 nouveau Nvidia GPU not starting lightdm Xorg failing solution for Could not determine valid watermarks for inherited state
  • br0: received packet on bond0 with own address as source address Linux Solution Mint Debian Redhat CentOS bridge bridging
  • Debian Mint Ubuntu Howto Disable Network Manager
  • AMD GPU Xorg Won't Start [3576284.324] (EE) Segmentation fault at address 0x0 [3576284.325] (EE) Fatal server error: [3576284.325] (EE) Caught signal 11 (Segmentation fault). Server aborting
  • symbol 'grub_calloc' not found grub boot error solution / fix
  • /var/log/journal huge/too large solution in Debian Mint Ubuntu Linux Howot Fix
  • Libreoffice Calc Opens CSV Spreadsheet File as Asian Language/Chinese Characters Solution Fix
  • RTL8821AU Setup Configure Wifi Realtek 8821 in Linux Debian Mint Ubuntu Howto
  • How To Tell Which Repository a Package Comes From Debian Mint Ubuntu
  • How To Reload All Kernel Modules And List Required Moduels for Each Device - Linux Mint Debian Ubuntu Troubleshooting
  • Debian Ubuntu Mint How To Change Default Display Manager
  • Ubuntu Mint Debian Howto Execute Command / Script / Program Upon Wakeup From Sleep