This page explains how to create and use a file-based swap in Linux. This will generally be used in VMware and Xen images to simplify the images.
- Type the following command to create a 512MB swap file (1024*512 = 524288 block size)
$ sudo dd if=/dev/zero of=/swap.file bs=1024 count=524288
- Set up a linux swap area
$ sudo mkswap /swap.file
- Activate the swap space immediately
$ sudo swapon /swap.file
- To active the swap space after a system reboot, and an entry to /etc/fstab. Open this file using a text editor such as vim.
$ sudo vim /etc/fstab
- Append the following line
/swap.file swap swap defaults 0 0
- Verify swap is activated
$ free -m
Was this helpful?
0 / 0