-   Linux - General (
-   -   Compilation of kernel from source code: Running into mess. (

annim 04-30-2013 02:38 PM

Compilation of kernel from source code: Running into mess.

i am a student, new to linux kernel compiling, starting from scratch. I hope this is the correct place to put such kind of questions.

What i am trying to do is:
1.Compiling Linux kernel From source code.
---this in turn compiles the kernel and also the initramfs file.
2. Compile modules.
---but want to put in other drive.
3.Hence a newly installed linux OS, a new entry in boot loader.
4.All above shall be carried out in Debian based Ubuntu Distro.

Putting in a comprehensive manner:

i want to compile the kernel from its source and want to put that in other drive
and also want to put the initramfs along with the /etc/modules filees to other drive
hences forming a whole new OS standing seperated from the HOST OS.

Clarifying the above by providing an example:
--Host OS: Ubuntu
--------------------------/ (Only root and everything mounted with repstec to /)
|---Kernel is been compiled on this OS.
|---Now put the kernel image, initramfs, modules folder to
-----------------/(pre-ready root mountable)

Now add new entry to Booot loader for this new OS

--How to put /etc/modules to /dev/sda2 while making modules_install
--How to install grub in /dev/sda2 , so i will be erasing /dev/sda1 althou the grub will be over /dev/sda .
--Wanted to make a Debian based system(kernel).

What i have tried-
---- Compiling linux kernel
-----------make menuconfig
-----------make(got error: out of space:How much HDDspace required? am i suppose to provide more than 10 GB?)
-----------make modules(not performed due to above error)
-----------make modules_install ( this is the point where i want to get modules to /dev/sda2)(am i correct?).
-----------(manually cp the generated kernel image to /dev/sda2
-----------(manually copying initrd files to /dev/sda2)(am i correct?).

is this correct---?
-Put kernel image file in /dev/sda2/boot/
-Put initrd file in /dev/sda2/boot/

----Lastly am i missing something..?
----Whats files is and what for it is?

i hope i have presented a fair scenario of what i am trying to do !!!

Links, descriptions, books, refferences, further readings, instructions are appriciated!!!

cyent 04-30-2013 04:22 PM

An easier / better way may be to use a Ubuntu Kernel source package and use that. It is essentially a scripted "build and package a kernel for distribution".

smedley76 04-30-2013 11:37 PM

i am sure you will find compilng the kernel much easier by following this nifty guide

sundialsvcs 05-04-2013 09:28 AM

The word "shall" in the OP strongly implies that this is a homework assignment. :tisk:

In any case, when compiling a kernel, I first of all, don't attempt to do that on any system whose kernel is designed to be maintained through the use of packages! Responsibility for maintaining the packages (source and binary) rests with the "distro" publisher, and I don't assume that the distributed source-code as installed on my system 100%-matches what the binaries (which work...!) contain.

When compiling a kernel, a hidden file called .config drives the process, and I always make multiple named backup copies of that file, placing them in a safe subdirectory within /root and write-protecting each one. I keep a distinct copy of every version that there has ever been of this file. (I also keep kernel-images and boot-loader configuration files there. All the files are not-hidden.

Finally, I keep a running log. "Captain's Log, Stardate 1234.5." What, exactly, did I do today. Why did I do it? What, exactly, messages appeared? And so on. A current copy of the log is copied into that same dated subdirectory, and write-protected along with all the other files. ("Trust the computer's RAM chips, but don't trust your memory." Especially as you get ... :hattip: well, never mind!)

When compiling, I always recompile everything, every time, in a process that goes something like this:
  1. mv .config dont_lose_me
  2. make distclean
  3. mv dont_lose_me .config
  4. make ... make modules ... make (what have you)
  5. make install
  6. manually examine the "/boot" directory and boot-loader configuration files.
Steps 1-3 are the most important: after carefully saving the ".config" that would otherwise be destroyed :eek: in step 2, I cause everything to be reset to a "nothing has been compiled" state, then put the config file back. The remaining steps are then obliged to recompile every part of the system, including every module. In this way, it is very unlikely that I will "mix apples with oranges."

All times are GMT -5. The time now is 08:44 PM.