You are not logged in.

#1 2014-06-13 18:15:01

gnomikian
Member
Registered: 2009-04-11
Posts: 35

cannot allocate memory for swap partition

Hi,

I'm trying to install the i686 version on my laptop which have 16gb ram (ok, I know you would ask why I don't use the x86_64 version instead but I have my reasons so I decided to use a pae kernel instead).

The problem I'm facing is when I created my 8GB swap partition, I tried to activate it with swapon, but now here's the error:

swapon: /dev/sda2/: swapon failed: cannot allocate memory.

I tried it with 5GB and it works so the question is: why doesn't it work for 8GB ?

It shouldn't be because I'm using a 32 bit install cause, if I understand it correctly, a swap file is: just a file... so the size shouldn't matter right ?

If I can play a 25GB blu-ray video file under 32 bit  by example, I should be able to create a 25GB swap file if I want to no ?

I would like to be enlightened on the subject.

Any help will be very appreciated.

Thanks in advance.

Offline

#2 2014-06-13 18:17:47

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cannot allocate memory for swap partition

Are you using a swap partition or a swap file?
Are you using linux-pae kernel?
Can you post the output of 'free -m'?

Offline

#3 2014-06-13 18:29:04

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Hi karol,

Q. Are you using a swap partition or a swap file?
A. I'm trying to use a swap partition as the installation wiki says.

Q. Are you using linux-pae kernel?
A. Not at the moment since I'm trying to install it, do you mean if I skip the swapon part and install a pae kernel afterwards that will solve my problem ?

Q. Can you post the output of 'free -m'?
A. No since I can't pass the installation yeat.

Thanks for your support.

Offline

#4 2014-06-13 18:36:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cannot allocate memory for swap partition

Why do you need such a big swap partition in the first place?
Have you tried using a 3 GB swap partition?

Offline

#5 2014-06-13 18:46:14

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

I did read that for 8GB to 64GB a swap file of 0.5 times RAM is recommended (I think that was from RHEL), so because I have 16GB I wanted to use 8GB for the swap partition.

and assuming there's a 4GB limit for every process I assume 8GB swap would be just fine.

Thanks for your support

Offline

#6 2014-06-13 18:53:10

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cannot allocate memory for swap partition

What do you need swap for?

Offline

#7 2014-06-13 20:11:14

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Well.. mostly for video editong, encoding. Some database programming, compiling etc...  I wouldn't want to start a process and, after a while, it gets interrupted because the lack of memory.

Offline

#8 2014-06-13 20:24:27

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cannot allocate memory for swap partition

Can you share why don't you want to use 64-bit?
Have you tried using a 3 GB swap partition?

Offline

#9 2014-06-13 20:40:52

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

A bunch of software I use is 32 bit only, like wine and others, I don't see the point of installing a 64 bit OS and be in the need to install every 32 bit libraries that I will need after.  I prefer to just install a 32 bit os and be done with that.  Honestly, when every software will be 64 bit I would install a pure 64 bit operating system.  64 bit os with 32 bit libraries (hybrid) looks more than a patched system to me.  So either go to full 32 bit or full 64 but not both <- I still don't see why I can't do it.  I searched the internet for the swap partition limits under 32 bit, it should be any size through 64GB but still, swapon refuses to allocate memory beyond 5GB (for my system), I did achieved 6GB on another laptop.  I have to find the reason why swapon does work with 6GB but not 8GB.

Offline

#10 2014-06-13 22:18:46

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Okay, here's the official documentation:

from: http://www.tldp.org/HOWTO/Partition/requirements.html

4.4. Swap Partitions

4.4.2. How large can my swap space be?

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. For linux kernels 2.1 and earlier, the limit is 128Mb. The partition may be larger than 128 MB, but excess space is never used. If you want more than 128 MB of swap for a 2.1 and earlier kernel, you have to create multiple swap partitions (8 max). After 2.4, 32 swap areas are "officially" possible. See setting up swap for details.

footnote: "official" max swap size: With kernel 2.4, the limit is 64 swap spaces at a maximum of 64Gb each, although this is not reflected in the man page for mkswap. With the 64 bit opteron on the 2.6 kernel, 128 swap areas are permitted, each a whopping 16 Tb! (thanks to Peter Chubb for the calculation)

