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 07-10-2008, 03:05 AM   #1
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Rep: Reputation: 30
swap space (or) swap file


Dear Friends,

I have a requirement that I have to increase swap in my production Linux RHEL ES 4.0 server. Currently,


[root@oracle ~]# swapon -s
Filename Type Size Used Priority
/dev/cciss/c0d0p3 partition 8217236 160 -1

Now , I understand that I can add swap space or swap file to achieve this.. Can anyone let me know which one is the best option to work with ?..adding swap space or adding swap file ?


Thanks
Yusuf
 
Old 07-10-2008, 03:11 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
You can swap to an entire partitiion, or to a file.

Swapping to a partition has much better performance.
 
Old 07-10-2008, 03:30 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Swap partitions are a little faster, but you have to have some unpartitioned space on your disks to add another swap partition.

It is also more difficult to change the amount of space used for swap if you are using swap partitions, since it requires a change in partitioning on the disk.

So it depends - which is more important for you - a small increase in speed, or flexibility?
 
Old 07-10-2008, 03:36 AM   #4
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
Swap partitions are a little faster, but you have to have some unpartitioned space on your disks to add another swap partition.

It is also more difficult to change the amount of space used for swap if you are using swap partitions, since it requires a change in partitioning on the disk.

So it depends - which is more important for you - a small increase in speed, or flexibility?
Thanks Mathew and Mr.c ,


[root@oracle ~]# fdisk -l

Disk /dev/cciss/c0d0: 73.3 GB, 73372631040 bytes
255 heads, 63 sectors/track, 8920 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 3 3201 25695967+ 83 Linux
/dev/cciss/c0d0p2 4225 8920 37720620 83 Linux
/dev/cciss/c0d0p3 3202 4224 8217247+ 82 Linux swap

Partition table entries are not in disk order

Disk /dev/sda: 293.6 GB, 293630353408 bytes
255 heads, 63 sectors/track, 35698 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 35698 286744153+ 5 Extended
/dev/sda5 1 12450 100004562 83 Linux
/dev/sda6 12451 24900 100004593+ 83 Linux
/dev/sda7 24901 35698 86734903+ 83 Linux


I dont think I have unpartitioned space here , so the only option is to create a swap file ?.. Right ?.. I created swap file many times, but I feel that the system is slow after doin this ?..

Any comments ?


Yusuf
 
Old 07-10-2008, 03:57 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by yusufs View Post
I dont think I have unpartitioned space here , so the only option is to create a swap file ?.. Right ?.. I created swap file many times, but I feel that the system is slow after doin this ?..

Any comments ?


Yusuf
You can add another hard disk and create a swap partition on that. I would not recommend using a flash drive for swap as they have a fairly limited number of read/write cycles, and a swap device might kill one pretty quick.

What swap does is enable you to run programs for which you do not have enough physical memory, or allowing you to run more concurrent processes than you would be able to without swap.

If you are not having "out of memory" problems with your current system load, and do not need to change this, then you do not need to add more swap.

Adding more swap if you are not changing the load on he system may change how the OS allocates physical RAM, which may affect performance, but it may not.

If you are adding swap so that you can run more or larger programs, then it is likely that you will get a performance hit on any given process. If this is the case then you must decide which is more important - performance for a given process or the ability to run more/larger processes.

If your system's physical memory can be expanded, this is probably a better option, given that RAM is pretty cheap these days. Of course, this won't help you if your system is already loaded with as much RAM as it can take.
 
Old 07-10-2008, 04:27 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Swapping to a partition has much better performance.
This may have been true for 2.4 kernels, but certainly isn't for 2.6
There is no difference - the way the (physical) swap I/O is handled was changed markedly in the 2.5 timeframe. All the swap I/O is now handled by the normal block driver - no filesystem entanglement.

Choose whatever is most convenient.
 
Old 07-10-2008, 04:59 AM   #7
Vit77
Member
 
Registered: Jun 2008
Location: Toronto, Canada
Distribution: SuSE, RHEL, Mageia
Posts: 132

Rep: Reputation: 17
I've found that the system performance depends on number of swap places (partitions, files).
So, I'd recommend to create a swap file. Then, in case you need more swap space, it'd be better not to create a new file, but enlarge the current one.

Some other ideas:
- to use LVM (allows to resize partitions dynamically)
- to add a new HDD (in this case it's recommended to have some swap space on each drive)
 
Old 07-10-2008, 06:08 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If you are actually swapping, look at assigning the same priority for multiple swap extents. The swap daemon will "soft stripe" across all that are at the same priority - works well.
Best is not to have (any of) your swap on a disk that has other I/O - especially active binaries.

Don't know about using LVM - just another level of software to get in the way. I've never tested it tho', as I don't use LVM.
 
Old 07-17-2008, 02:02 AM   #9
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by syg00 View Post
If you are actually swapping, look at assigning the same priority for multiple swap extents. The swap daemon will "soft stripe" across all that are at the same priority - works well.
Best is not to have (any of) your swap on a disk that has other I/O - especially active binaries.

Don't know about using LVM - just another level of software to get in the way. I've never tested it tho', as I don't use LVM.
Thanks Mathew,syg00 and Vit77.. It helped me in getting a better understanding.



Yusuf
 
  


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
swap file vs. swap partition verndog Ubuntu 16 07-09-2012 08:49 PM
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 03:20 AM
Redistribute Swap file space to main partition stuartornum SUSE / openSUSE 11 10-30-2006 03:49 PM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM

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

All times are GMT -5. The time now is 09:24 AM.

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