Instead you can just make a file and assign it to the swap.
Just follow these steps for that.
1. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 1024 MB swap file is 1048576.
2. Lets make a zero’d file for the swap using dd. At a shell prompt as root, type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
2. Make the file as a swap file. Setup the swap file with the command:
3. Activate swapfile. To enable the swap file immediately but not automatically at boot time:
4. Verify that our swapfile has been activated
or by viewing the output of the command
5. To enable it at boot time, edit
/etc/fstab to include the following entry:
If you want to have this a permanent solution, then adding this entry to fstab would probally be a better idea,for that open up /etc/fstab in your favourite editor and add the following line.
/swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.