How to add swapfile to your linux system

We are creating one swapfile of size 1M * 1024 = 1024M = 1GiB 🙂

dd if=/dev/zero of=/swapfile bs=1M count=1024
chown root:root /swapfile
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile

if you want to have this swap file peramanent you have two options:
worse – add swapon /swapfile to /etcc/rc.d/rc.localbetter – add it to /etc/fstab

/swapfile1 none swap sw 0 0


Leave a Comments

Marek Knappe