05 March 2013

355. Compiling kernel 3.8.2 on Arch linux -- exploration

Edit: remove the sudo make install line -- it shouldn't be necessary and it triggers an error: 'cannot find LILO'

You can generate a good starting .config with make localconfig which creates a .config which prepares the modules which are in use by your system at that point. You can also get the old kernel config from /proc/config.gz which is probably a better approach.

I would guess that the approach described here is pretty much distro-agnostic.

Anyway, compiling the kernel:

mkdir ~/tmp
cd ~/tmp
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.8.2.tar.bz2
tar xvf linux-3.8.2.tar.bz2
cd linux-3.8.2/
cp /proc/config.gz .
gunzip config.gz
mv config .config
make oldconfig
make -j2
make -j2 modules
sudo make modules_install
sudo make headers_install INSTALL_HDR_PATH=/usr/src/linux-3.8.2
sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-3.8.2
sudo cp System.map /boot/System-3.8.2.map
sudo mkinitcpio -k 3.8.2-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-3.8.2.img

NOTE: the naming isn't random. In order for grub-mkconfig to discover both the vmlinuz and initramfs files they need to be named vmlinuz-IDENTIFIER and initramfs-IDENTIFIER.img. The identifier can be anything.

Generate your grub.cfg:
sudo grub-mkconfig -o /boot/grub/grub.cfg

Reboot, and do
uname -a
Linux titanium 3.8.2 #1 SMP Mon Mar 4 20:17:17 EST 2013 x86_64 GNU/Linux


  1. Little , can not be recognized.

    1. Note sure I understand...

    2. linux-3.8.2,tar.bz2
      and it says ==> ERROR: '/lib/modules/3.8.2' is not a valid kernel module directory

    3. OK, it looks like you tried to run
      tar xvf linux-3.8.2,tar.bz2 ?

      Anyway, turns out that there's a typo -- the , should be a . i.e
      tar xvf linux-3.8.2.tar.bz2

    4. When I say
      sudo mkinitcpio -k 3.8.2 -c /etc/mkinitcpio.conf -g /boot/initramfs-3.8.2.img
      it said
      ==> ERROR: '/lib/modules/3.8.2' is not a valid kernel module directory
      thanks for the help :)

    5. Did all the previous steps work properly? Did the kernel build and install successfully? Is there a /lib/modules/3.8.2 directory?

    6. None of them displayed a problem. Kernel builded. It take about one hour. yes that folder has a kernel folder and "modules" files.

    7. I'll see if I can have a look at it over the weekend.

    8. Fixed it. Do
      sudo mkinitcpio -k 3.8.2-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-3.8.2.img

  2. /usr/src/linux is not used anymore. They recommend the home directory. I think the old way is better but I just wanted to share that because it will be a source of problems.

    1. Thanks for the feedback/warning.

      Presumably like you, I don't see why a random home directory should be preferable to a standardised location though.