Compiling new linux Kernel

Posted on 2008-11-10
Last Modified: 2013-12-16
I have a linux system which was installed on a very small hard disk of the size 2GB , meant to be embeded system , the kernel version is 2.6.10 and was compiled by the system supplier to support very limited set of drivers , also almost all development utilities are removed from the file system , i managed to move the system to another PC with larger hard disk by taking an image with 'dd' and restore it , however i faced the problem that kernel cant detect the network card and a lot of other system prepherals m my question is :
1- How to increase the linux root file system size
2- How to Compile and install a new kernel to detect all hardware , noting that the system is a minimized version which doesnt have gcc and other things.
3- Note that the kernel .config file doesnt exist , means also i dont know which options were configured in the exisiting kernel , how can i detect which options are enabled in it.
Question by:esam9831
    LVL 8

    Accepted Solution

    1) how to increase the linux root file system size:

    check if you have sufficient available unallocated disk space you can use temporarily while you do this
    if not, add a second disk, just for the purposes of the data migration.
    boot the box with a rescue disk, like knoppix, or if you prefer your distro specific livecd.
    create a new partition to copy your /boot data, and if you are picky about WHERE on the disks your partitions are, you might not have room to enlarge your current /boot if there are other partitions after /boot make partions in the extra space and copy that data to the newly created partitions.

    check to make sure the copies copied everything, like an md5 checksum or something.

    once happy, delete the original /boot partitions, and any others you need to delete, and recreate them with the right sizes.

    copy the recued data BACK to the new partitions and then boot to make sure everythings works, if it doesnt reboot with the livecd and edit /etc/fstab and your boot loader configuration to make sure you are booting from the correct drive.

    once the system boot correctly and you are happy that the copy restore operation worked like you wanted, you can delete the temp partions and remove the extra drive if you installed one, and if  you want put the empty space in service somewhere.

    2) without a compiler, you cant compile and install a new kernel.  so install the needed build tools gcc, make, autoconf, etc.

    then you can compile a kernel.

    3) kernel modules are stored seperatly and you can do a "lsmod" and figureout which modules are installed, you can also do a dir listing on the modules directory and get a list of all kernel options that were complied as Modules.

    Maybe someone else can help you to dianose a running kernel, to see what options were built into a running kernel as static build options.

    LVL 2

    Assisted Solution

    2) How to Compile and install a new kernel to detectall hardware , noting that the system is a minimized version whichdoesnt have gcc and other things.

    You can compile kernel on another system and then copy to the needed place. Try also using kernel from similar distribution (maybe supplier used some common distro) it might boot too.

    3) Note that the kernel .config file doesnt exist ,means also i dont know which options were configured in the exisitingkernel , how can i detect which options are enabled in it.

    Sometimes you can get kernel config by simply executing this command:
    cat /proc/config

    But it might not be configured in kernel, especially if developer where trying to minimize as possible.

    Author Comment

    i found the kernel config file under /proc , it is compressed , this solves part of the problem .
    1- which tools are required to recompile the kernel , i need explicit list ?
    2- How to install them noting that the system is having the bare minimum binaries

    I appreciate the detailed steps rather than general tips and guidance
    LVL 2

    Expert Comment

    Just as a beginning what architecture is the embedded system (x86, x86_64 or any other)? What is the kernel version?

    Author Comment

    It is x86 , the kernel version is 2.6.10
    LVL 7

    Assisted Solution

    As for resizing, since you've already created a partition table using dd, your easiest solution will probably be to use 'resize2fs' or similar.  Booting from a rescue CD of some type will likely simplify this.

    As for the kernel, if a custom compile is needed, I would compile this on another system, and copy it over once you're ready.

    While I appreciate your goal, and wanting step-by-step instructions, doing it on the local system would be a hugely time-intensive task, unless the distro is based on something "standard" (e.g. Red Hat), for which you can readily install tools like gcc, kgcc, and a lot of libraries.

    Your best bet with the kernel is going to be to use a stock RHEL/Cent/etc. kernel from another system; copy over the kernel and initrd files, edit the lilo.conf or grub.conf to use these (modify the existing lines to match the new location).  If grub, it will work automatically, if lilo, reinstall lilo by running `/sbin/lilo`.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
    Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now