The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Increase size of swap partition

Discussion in 'General Discussion' started by Janak, Jul 19, 2009.

  1. Janak

    Janak Well-Known Member

    Joined:
    Jul 18, 2009
    Messages:
    71
    Likes Received:
    1
    Trophy Points:
    6
    I was wondering if it is possible to increase the size of swap partition. If yes the how can I increase it?

    Thanks!
     
  2. Janak

    Janak Well-Known Member

    Joined:
    Jul 18, 2009
    Messages:
    71
    Likes Received:
    1
    Trophy Points:
    6
    I found the solution. No need to reply this thread.

    Open SSH and run below commands:

    dd if=/dev/zero of=/usr/swap-file bs=1024 count=2048000
    mkswap /usr/swap-file
    swapon /usr/swap-file
    swapon -s

    Now add the following to the /etc/fstab and you are done.

    /usr/swap-file swap swap defaults 0 0

    I found this from Blogs | eth0.us - Server admin info for cPanel, plesk, ensim and linux!

    Thanks!
     
    Arash Mehmandoost likes this.
  3. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    That is one way to do it. Swap is really good at spreading the load across the system. So if you give swap 1 gig on 4 drives it'll equal out the load. It's a real neat feature, I donate a gig to swap on each hardware device in hopes of speeding things up over all.

    Most of the time, if I'm swapping something is either really wrong, or it's time to get more ram. :D
     
  4. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    Also don't forget that swap is basically RAM but on the hard drive, so it is a lot slower. If you are starting to swap a lot your IOwait is probably going to very quickly increase which is going to bog down your server pretty quickly. You probably should look at optimizing or adding in some more RAM if you need more swap constantly.
     
  5. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    To use a RAID Drive is also a better option to decrease number of Disk I/O.
     
  6. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    While true it is MUCH cheaper just to add in more RAM unless you are at the servers max -- even then upgrading may still be cheaper then RAID.
     
  7. david510

    david510 Well-Known Member

    Joined:
    Aug 22, 2004
    Messages:
    473
    Likes Received:
    0
    Trophy Points:
    16
    It is always not recommended to increase the swap to high values.
     
  8. Janak

    Janak Well-Known Member

    Joined:
    Jul 18, 2009
    Messages:
    71
    Likes Received:
    1
    Trophy Points:
    6
    Ok..I think I should upgrade RAM first and then think about SWAP if required.
     
Loading...

Share This Page