See also: DebianLinux, UsingApt, RedhatKernelPackage
Compiling a Kernel the Debian Way
- # apt-get install kernel-source-2.4.17
- # cd /usr/src
- # tar jxvf kernel-source-2.4.17.tar.bz2
- # ln -s kernel-source-2.4.17 linux
- # cd linux
- # vi Makefile (optional)
- Set EXTRAVERSION = -YYYYMMDDn ( i.e. to todays date, where n is a daily serial no. That way /lib/modules won't get confused)
- # cp /boot/config-2.4.16 .config (optional)
- Gets the stock Debian config so you can just modify what you need to
- # make oldconfig
- # make-kpkg clean
- # make-kpkg --initrd --config xconfig --revision=2:hostname.1.0 kernel-image
- # dpkg -i kernel-image-2.4.17_heyzeus.1.0_i386.deb
- .. and if want to build PCMCIA deb's as well
- # apt-get install pcmcia-source
- # cd /usr/src
- # tar zxvf pcmcia-modules.tar.gz
- # cd linux
- # make-kpkg modules_image
- # cd ..
- # dpkg -i ../pcmcia-*.deb
Notes:
You only need the --initrd option to make-kpkg if you're building an initrd (Initial RamDisk) kernel image.
In the make-kpkg line heyzeus is the name of the machine that I'm building the kernel for and 1.0 is the version of my build. The cryptic looking 3: colon part is setting the package epoch. What this means is that your kernel package will always have a higer version number then the default Debian kernel package so it will never get overwritten when you upgrade.
There's a good article from the Linux AU magazine which covers kernel compilation the Debian way.
These are later docs that are probably better and I should integrate them. -- AdamShand
# apt-get install make gcc libc6-dev binutils patch bin86 bin86 is required for intel arch only # apt-get install dpkg-dev debhelper kernel-package debianutils dh-make # apt-get install ncurses-dev (for menuconfig) # apt-get install initrd-tools fileutils modutils fdutils # apt-get install pcmcia-source if you need pcmcia support make sure you have recent enough versions of various utilitites (including grub and lilo) # apt-get install kernel-image-2.4.8-386 (this isn't required but we want the config file) # apt-get install kernel-source-2.4.8-386 # cd /usr/src # tar Ixvf kernel-source-2.4.8.tar.bz2 # ln -s kernel-source-2.4.8 linux # cd linux # cp /boot/config-2.4.8-386 .config # make oldconfig # make menuconfig (or menuconfig or config) (you need to remove the initrd crap at the bottom of the block devices section and make sure the ext2 is compiled in (not a module) in the filesystem section. if you wanna use the pcmcia-cs stuff disable pcmcia in the general section) or just remove pcmcia stuff to build pcmcia manually later. # make-kpkg --revision=2:hostname.1.0 kernel-image # apt-get remove kernel-image-2.4.8-386 (unless this is your only bootable kernel!!) # dpkg -i ../kernel-image-2.4.8_hostname.1.0.i386.deb # vi /boot/grub/menu.1st or vi /etc/lilo.conf (and if you use lilo remember to run lilo!) # shutdown -r now if you can boot safely great and don't use pcmcia then you are done, congratulations! if you use a pcmcia and especially if you use a pcmcia card for your main network connectivity then you need to build the pcmcia stuff to match your kernel # cd /usr/src # tar zxvf pcmcia-cs.tar.gz # make-kpkg --revision=2:hostname.1.0 modules # mkinitrd -o /boot/initrd-2.4.8 /lib/modules/2.4.8/ --- http://194.241.248.126/Prism2/ download Prism2-2001-07-11.tar.gz and read instructions. tar zxvf /tmp/Prism2-2001-07-11/prism2-0.0.0.tar.gz -C /usr/src/modules/pcmcia-cs