Nytro Posted June 9, 2011 Report Posted June 9, 2011 How to Increase the Swap File in UNIX(-like) Operating SystemsFirst of all, I’m not saying on which operating system because this applies to numerous UNIX, UNIX derivates and UNIX-like operating systems. For example, the process of increasing the swap file is the same on all Linux, AIX, HP-UX, FreeBSD, NetBSD, OpenBSD, IRIX, Tru64 and possibly more. So, assuming that we have approximately 2GB of swap… 1root:~# free2 total used free shared buffers cached3Mem: 1026140 690164 335976 0 226408 2463404-/+ buffers/cache: 217416 8087245Swap: 2064376 0 20643766root:~# We first create an empty file with the size of additional swap we need. For example if we need 512MB of additional swap we’ll create a file like this: 1root:~# dd if=/dev/zero of=/example_swap bs=1024 count=5000002500000+0 records in3500000+0 records out4512000000 bytes (512 MB) copied, 7.03446 seconds, 72.8 MB/s5root:~# Which will obviously create file with size of 512MB filled with zeros… 1root:~# ls -l /example_swap2-rw-r--r-- 1 root root 512000000 May 24 11:49 /example_swap3root:~# Next, we are making this a swap area using the provided utility. 1root:~# mkswap /example_swap2Setting up swapspace version 1, size = 511995 kB3root:~# And we attach this to the system’s swap file as shown below… 1root:~# swapon /example_swap2root:~# free3 total used free shared buffers cached4Mem: 1026140 1005904 20236 0 197632 5793085-/+ buffers/cache: 228964 7971766Swap: 2564368 0 2564368 As you can see the space was increased. It would be wise to also update /etc/fstab to map this area at boot time or when using swapon -a command.In order to stop using this area, simply remove it with the appropriate system call’s wrapper utility. 1root:~# swapoff /example_swap2root:~# free3 total used free shared buffers cached4Mem: 1026140 1005780 20360 0 197648 5793165-/+ buffers/cache: 228816 7973246Swap: 2064376 0 20643767root:~#Sursa: How to Increase the Swap File in UNIX(-like) Operating Systems « xorl %eax, %eax Quote