Xupeng's blog

Apr 1, 2009 - 3 minute read - Comments

Upgrade kernel to 2.6.29 for my debian unstable

Two reasons made me want to upgrade my kernel from 2.6.26 to 2.6.29 for my Debian unstable:
  1. It's weird that my mobile hard disk make annoying sound even if I "eject" it before I pull out the USB cable, it's the same sound as the hard disk makes when I power off the computer directly without shutting down the OS.
  2. I want to mount my ext4 volume created by Fedora Core 10, it contains a lot of data I need.
So I download the latest kernel from kernel.org, unzip it to /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.tar.bz2
cd /usr/src
tar xf linux-2.6.29.tar.bz2
ln -s linux-2.6.29 linux
Then configure kernel for my DELL 1420
cd linux
make defconfig
"make defconfig" is very useful for me, I don't want to compile the tons of kernel modules/drivers I'll never need for my computer, so I run "make defconfig" first before I configure the kernel by myself, it removed most of the modules/drivers that have no relationship with my hardware. After "make defconfig" completed, I issue "make menuconfig" to run the menu-based kernel configuration interface, actually I only review the configuration to make sure all the necessary drivers needed by computer are selected, and make little changes to it, for example settings about ACPI, network devices(tun, tap etc), and filesystem(Of course I select ext4;), I made most of the drivers builtin instead of plugable modules, my philosophy of compiling kernel is to let it work just as I want it to, I don't want to spend too much time on it, the current configuration is good enough for me. Then I run "make && make install && make modules_install" to compile the kernel, kernel modules, install the kernel itself and all the compiled kernel modules. I am using LVM, and my / sits on a LVM volume, so I have to generate initrd image for the new kernel:
update-initramfs -c -k 2.6.29
"update-initramfs" is debian's command to help users generate initramfs image easily, many Linux distributions have their own methods to generate this image, for example Gentoo use genkernel to compile kernel and generate initramfs image automatically, and redhat-based distributions have mkinitrd command to do this if I remember right. "-c" is to tell update-initramfs to create new initramfs image, and "-u" is to update an existing initramfs of course, "-k" is to specify the kernel version to generate initramfs against to, this command will generate file /boot/initrd.img-2.6.29. All the needed files have been compiled and generated, I update /boot/grub/menu.lst to add new grub item for the new kernel:
title Debian 2.6.29
root (hd0,4)
kernel /vmlinuz-2.6.29 root=/dev/mapper/nb-debian64 ro vga=791
initrd /initrd.img-2.6.29
savedefault
Reboot the system and select the new item from grub menu, the new kernel boots smoothly, and I see the new logo for kernel 2.6.29 ;) I am lucky but not that lucky as I thought, my hard disk still make noise when I pull out the USB cable, I have to spend more time on this issue... Now is time for the second reason I upgrade my kernel, unfortunately, error occurs when I mount an existing ext4 volume created by my previous Fedora core 10:
[12034.562345] EXT4-fs: dm-3: Filesystem with huge files cannot be mounted read-write without CONFIG_LBD.
After read this post, looks like on 32bit system, if CONFIG_LBD is not enabled when compiling kernel, ext4 volume will can only be mounted in readonly mode, so I re-configue the kernel to enable CONFIG_LBD, then I can mount the ext4 volume successfully. PS: to enable CONFIG_LBD, go to "Main menu" -> "Enable the block layer" -> "Support for large block devices and files".