Operating System - Linux
1827809 Members
1973 Online
109969 Solutions
New Discussion

Re: multiple swap filesystems

 
SOLVED
Go to solution
Maaz
Valued Contributor

multiple swap filesystems

Dear Gurus

1, does 2.6 kernel support more than 2 GB of swap ?
2, If not, then is it possible to have multiple swap filesystems of 2 GB?
3, If multiple swap partitions are supported then how many max swap partitions do we have ?

One more thing, there are two ways to create swap
1a) create partition of type 0x82
1b) mkswap -v1 /dev/hdaX
1c) add entry in /etc/fstab
1d) swapon -a
But there is another way .. Creating a swap File as:
2) dd if=/dev/zero of=swapfile bs=1024 count=X
plz le me know the diff b/w the two. I have never tried the the second(2).

Regards
Maaz
14 REPLIES 14
Alexander Chuzhoy
Honored Contributor
Solution

Re: multiple swap filesystems

First of all kernel 2.6 supports more than 2 GB of swap.
Why would you want to create as many swap partitions as possible?

as for choosing between swap file and partition:
always when possible create swap partition.
Swap file should be created only in cases when you can't add partitions...
Regards.
Maaz
Valued Contributor

Re: multiple swap filesystems

>First of all kernel 2.6 supports more than >2 GB of swap.
May I ask how much on a pentium4/xeon system ?
I have search this on google but no success, my search string is :
http://www.google.com/search?hl=en&q=maximum+size+of+swap+2.6+kernel+support+is&meta=

>Why would you want to create as many swap >partitions as possible?
Its an assignment. I have told by the higher authorities to provide these information.
Higher Authorities are looking forward to upgrade their all linux systems from 2.4.* to 2.6 kernel.

Regards
Maaz
dirk dierickx
Honored Contributor

Re: multiple swap filesystems

2.6 supports more then 2gb swap and you can have multiple swaps as well.
Ivan Ferreira
Honored Contributor

Re: multiple swap filesystems

I would like to know where did you get the information about 2.6 supporting more than 2 GB swap. From the Red Hat Enterprise 4 installation guide (2.6 kernel) it states that swap partitions cannot be larger than 2 GB. A portion of the document:

"If your partitioning scheme requires a swap partition that is larger than 2 GB, you should create an additional swap partition. For example, if you need 4 GB of swap, you should create two 2 GB swap partitions. If you have 4 GB of RAM, you should create three 2 GB swap partitions. Red Hat Enterprise Linux supports up to 32 swap files"
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vipulinux
Respected Contributor

Re: multiple swap filesystems

Hi
I think Ivan is right.
Although we can have more than 2 gb of swap but 1 partition cant be of more size than 2 gb.

Cheers
Alan_152
Honored Contributor

Re: multiple swap filesystems

Depending on the processors and OS involved, I try not to have more than 4GB (32-bit) or 64GB (64-bit) worth of swap. I always try to place the swap partition on the fastest drive I have.

I don't technically see anything wrong with having more than 1 swap partition (though it does seem strange) as long as the partitions are (1) not on the same physical drive, (2) not on the same interface chain, and (3) not on the same I/O bus. Otherwise, you'll just slow things down.

Ditto for having too much swap space -- the computer has to expend cpu time and real memory space allocating and tracking swap memory addresses.
Maaz
Valued Contributor

Re: multiple swap filesystems

If i wana creat multiple swap partitions
1a) create say 4 partitions of type 0x82
1b) mkswap -v1 /dev/hda3
1c) mkswap -v1 /dev/hda4
1d) mkswap -v1 /dev/hda5
1e) mkswap -v1 /dev/hda6
1f) add entry in /etc/fstab
1g) swapon -a

Am I right ?
Regards
Maaz
Ivan Ferreira
Honored Contributor

Re: multiple swap filesystems

Your procedure is correct, just ensure that you are using the fastest disk (use hdparm -tT to check the speed) and try to separate the swap partitions from data partitions. If you system has enough RAM, swap should not be used and this may not be an issue.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Maaz
Valued Contributor

Re: multiple swap filesystems

One last question ... If I have multiple swap partitions, then which swap partition will be use 'first'

Regards
Maaz
Ivan Ferreira
Honored Contributor

Re: multiple swap filesystems

It depends of the priority asigned to the swap device. Higher priority will be used first. If priority is the same, will try to balance the use.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Ferreira
Honored Contributor

Re: multiple swap filesystems

If you don't specify a priority in the /etc/fstab file (pri=N), swap space will be used in the order listed by swapon -s.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Ferreira
Honored Contributor

Re: multiple swap filesystems

One more insteresting thing, this is from the "Tuning Red Hat Enterprise Linux on IBM eserver xseries servers":

Linux kernels 2.4 and beyond support swap sizes up to 24 GB per partition with an 8 TB theoretical maximum for 32-bit systems. Swap partitions should reside on separate disks.

Anyway, I will use 2 GB partitions for swap until Red Hat Intallation guide confirms this.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Stuart Browne
Honored Contributor

Re: multiple swap filesystems

Having a look through a few things, I've found this.

In /usr/include/linux/swap.h, it shows:

#define MAX_SWAPFILES 32

This file does not however state how big the individual swapfiles can be (This is from a 2.6.14-1.1637_FC4 machine).

From TLDP ( http://www.tldp.org/HOWTO/Partition/requirements.html ):

'Currently, the maximum size of a swap partition is architecture-dependent. For i386, m68k, ARM and PowerPC, it is "officially" 2Gb. It is 128Gb on alpha, 1Gb on sparc, and 3Tb on sparc64. An opteron on the 2.6 kernel can write to a 16 Tb swap partition.'

So, safe side. Stick to multiple 2GB partitions.
One long-haired git at your service...
Maaz
Valued Contributor

Re: multiple swap filesystems

Thanks Dear Ivan Ferreira for Continous Help and support
and Nice help Stuart Browne ;)