Rolling a fat one (kernels)
It's been 5 years since I've had to roll my own kernel and things have changed. I've always viewed ramdisks as somewhat of a dark art, but they appear to be highly configurable. I was just too lazy/in too much of a hurry in the past to find out how they were built.
So, download the source from www.kernel.org (or mirrorservice.org for our UK based viewers).
Unpack into /usr/src as per normal and make the symlink
# cd /usr/src
# ln -s linux-2.x.yz.ab linux
# cd linux
Copy the appropriate config file from wherever you want /boot/config* is a good first stab.
# cp config-2.x.yz.ab-generic .config
Edit the Makefile and add your appropriate Extraversion
FROM:
VERSION = 2
PATCHLEVEL = x
SUBLEVEL = yz
EXTRAVERSION = .ab-generic
NAME = Flesh-Eating Bats with Fangs
TO:
VERSION = 2
PATCHLEVEL = x
SUBLEVEL = yz
EXTRAVERSION = .ab-tb1
NAME = Flesh-Eating Bats with Fangs
Time to update the config. oldconfig saves time as it just builds/converts and makes sensible decisions for you. make config is for the hardcore.
# make oldconfig
# make menuconfig
Tweak as necessary.
Copy .config config-2.x.yz.ab-tb1
If you want to build a Debian package, then the easiest way is:
# make-kpkg kernel_image --append-to-version tommybobbins1
Slightly oddly make-kpkg doesn't make the initrd.img correctly (as far as I could see- loads of people reporting errors, but only hacks to fix it). I decided to roll my own as I was determined to understand exactly what I needed to get it to boot. Also Automagic grub editing on roll your own kernels gives me the heeby-jeebies.
If you like to roll and deploy old school:
# make bzImage; make modules; make modules_install
Now you need a Ramdisk. Now there is a clever little directory which is called /etc/initramfs-tools. You need to understand this directory quite well - modules and initramfs.conf being very important.
I made my own copy of this directory as I had particular needs (needed to make sure the SATA drivers were loaded into the Ramdisk) so I created /etc/initramfs-tools-custom and then added to /etc/initramfs-tools-custom/modules
# List of modules that you want to include in your initramfs.
#
# Syntax: module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod
ahci
usbhid
Now it's time to create our Ramdisk:
# mkinitramfs -d /etc/initramfs-tools-custom -o initrd.img-2.x.yz.ab-tb1 2.x.yz.ab-tb1
Gather all the needed files
# mkdir /home/tommybobbins/Desktop/DEPLOY_KERNEL/
# cp /usr/src/linux/System.map /home/tommybobbins/Desktop/DEPLOY_KERNEL/System.map-2.x.yz.ab-tb1
# cp initrd.img-2.x.yz.ab-tb1 /home/tommybobbins/Desktop/DEPLOY_KERNEL
# cp /usr/src/linux/arch/i386/boot/bzImage /home/tommybobbins/Desktop/DEPLOY_KERNEL/vmlinuz-2.x.yz.ab-tb1
# zip -r /home/tommybobbins/Desktop/DEPLOY_KERNEL/modules.zip /lib/modules/2.x.yz.ab-tb1/
Obviously, the System.map, the Kernel and the Ramdisk need to end up in /boot and the modules need to end up in /lib/modules/2.x.yz.ab-tb1
If using Grub <2 and assuming your root filesystem is on /dev/sda1 then edit /boot/grub/menu.lst and add the following:
title TEST
root (hd1,0)
kernel /vmlinuz-2.x.yz.ab-tb1 root=/dev/sda1 ro
initrd /initrd.img-2.x.yz.ab-tb1
quiet
Save and then run grub-install
# /usr/sbin/grub-install /dev/sda
If using GRUB2, then please see here:
http://ubuntuforums.org/showthread.php?t=1195275
Next post about Netbooting, gPXE's epicness and making monolithic kernels (and when did monolithic kernels go from floppy sized to 4MB?).
0 comments:
Post a Comment