Ady Wicaksono Daily Activities

Add swap space on linux without restarting linux

leave a comment »

1. Allocate new file for swap, e.g 10 Mbytes

   # dd if=/dev/zero of=/swapfile01 bs=1024 count=10000
     10000+0 records in
     10000+0 records out
   # ls -l /swapfile01
     -rw-r--r--    1 root     root     10240000 Jan 26 17:27 /swapfile01

Now we have /swapfile01 for our swapfile

2. Now setup swaparea first

   # mkswap /swapfile01
     Setting up swapspace version 1, size = 9996 KiB

Check our current swap value

    # free
                total       used       free     shared    buffers     cached
    Mem:        604020     562100      41920          0      34100      42848
    -/+ buffers/cache:     485152     118868
    Swap:      1546056     692200     853856

3. activate our swap

 swapon /swapfile01

Check our current swap value

    # free
                total       used       free     shared    buffers     cached
    Mem:        604020     566796      37224          0      35576      43520
    -/+ buffers/cache:     487700     116320
    Swap:      1556048     691564     864484

Our swap file is increase by 10240000 bytes🙂

Anytime we want to deactivate this swap file area, simply run

   swapoff /swapfile01

Written by adywicaksono

November 19, 2007 at 6:02 am

Posted in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: