Tuesday, May 17, 2011

Create Swap based on File


Features:
1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc., if you have no available disk space to partition.

2. Doesn't waste partitions


Task:
1. Create 512MB swap file
a. dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288
b. mkswap /home1/swapfile1 - overlays swap file system
c. swapon /home1/swapfile1 - makes swap space avaialable to the kernel

2. Ensure that when the system reboots, the swapfile is made avialable to the kernel
a. nano /etc/fstab - /home1/swapfile1 swap swap defaults 0 0


3. Create 2GB swap file
a. dd if=/dev/zero of=/home1/swapfile2 count=2G