So by reading this, under a 2.4 kernel I should be able to use a single 64GB swap partition, however I cannot even allocate a 8GB swap one with swapon, mkswap works but not swapon.

swapon is still a mystery...

Offline

#11 2014-06-13 22:23:42

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cannot allocate memory for swap partition

I don't know how up-to-date this info is.

gnomikian wrote:

So by reading this, under a 2.4 kernel I should be able to use a single 64GB swap partition, however I cannot even allocate a 8GB swap one with swapon, mkswap works but not swapon.

For i386, m68k, ARM and PowerPC, it is "officially" 2Gb.

Offline

#12 2014-06-13 22:33:37

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Well if very old kernels supported 64GB swap partitions, I had to think newer ones should support at least the latter or more no ?

Offline

#13 2014-06-13 22:46:47

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

As I can see, from googleing, swapon works fine under debian on a 2.6x kernel for 8GB swap partition

see here: http://forums.debian.net/viewtopic.php?f=17&t=62741

but not in arch sad

Offline

#14 2014-06-13 22:51:11

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

However, I think if I continue the installation without the swapon part and reboot maybe the problem will resolve by itself ?  I'm kinda out of options here

Offline

#15 2014-06-14 00:44:04

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Just asking, If I reboot with a pae kernel under i686 (3.x), does my 8GB partition swap will be activated ?

or if I must use 2x 4GB swap partitions instead to make it happen

I looked at every linux paper on that subject, there's no mention of swapon limitation under 32 bit beyond 64GB, if mkswap works, swapon should work too.

Any ideas ?

Offline

#16 2014-06-14 00:45:50

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

I presume I'll be a swap guru by tomorrow smile

Offline

#17 2014-06-14 02:22:41

samiam
Banned
From: EAX
Registered: 2010-08-20
Posts: 58

Re: cannot allocate memory for swap partition

gnomikian wrote:

A bunch of software I use is 32 bit only, like wine and others, I don't see the point of installing a 64 bit OS and be in the need to install every 32 bit libraries that I will need after.  I prefer to just install a 32 bit os and be done with that.  Honestly, when every software will be 64 bit I would install a pure 64 bit operating system.  64 bit os with 32 bit libraries (hybrid) looks more than a patched system to me.  So either go to full 32 bit or full 64 but not both <- I still don't see why I can't do it.  I searched the internet for the swap partition limits under 32 bit, it should be any size through 64GB but still, swapon refuses to allocate memory beyond 5GB (for my system), I did achieved 6GB on another laptop.  I have to find the reason why swapon does work with 6GB but not 8GB.

Enable multilib and be done with it. I have a dozen machines running x86_64 with multilib enabled and everything just works. Yes, you'll have 32 bit libraries installed, but that's no bigger a hack than PAE has always been. Out of my 830 installed packages, 72 of them match 'lib32'.

Besides. With 16GB of RAM you don't need swap for compiling or DB dev. You _might_ need it for video, but I doubt it. My 16GB workstation has never hit swap, including when running a dev lab worth of VMs. 

</soapbox>

Are you using a swap file or a swap partition?
Did you mkswap on the partition?

If you insist on using i686 - go ahead and partition the disk, install the system (and PAE kernel), boot into the system and then activate your swap space.

Offline

#18 2014-06-14 02:27:15

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,561

Re: cannot allocate memory for swap partition

gnomikian wrote:

Hi,

I'm trying to install the i686 version on my laptop which have 16gb ram (ok, I know you would ask why I don't use the x86_64 version instead but I have my reasons so I decided to use a pae kernel instead).

Do you know how PAE works? Were you around in the old DOS HIMEM days? PAE is crap.

If you need more information about why, try this: http://cl4ssic4l.wordpress.com/2011/05/ … about-pae/

Offline

#19 2014-06-16 14:40:07

gnomikian
Member
Registered: 2009-04-11
Posts: 35

Re: cannot allocate memory for swap partition

Nice article,  I'll install x86_64 and see how it goes.

Thanks

Offline

Board footer

Powered by FluxBB