July 30

Enabling PAE on a 32 bit Ubuntu Desktop supporting up to 64 GB

I think most people would agree with me that 64 bit Linux is not the greatest desktop right now. In fact 64 bit Operating Systems in general are out performed by 32 bit until you start to get into ram sizes above 4GB where native physical address extension will top out the 32 bit added physical address extension. Even then the 32 bit applications run faster so unless you are planning on running a enterprise level workstation or server the 64 bit version is not necessary. Also, it is easier to find games and programs to run natively in a 32 bit OS so I personally prefer to use it as a desktop. As you may know, a 32 bit Ubuntu installation out of the box will only support 2.7GB of ram without PAE. This is a limitation of the 32 bit kernel but can easily be overcome by a recompile. In this tutorial I will walk you though the installation of needed packages, the obtaining of the kernel source, the recompiling and the packaging of the .deb files so you can install this easily should you need a reload or want to share the kernel with a friend. I found very few resources on the net for doing a recompile in Ubuntu and those I did find never mentioned PAE which is probably the most desired kernel option. Let’s get started!

Do I need PAE?

The fastest way to determine this is knowing what size ram you have installed in the system.Either login as root or sudo su and you can do the following:

# dmidecode | grep Size | grep MB
Maximum Memory Module Size: 4096 MB
Maximum Total Memory Size: 8192 MB
Installed Size: 2048 MB (Double-bank Connection)
Enabled Size: 2048 MB (Double-bank Connection)
Installed Size: 2048 MB (Double-bank Connection)
Enabled Size: 2048 MB (Double-bank Connection)
Size: 2048 MB
Size: 2048 MB

As you can see above we have 4096 MB of ram installed for a total of 4GB. Now let’s see what the OS reports:

# free -m
               total       used       free     shared    buffers     cached
Mem:           2771        704       2066          0         98        320
-/+ buffers/cache:        285       2485
Swap:         2045          0       2045

Based on the output above we can now see that the system can only see roughly 2.7GB of the 4GB installed.

Prerequisites

We will need some tools installed along with kernel sources so we can recompile. As sudo su or root issues the following commands:

# apt-get install linux-source-2.6.28 kernel-package libncurses5-dev fakeroot

Once these packages installed you will need to go to the source directory to extract the bzip file. A quick way of knowing where the source can be found is by issuing the below command:

# dpkg -L linux-source-2.6.28
/.
/usr
/usr/src
/usr/src/linux-source-2.6.28.tar.bz2
/usr/share
/usr/share/doc
/usr/share/doc/linux-source-2.6.28
/usr/share/doc/linux-source-2.6.28/copyright
/usr/share/doc/linux-source-2.6.28/changelog.Debian.gz

Based on this output we know the kernel source can be found in /usr/src. So lets cd to that directory:

# cd /usr/src/

Now we need to extract the contents of our kernel source with the following two commands:

# bunzip2 linux-source-2.6.28.tar.bz2
# tar xvf linux-source-2.6.28.tar

We now need to create a symlink in the src directory:

# ln -s linux-source-2.6.28 linux

The enter the symlinked directory:

# cd linux

Getting the recompile of the kernel going

To saves us some time from building a completely new config, let’s copy the old ( unless you want to build a new one) :

# cp /boot/config-`uname -r` /usr/src/linux/.config

Now let’s enable PAE support from make menu config:

# make menuconfig

Then scroll down and select –> load alternate config and load the .config and hit enter.

kernel1

From this screen select –> Processor type and Features

kernel2

Then –> High Memory Support (64GB)  – note: It will say support for 4gb is there bit it is a lie!

kernel3

Select –> 64GB

kernel4

Select –> Exit

kernel5

Select –>Exit

kernel6

Once these steps are complete, we will now start the recompile ( This can take some time, so grab a beer and watch T.V. or something):

# make-kpkg --initrd --append-to-version=-mykernel kernel_image kernel_headers

Note: the append-to-version=-mykernel can contain whatever you want so you can change this to say im1337 or whatever.

When the recompile finally finishes, cd to /usr/src and there will be two .debs for your kernel, install them as shown below:

# dpkg -i linux-headers-2.6.28.9-mykernel_2.6.28.9-mykernel-10.00.Custom_i386.deb
# dpkg -i linux-image-2.6.28.9-mykernel_2.6.28.9-mykernel-10.00.Custom_i386.deb

Reboot and you should now be good to go as the new kernel will default as #0 in the /boot/grub/menu.1st file. If anything goes wrong your old kernels will be there and you can boot back into them however any issues arising from this process is highly doubtful.


Copyright © 2014. All rights reserved.

Posted July 30, 2009 by Dustin Larmeir in category Linux

