Adding A Swap File to Linux


The following commands illustrate how to add a swap file of 2GB to a RedHat system:

# dd if=/dev/zero of=/temp_swap bs=1024 count=2097152
# mkswap /temp_swap
# swapon /temp_swap

To enable it at boot time, edit /etc/fstab to include:

/temp_swap swap swap defaults 0 0

After adding the new swap file and enabling it, verify it is enabled by viewing the output of the

# free -mo


Leave a Reply

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