Create swap file in Linux

Before creating a swap file, we should check the size of the current swap:

#cat /proc/meminfo | grep SwapTotal
SwapTotal: 9233400 kB

Create a swap file
To create swap file, you will need to use dd command:

#dd if=/dev/zero of=/newswap bs=1024 count=1048576

if=/dev/zero – read from /dev/zero
of=/newswap – write to /newswap
bs=1024 – blocksize in bytes for reading and writing
count=1048576 – swap file size

Source: http://linuxapachemysqlphp5.blogspot.com/2013/05/create-swap-file-in-linux.html

Leave a comment