Adding A Swap File to Linux

SWAP File

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
command:

# free -mo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s