Dustin Larmeir's tech blog.
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 2045Based 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.
From this screen select –> Processor type and Features
Then –> High Memory Support (64GB) – note: It will say support for 4gb is there bit it is a lie!
Select –> 64GB
Select –> Exit
Select –>Exit
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.
| Print article | This entry was posted by dlarmeir on July 30, 2009 at 5:27 pm, and is filed under Past Blogs. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |






about 1 year ago
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!
about 1 year ago
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.
about 1 year ago
That sounds like a Grub boot loader issue more than a kernel problem. This thread may help:
http://ubuntuforums.org/archive/index.php/t-5134.html
and
http://www.linuxforums.org/forum/slackware-linux-help/54246-grub-error-17-a.html
These go over a fsck and the grub-install command which may get you back up.
Good Luck – Dustin
about 1 year ago
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?
about 1 year ago
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.
about 1 year ago
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.
about 12 months ago
By all means
about 11 months ago
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
about 10 months ago
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)
about 9 months ago
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 ??
about 9 months ago
Following commands can do the trick:
# sudo chmod -x /etc/kernel/postinst.d/nvidia-common
# sudo apt-get purge nvidia-common
about 9 months ago
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