LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2013, 03:46 AM   #1
yashfire007
Member
 
Registered: Jan 2013
Distribution: CentOS, RHEL 6.4
Posts: 79

Rep: Reputation: Disabled
How to extend SWAP memory


Dear all,

I am having 4Gb of RAM in my machine , but i have assigned only 6GB for SWAP.
Now i need to extend it to 8GB, please suggest.

Thanks in advance..



Best regards,
Mohammed yasin...
 
Old 02-14-2013, 03:54 AM   #2
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
1.You need a partition to expand the swap.(you can use fdisk command )
2.Let's take /dev/sda6 as example.
3.Run sudo mkswap /dev/sda6
4.Technically speaking, you’re not formatting the partition; rather,you’re writing a small amount of information to indicate to the kernel that it can be used as swap space.
You can immediately activate the new swap partition via the swapon command. This command tells the kernel it can use the specified partition as swap space.
5.Run sudo swapon /dev/sdb6
This command will complete without printing anything, but you can check dmesg for
information on what happened.
 
Old 02-14-2013, 03:55 AM   #3
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
just FYI: You can use "free -m" command to check the swap memory.
 
Old 02-14-2013, 04:03 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by yashfire007 View Post
Now i need to extend it to 8GB
How did you reach that conclusion ?.
Do you have a swapping issue, or are you merely following an old (probably wrong in your case) "rule-of-thumb" ?.
 
Old 02-14-2013, 04:22 AM   #5
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
Quote:
Originally Posted by syg00 View Post
How did you reach that conclusion ?.
Do you have a swapping issue, or are you merely following an old (probably wrong in your case) "rule-of-thumb" ?.
You should have a 2GB(atleast) partition as you require.

As you have 6GB+(New partition)=8GB of swap memory
 
Old 02-14-2013, 04:44 AM   #6
yashfire007
Member
 
Registered: Jan 2013
Distribution: CentOS, RHEL 6.4
Posts: 79

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by RaviTezu View Post
1.You need a partition to expand the swap.(you can use fdisk command )
2.Let's take /dev/sda6 as example.
3.Run sudo mkswap /dev/sda6
4.Technically speaking, you’re not formatting the partition; rather,you’re writing a small amount of information to indicate to the kernel that it can be used as swap space.
You can immediately activate the new swap partition via the swapon command. This command tells the kernel it can use the specified partition as swap space.
5.Run sudo swapon /dev/sdb6
This command will complete without printing anything, but you can check dmesg for
information on what happened.
If have created a new partition for SWAP , Is there will be two SWAP partitions in my system..
 
Old 02-14-2013, 04:56 AM   #7
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
Quote:
Originally Posted by yashfire007 View Post
If have created a new partition for SWAP , Is there will be two SWAP partitions in my system..
Yes. You'll have 2 swap partitions.
 
Old 02-14-2013, 06:26 AM   #8
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
You can also create a swap file. From what I have read there is no performance difference between using a swap file and partition. So if you don't have the ability to add/resize a swap partition, but create a swap file and add that to fstab and the two should work in tandem (such has been the case for me). See https://wiki.archlinux.org/index.php/Swap
 
1 members found this post helpful.
Old 02-14-2013, 06:29 AM   #9
Pastychomper
Member
 
Registered: Sep 2011
Location: Scotland
Distribution: Slackware, Devuan, Android
Posts: 132

Rep: Reputation: 243Reputation: 243Reputation: 243
I'd vote for a swap file too.

Traditionally, swapfiles have disadvantages when compared to dedicated partitions, but the big one - that the kernel has to go through an extra layer to access a file, which used to reduce performance - has been overcome in modern kernels.

You still have the potential problems of file fragmentation and not being able to choose where the file physically sits on the hard disc, though. (I'm assuming you have a traditional hard disc - SSDs are a different kettle of fish.) It's possible to place a swap partition on the outer edge of the disc, which reduces read/write times, but a file doesn't give you that luxury. On the other hand, a lot of people don't bother anyway, and as you are already using the system, the best parts of the disc might already be taken.

If you happen to have two hard discs, it's often worth having a swap partition/file on each with equal priority. The kernel alternates the swapping reads (or writes) between them, giving a significant performance boost. If your two swaps are both on the same device, then giving one of them a lower priority avoids the risk of making the disc heads 'dance' between two parts of the disc every time you swap.

Last edited by Pastychomper; 02-14-2013 at 06:36 AM. Reason: Jinxed :)
 
Old 02-14-2013, 06:42 AM   #10
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by Pastychomper View Post
Last edited by Pastychomper; Today at 07:36 AM. Reason: Jinxed
I didn't say your name : punch:
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
memory metric to monitor memory usage or swap? karlochacon Linux - Newbie 5 08-13-2011 03:49 PM
process, memory, swap, virtual memory wakatana Linux - Hardware 1 08-31-2009 07:55 AM
Swap Memory / Virtual Memory in Fedora Core 6 Jojo_CFT Linux - Newbie 2 10-15-2007 04:23 AM
swap memory mystic-d Slackware 13 08-17-2006 09:33 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration