Creating additional Linux swapfile

Problem:

After installing Linux in a virtual machine, the memory is increased from 512MB to 1536MB. The swap file must be increased as well, but there is no additional hard drive space or partitions to increase the swap partition.

Solution:

Create a new swap file:

1. As the root user, create a 3072MB swap file (block size=1024 bytes, count=1024*3072 blocks):

dd if=/dev/zero of=/swapfile1 bs=1024 count=3145728

2. Create swap file in swapfile1:

mkswap /swapfile1

3. Set file permissions for swapfile1:

chmod 0600 /swapfile1

4. Turn on swapfile:

swapon /swapfile1

5. Add swapfile to fstab:

Edit /etc/fstab and add the following line:

/swapfile1 swap swap defaults 0 0

Reference:

http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


This site uses Akismet to reduce spam. Learn how your comment data is processed.