swap

swap what is it good for...

Submitted by isntall on Thu, 07/07/2016 - 14:01

Traditional

dd if=/dev/zero of=/mnt/swap16G bs=1G count=16

fast

fallocate -l 16G mnt/swap16G

enabling

mkswap /mnt/swap16G
chmod 600 /mnt/swap16G
swapon /mnt/swap16G

add to the /etc/fstab if you want to keep the settings

/mnt/swapfile16g   none    swap    sw    0   0

If using things like AWS instance-store-volume adding the file to the /etc/fstab is not appropriate.
You could create the swapfile on the fly or you could create one swapfile, compress it, and decompress on each boot.
In Ubuntu and other probably others using the /etc/rc.local file can be a decent choice (there are others).

gunzip -c /swapfile16g.gz > /mnt/swapfile16g
chmod 600 /mnt/swapfile16g
swapon /mnt/swapfile16G

Tags