Make swap

The purpose of this document is to explain how to create a swap file on an existing partition.

Multiply the number of blocks per MB (1024) by the number of MBs desired (8192 in this case) to get the count: 8388608

  • swap_file="/var/db/os_swap"

  • mb=8192

  • count=$(expr 8192 * 1024) && dd if=/dev/zero of="${swap_file}" bs=1024 count="${count}"

  • mkswap "${swap_file}"

  • swapon "${swap_file}"

    • vim /etc/fstab

        • Add this line:

      • /var/db/os_swap swap swap defaults 0 0

    • verify with free -m

# free -m total used free shared buffers cached Mem: 14984 14759 225 0 81 8460 -/+ buffers/cache: 6217 8767 Swap: 8191 0 8191

[Edit]