Let's download the last vanilla kernel with the below command, the portage will extract the kernel source into /usr/src/linux-x.y.z.t/ (where x.y.z.t are the version numbers), the portage will also create the symbolic link /usr/src/linux:
# emerge vanilla-sources |
Now we must apply the squashfs' patch to our kernel. Squashfs is a read-only compressed filesystem, and it will be treated ahead in this document. Below the steps required to apply, the patch, and to compile to userspace program (mksquashfs) that we will use to create a loop mountable file containing our squashed filesystem:
Downlad the patch (tar.gf format) from the squashfs site http://squashfs.sourceforge.net/. In this document we suppose to download the tar.gz into the /usr/local/src directory. The tar.gz will be extracted in that directory.
Apply the patch:
# cd /usr/local/src/squashfs
# cp linux-2.x.y/squashfs-patch /usr/src/linux
# cd /usr/src/linux
# patch -p1 < squashfs-patch
# make distclean
# make mrproper
|
Compiling the mksquashfs tool:
# cd /usr/local/src/squashfs/squashfs-tools
# make
# cp mksquashfs /usr/sbin/
|
Now configure you kernel, i'm sure i know how to compile it. Please follow these suggestions:
Try to compile everything built-in, probably you don't need to have modules on your embedded
Compile exactly what you need, to save space
Take care about the CPU type, the network card chipset, etc...
Use the menuconfig target to enter into the menu:
# make menuconfig |
When i've finished to configure your kernel (don't forget the squashfs support!) let's save the configuration coping the configuration file into a backup directory:
# cp .config /root/dot-config-linux-kernel-x.y.z.t-BACKUP |
Compile the kernel, then install it on /embedded_rootfs/boot/:
# make # ROOT=/embedded_rootfs make modules_install # cp /usr/src/linux/arch/i386/boot/bzImage /embedded_rootfs/boot/linux-x.y.z.t |
Edit the /embedded_rootfs/etc/lilo.conf to configure the boot loader:
# change hda with you drive boot = /dev/hda vga = normal image = /boot/linux-x.y.z.t root = /dev/hdaX # where X is you root partition # leave X now, you will change this later label = embedded |