User Tools

Site Tools


swapfile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
swapfile [2024/04/30 21:06] wigumsswapfile [2024/07/23 16:19] (current) – external edit 127.0.0.1
Line 1: Line 1:
 i dont bother with swap as ive ALMOST never needed it. if you find yourself in a situation where you do need swap just spin up a swapfile. i dont bother with swap as ive ALMOST never needed it. if you find yourself in a situation where you do need swap just spin up a swapfile.
  
-create a file with the size of swap space you want. Let’s say that I want to add GB of swap space to my system. Use the fallocate command to create a file of size GB.+create a file with the size of swap space you want. Let’s say that I want to add 32 GB of swap space to my system. Use the fallocate command to create a file of size 32 GB.
  
  
-<code>fallocate -l 1G /swapfile</code>+<code>fallocate -l 32G /swapfile</code>
  
 It is recommended to allow only root to read and write to the swap file.  It is recommended to allow only root to read and write to the swap file. 
Line 10: Line 10:
 <code>chmod 600 /swapfile</code> <code>chmod 600 /swapfile</code>
  
-mkswap /swapfile 
  
 You need to tell Linux that this file will be used as swap space. You can do that with mkswap You need to tell Linux that this file will be used as swap space. You can do that with mkswap
  
-mkswap /swapfile+<code>mkswap /swapfile</code>
  
-<code>Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)+You should see an output like this: 
 + 
 +<code>Setting up swapspace version 1, size = 32 GiB (34359734272 bytes)
 no label, UUID=7e1faacb-ea93-4c49-a53d-fb40f3ce016a</code> no label, UUID=7e1faacb-ea93-4c49-a53d-fb40f3ce016a</code>
 +
 +Now your system knows that the file swapfile can be used as swap space. You need to enable the swap file so that your system can start using this file as swap.
  
 <code>swapon /swapfile</code> <code>swapon /swapfile</code>
 +
 +when youre done just do 
 +
 +<code>swapoff /swapfile</code>
 +
 +if you want to reclaim your disk space just rm it
 +
 +<code>rm -rf /swapfile</code>
  
swapfile.1714511192.txt.gz · Last modified: 2024/07/23 16:19 (external edit)