19 thoughts on “Enabling PAE on a 32 bit Ubuntu Desktop supporting up to 64 GB

  1. Ian

    Perhaps the most helpful thing I’ve ever read!!! !!! I’ve never compiled a kernel before so this was great. Not one step was left out and a good job explaining what each step was so I actually LEARNED. Thank you so much. This is the type of stuff that makes Linux so great!

  2. Pingback: Enabling PAE on a 32 bit Ubuntu Desktop supporting up to 64 GB | Ubuntu-News - Your one stop for news about Ubuntu

  3. Rick

    Followed this and now I get an Error 17 when Grub starts…

    I haven’t installed the RAM though, but I doubt that could be the issue. Any ideas?

    8.04 LTS. I tried commenting out the lines loading the new kernel, but it has no effect.

  4. Brian W

    I followed the steps here but I still see 3 gigs of RAM instead of 8. Do I have to pass the kernel a command line parameter?

    Also, do the proprietary drivers in Ubuntu have to be disabled first before installing the custom kernel?

  5. dlarmeir (Post author)

    Hello, Brian – in regards to the 3gb issue, try running dmidecode or lshw to see what dimms the OS is seeing. If these utilities see the ram then something went wrong during the make menuconfig process. There is no special lines that need to be passed but it is possible that your custom kernel is not listed as 0 in the /boot/grub/menu.1st file and needs to be adjusted accordingly.

    In regards to the proprietary drivers these can cause issues (such as nvidia) and most of the time it is better to run your own compiled drivers when modifying the kernel. I use the source from NVidia’s site personally.

  6. Brian W

    Hi, Dustin!

    I did run dmidecode and lshw and they did see the RAM so that means something did go wrong during the menuconfig process so I may install your 2.6.30 kernel instead. :)

  7. Pingback: Linux kernel 2.6.31 – Desktop speed enhancements and other improvements. | Larmeir.com

  8. Johannes

    Hi,
    first of all thank you for this page, PAE seems to be the solution for my problem. I need two graphic cards and each of them has 512MB memory, so the maximum RAM I can have seems to be 2GB (while I have three 1GB modules). For testing, I installed the server kernel, and voilà i have 2,9 GB, with the client kernel, its only 2GB.

    But now, I want to use the client kernel… I tried to compile the kernel using your description, but when installing the image package, I get an error:

    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/dkms
    run-parts: executing /etc/kernel/postinst.d/nvidia-common
    run-parts: /etc/kernel/postinst.d/nvidia-common exited with return code 20
    Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.28.10-mykernel.postinst line 1186.
    dpkg: Fehler beim Bearbeiten von linux-image-2.6.28.10-mykernel (–install):
    Unterprozess post-installation script gab den Fehlerwert 2 zurück
    Fehler traten auf beim Bearbeiten von:
    linux-image-2.6.28.10-mykernel

    So it seems to have something to do with the nvidia driver, I am using the proprietary one. Could you explain, what you did with the source from the nvidia website? This is the first time, I compiled a linux kernel, so I dont know hiw to get it to work with the graphic drivers.

    Thx in advance!
    Johannes

  9. Henning

    Thanks for these hints…

    But I had trouble installing the kernel-image package, I got

    run-parts: executing /etc/kernel/postinst.d/nvidia-common
    run-parts: /etc/kernel/postinst.d/nvidia-common exited with return code 20
    Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.28.10-henningpae.postinst line 1186.
    dpkg: error processing linux-image-2.6.28.10-henningpae (–install):
    subprocess post-installation script returned error exit status 2
    Errors were encountered while processing:
    linux-image-2.6.28.10-henningpae
    root@mariacron:/data/produktion/tmp#

    it could be resolved by removing the package nvidia-common.

    (UBuntu 9.04 Jaunty)

  10. Manavendra Nath Manav

    Hi, Thanks for the elaborate and detailed article on enabling PAE on Ubuntu. However, i got struck at the last command to install custom-linux-image deb package. After this, the new custom kernel is not showing up in the grub boot menu. The debug output of the last command is:

    root@manav-workstation:/usr/src# dpkg -i linux-image-2.6.31.4-mykernel_2.6.31.4-mykernel-10.00.Custom_i386.deb

    (Reading database … 176378 files and directories currently installed.)
    Preparing to replace linux-image-2.6.31.4-mykernel 2.6.31.4-mykernel-10.00.Custom (using linux-image-2.6.31.4-mykernel_2.6.31.4-mykernel-10.00.Custom_i386.deb) …
    Done.
    Unpacking replacement linux-image-2.6.31.4-mykernel …
    Running postrm hook script /sbin/update-grub.
    Searching for GRUB installation directory … found: /boot/grub
    Searching for default file … found: /boot/grub/default
    Testing for an existing GRUB menu.lst file … found: /boot/grub/menu.lst
    Searching for splash image … none found, skipping …
    Found kernel: /boot/vmlinuz-2.6.31.4-mykernel
    Found kernel: /boot/vmlinuz-2.6.31-14-generic
    Found kernel: /boot/vmlinuz-2.6.28-11-generic
    Found kernel: /boot/memtest86+.bin
    Updating /boot/grub/menu.lst … done

    Setting up linux-image-2.6.31.4-mykernel (2.6.31.4-mykernel-10.00.Custom) …
    Running depmod.
    Finding valid ramdisk creators.
    Using mkinitramfs-kpkg to build the ramdisk.
    initrd.img(/boot/initrd.img-2.6.31.4-mykernel
    ) points to /boot/initrd.img-2.6.31.4-mykernel
    (/boot/initrd.img-2.6.31.4-mykernel) — doing nothing at /var/lib/dpkg/info/linux-image-2.6.31.4-mykernel.postinst line 588.
    vmlinuz(/boot/vmlinuz-2.6.31.4-mykernel
    ) points to /boot/vmlinuz-2.6.31.4-mykernel
    (/boot/vmlinuz-2.6.31.4-mykernel) — doing nothing at /var/lib/dpkg/info/linux-image-2.6.31.4-mykernel.postinst line 588.
    Running postinst hook script update-grub.
    Searching for GRUB installation directory … found: /boot/grub
    Searching for default file … found: /boot/grub/default
    Testing for an existing GRUB menu.lst file … found: /boot/grub/menu.lst
    Searching for splash image … none found, skipping …
    Found kernel: /boot/vmlinuz-2.6.31.4-mykernel
    Found kernel: /boot/vmlinuz-2.6.31-14-generic
    Found kernel: /boot/vmlinuz-2.6.28-11-generic
    Found kernel: /boot/memtest86+.bin
    Updating /boot/grub/menu.lst … done

    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/dkms
    run-parts: executing /etc/kernel/postinst.d/nvidia-common
    run-parts: /etc/kernel/postinst.d/nvidia-common exited with return code 20

    Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.31.4-mykernel.postinst line 1186.

    dpkg: error processing linux-image-2.6.31.4-mykernel (–install):
    subprocess installed post-installation script returned error exit status 2
    Errors were encountered while processing:
    linux-image-2.6.31.4-mykernel

    root@manav-workstation:/usr/src#

    I guess that the error might be due to nvidia drivers as I don’t have any nvidia graphics card but ATI Raidon card. However, i cannot understand why it is compiling nvidia drivers. I am planning to remove the support for nvidia drivers from “make menuconfig” and give a try again. What do you suggest ??

  11. Manavendra Nath Manav

    Following commands can do the trick:

    # sudo chmod -x /etc/kernel/postinst.d/nvidia-common

    # sudo apt-get purge nvidia-common

  12. Tom

    Hi Dustin,

    One thing I found out following your procedure is that it results in a default debug version of the kernel image which was humongous at 142MB and takes 2 hours on my P4 at 3.2GHz w/hyperthreading. If you add a step in the ‘make menuconfig’ part to choose kernel-hacking and then select N to exclude kernel debugging during the compile you will wind up with a kernel-image in the range of 32MB which takes about 1hr 40min to complete on my system.

    My quest is somewhat different than those who are installing Ubuntu. What I am trying to do is to build a LiveCD PAE version of Karmic (9.10). When I substituted the PAE versions of packages for the generic versions in a chrooted environment to build the Lice CD, I ran into three problems:
    1) the mount command for a CDROM did not work after booting up the PAE Live CD,
    2) iptables depended on the generic version of /lib/modules rather than the -pae version,
    3) and there was a 4MB inconsistency in one of the package’s size vs a zero length indicated in the /var/lib/dpkg/info .list version of the files contained in the package – a real stumper.

    Thus the search or other means/methods of arriving at a linux-image PAE kernel.

    Thanks for all the info – it certainly is a journey!

    – Tom

  13. Arun

    I am using a physical machine for server
    Configs are
    Core2Duo E 4400 2.Ghz (EM64T capable)
    4x2GB DDR2 667 Mhz RAM in Dual Channel
    in my BIOS it shows total RAM as 8096 MB
    and i downloaded Ubuntu server 11.04 64 Bit for AMD 64 platform(which has support for xeon core2Duos and core2Quads etc)
    and installed it .
    when i type in terminal ” free -m ” to check the ram it shows as 3216 GB

    and for cpu info when i typed this ” grep flags /proc/cpuinfo ” i got the following flags

    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm

    also this command clearly verifies that my CPU suuports PAE

    grep –color=always -i PAE /proc/cpuinfo”

    CPU Modes:( Source Ubuntu Forums )

    lm flag means Long mode cpu – 64 bit CPU
    Real mode 16 bit CPU
    Protected Mode is 32-bit CPU

    should i follow ur guide on kernal recompilation as u said above by just changing 2.6.28 with my version ? 2.6.3x ? please help me

  14. Pingback: Anonymous

  15. Pingback: Linux kernel doesn't see all my RAM

  16. Pingback: Why Does My 32bit Ubuntu See 8GB Of RAM? | Click & Find Answer !

Leave a Comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>