Linux Swap
Posted in BSD+Linux, IT | By tarotoast | Tags: linux, swap
I was trying to do a mysqldump on a gigantic database in order to move to a faster machine. About a minute after issuing the command, I started to regret. The mysqldump took over the entire system resource (in terms of memory, both physical ram and sawp are all taken) and pratically hanged the system. Hopefully no researchers are using any service at that moment.
Clearly, the server do not have enough memory for me to do a successful dump. I was thinking if there’s away to resize the swap. It turns out that I can increase the swap space pretty easy:
- As root, go to a directory where swap can be stored and type:
dd if=/dev/zero of=swapfile bs=1024 count=4127438
This command will create a 4GB file filled with null. - Now make sure it’s read/write only to root:
chmod 600 swapfile - Make it a SWAP:
mkswap swapfile - Add it into existing SWAP:
swapon swapfile
Now do a top and 4G of swap space is added, I can now dump the 2.8G database :)
Recent Comments