Suppose, you have recently installed a program in your unix box that needs at least 1GB of swap space but you only allocated 256MB for your swap partition when you installed your unix distro, or you even forgot to allocate a swap partition during the installation process because you were in a hurry and now your favourite programme slows down frequently. Thinking about reinstallation?
Well, think again!
There is a handy tool in unix called swapon that can solve your problem in a few seconds.
Here is how I added a 512MB extra swap space in my debian system:
- First I calculated the file size in KB. 512 * 1024 = 524288
- Then I ran these in root shell (This creates the swap file):
#dd if=/dev/zero of=swapfile bs=1024 count=524288
#mkswap swapfile -L linux_swap
#mkswap swapfile -L linux_swap
- Then I instructed my debian to use that swap file:
#swapon swapfile
Walla! My system suddenly appears to have 512MB of extra swap space!
Now, one single step is missing. You don't wanna write swapon in shell every time your system boots, do you?
Just add #swapon swapfile to your system's startup scripts.
And if don't wanna use that swap file for some reason, #swapoff swapfile and delete that file (and don't forget to remove that startup script if you have added that)
2 comments:
Hi mate, I want to delete the 512 swap file via your tips, but I don't know where it is.
Silly me already had 1 gig swap on a second drive that I simple turned on via gparted using 'swapon'
if you copied his lines exactly, it should be in /root
Post a Comment