Adding SWAP Space On-The-Fly

If somehow you need to add SWAP space in your Linux Box without having to reboot your Box, you could follow these steps. Basically create an Image in your HDD, format it to swap file system, and add it to your swap space, optionally you could add it to your fstab, so it still there during a reboot.

Build the Image

Build the image using dd command, give the size according to your needs. This example shows a 512MB image file.

dd if=/dev/zero of=/path/to/directory/swap.image oflag=direct bs=1M count=512

Format the Image

Format the image to SWAP file type.

mkswap  /direktori/swap.image

Activate Your Newly Created SWAP Image

mkswap  /path/to/directory/swap.image

Configure fstab

If you want the SWAP survive reboot.

vi /etc/fstab

### add the line similar to

/path/to/directory/swap.image swap                    swap    defaults        0 0

This entry was posted in Nix Basics. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted June 28, 2008 at 12:34 pm | Permalink

    Wogh… vewwy helpfull, bos.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Magnet Hosting, Hosting, VPS dan Server Indonesia
  • Categories

  • Archives