os:linux:create_swap_file
This is an old revision of the document!
Table of Contents
Linux: Create Swap File
Short
fallocate -l 1G /swapfile mkswap /swapfile swapon /swapfile vim /etc/fstab
/swapfile none swap sw 0 0
Long
Create File (eg. size 1GB).
root@server:~# fallocate -l 1G /swapfile
Set permissions.
root@server:~# chmod 0600 /swapfile
Set up swap space.
root@server:~# mkswap /swapfile Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=2903a264-5dc1-484c-8e1d-b0b6f687e65a
Activate Swap space.
root@server:~# swapon /swapfile
Edit fstab
root@server:~# vim /etc/fstab
add:
/swapfile none swap sw 0 0
Show Status
<code> swapon –summary <code>
Example. <code> root@server:~# swapon –summary Filename Type Size Used Priority /swapfile file 3145724 346156 -2 <code>
os/linux/create_swap_file.1670666842.txt.gz · Last modified: 2022-12-10 11:07 by Manuel Frei