We can either create swap file or swap partition and make it as swap space.
How to create swap space from file?
To create 512MB swap file, run below commands. Make sure the file system has enough diskspace, where you are creating swap file.
dd if=/dev/zero of=swapfile bs=1024 count=524288
chmod 600 swapfile
mkswap swapfile
swapon swapfile
To automate this while rebooting, add following entry to /etc/fstab. (Assumed that you created swapfile under /opt)
/opt/swapfile swap swap defaults 0 0
How to create swap space from partition?
Create a partition using "fdisk" with type swap i.e. make partition type to 82. Type "t" to set the partition type. (Assumed that you created a partition /dev/hdb1 as swap). To activate, run following commands
mkswap /dev/hdb1
swapon /dev/hdb1
To automate this while rebooting, add following entry to /etc/fstab.
/dev/hdb1 swap swap defaults 0 0
Use "free" command before and after executing above methods to verify that the swap has been created / increased
Have Fun .....
Sikkandar.Linux at Gmail.Com
Saturday, December 20, 2008
How to create/increase swap on the fly in Linux?
Labels:
Memory
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment