Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Compiling new linux Kernel

Posted on 2008-11-10
Medium Priority
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

Accepted Solution

Rance_Hall earned 672 total points
ID: 22922925
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.


Assisted Solution

artms earned 664 total points
ID: 22924826
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

ID: 22929907
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

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

Author Comment

ID: 22936917
It is x86 , the kernel version is 2.6.10

Assisted Solution

macker- earned 664 total points
ID: 23001353
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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

579 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