If you are running out of system RAM, you can add virtual memory by
using
swap space. If you reserved a swap partition on your disk
drive, you have to initialize it once using the
mkswap command:
# fdisk -l /dev/hda
Disk /dev/hda: 16 heads, 63 sectors, 1575 cylinders
Units = cylinders of 1008 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 5 2488+ 83 Linux
/dev/hda2 6 10 2520 83 Linux
/dev/hda3 11 141 66024 82 Linux swap
/dev/hda4 142 1575 722736 83 Linux
# mkswap /dev/hda3
Setting up swapspace version 1, size = 67604480 bytes
Then, to activate it, you use the
swapon command
like this:
# free
total used free shared buffers cached
Mem: 14628 14060 568 8056 100 11664
-/+ buffers/cache: 2296 12332
Swap: 0 0 0
# free
total used free shared buffers cached
Mem: 14628 14060 568 8056 100 11664
-/+ buffers/cache: 2296 12332
Swap: 0 0 0
# swapon /dev/hda3
Adding Swap: 66016k swap-space (priority -2)
# free
total used free shared buffers cached
Mem: 14628 14084 544 8056 100 11648
-/+ buffers/cache: 2336 12292
Swap: 66016 0 66016
If you forgot to reserve (sufficient) space in a separate partition
on your disk, you can still use an ordinary file for swap space. You
only have to create a file of appropriate size, and initialize it as
follows:
# mount /dev/hda4 /mnt
# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/root 2087212 1378824 708388 67% /
/dev/hda4 711352 20 675196 1% /mnt
# dd if=/dev/zero of=/mnt/swapfile bs=1024k count=64
64+0 records in
64+0 records out
# mkswap /mnt/swapfile
Setting up swapspace version 1, size = 67104768 bytes
Then activate it:
# free
total used free shared buffers cached
Mem: 14628 14084 544 6200 96 11788
-/+ buffers/cache: 2200 12428
Swap: 0 0 0
# swapon /mnt/swapfile
Adding Swap: 65528k swap-space (priority -3)
# free
total used free shared buffers cached
Mem: 14628 14084 544 6200 96 11752
-/+ buffers/cache: 2236 12392
Swap: 65528 0 65528