Building Linux Kernel (linux-4.10.10.tar.xz) from source - linux

Can someone explain the process of building linux-4.10.10 from source for a beginner? From my research, the answer to my question theoretically lies in the $src/Documentation/kbuild directory, however, the kbuild.txt and kconfig.txt are kinda complicated to understand assuming these are actually the files containing the instructions I need to follow.
Basically, how is someone suppose to understand how to build a kernel that theoretically contains helpful documentation consisting of hundreds of lines of text and possible configuration options.

The README file in the root directory is definitely worth reading. You can copy an existing config from /boot or make menuconfig to start from scratch or modify the abovementioned existing config. Then make && sudo make modules_install && sudo make install and reboot. But some more in depth reading is indeed recommended.

Related

how to install software on linux without root permissions

I need some help to install the ABySS assembler on PuTTY (virtual Linux) without root permission (as it takes a long time going via IT department etc.).
To be honest I've no idea where to start from, so I'll be very appreciated for step-by-step guide if that is not too much to ask.
Thanks in advance.
If you are referring to the software here, then it should be sufficient to follow the instructions here. Specifically, you should take note of the part labelled To install ABySS in a specified directory:, and specify a directory in your home directory that you have write access to. For example, I might:
mkdir ~/abyss
./configure --prefix=$HOME/abyss
make
make install
Note that I have removed sudo from before make install, so that you are trying to run the installation as a user rather than root. make install will put the software wherever you specified with --prefix.
However, this all depends upon the source code for any libraries upon which ABySS depends existing on your system as well. I expect you will fail at the ./configure step because some library is missing. In this case download the source code for those libraries and tell configure where you have put them (in your home directory), following the example given for Boost on that same page.

prevent rpmbuild from reading ~/.rpmmacros

Is there a way to prevent the rpmbuild command from reading the ~/.rpmmacros file? I want to add rpmbuild to a Make target and want to get a consistent build under any user account, regardless of the options somebody might have personally set in the rpmmacros file in his home directory.
How can I do this? Or, is that actually a bad idea?
If you're looking to get the a consistent build then the rpmmacros is only one part of the problem. The build may still differ simply because it's running on a machine with different things installed. Use mock to get a truly consistent build environment.
Solved this now this by setting $HOME to an empty directory while running rpmbuild:
mkdir $MY_DIST_DIR/dummyhome
HOME=$MY_DIST_DIR/dummyhome/ rpmbuild ...
rm -r $MY_DIST_DIR/dummyhome

Must I compile all the kernel source code due to some modification to sched.c?

I'm studying the linux kernel. I have modified sched.c to specify my own scheduling policy. But it takes more than 50 minute to recompile into my custom kernel. Why does I have to compile untouched source code? Is there any way to compile only sched.c?
I type the following commands to recompile the kernel in the directory /usr/src/linux-version.
sudo make
sudo make modules-install
sudo make install
Thank you in advance.
The kernel makefiles are usually quite clever about not rebuilding unless it's really required.
Are you perhaps also modifying sched.h? I'd expect that file to be included all over the place, so rebuilds are likely. If you're only modifying sched.c it shouldn't be rebuilding everything.
PS: If you're interested in learing about advanced (GNU) make those makefiles are gems. There are a couple of really neat ideas in them.

Trying to find all the kernel modules needed for my machine using shell script

I'm developing kernel modules right now, and the build times are starting to get under my skin. As a side effect I'm taking way too many "coffee" breaks during builds.
So I was looking for a way to build only the stuffs I need for my platform. Chapter 7 and 8 of "linux kernel in a nutshell" gave a good detail of how to do that by hand. Its a good read : http://www.kroah.com/lkn/
But Although I understand the stuffs, this is still a lot of tweaks to make that work.
2.6.32 and later kernels added a new target make localmodconfig. which scans through lsmod and change the .config appropriately. So I thought I found my "automation". But this perl script has some problem too.
This thread describes the problems : https://bbs.archlinux.org/viewtopic.php?pid=845113
There was also a proposed solution which apparently worked for others , is to run the script directly instead of using make's target.
Although for me, make localmodconfig does not work at all. its because of the following :
make clean
make mrproper
cp /boo/config-'uname -r' .config
make localmodconfig
and it halts with
vboxguest config not found!!
nf_defrag_ipv6 config not found!!
vboxsf config not found!!
vboxvideo config not found!!
The thing is my kernel development environment is inside virtualbox. These vbox modules were installed when I chose to install "virtualbox guest addtion".
And the netfilter module might be a Distribution specific module(Lot of netfilter modules are not part of the mainline kernel, so its not a shock to me), which is not included in mainline kernel.
Now the workaround this obviously unloading these module and trying again. But I'm thinking if there is patch for the streamline_config.pl which will enable the user to exclude certain modules if s/he wants. Problem is I have zero knowledge about perl and I like it that way.
So my problems in nutshell
Patching streamline_config.pl so I can give a list of module name as argument which it will exclude from processing the config file.
The script is located at kernel.org
EDIT: Removed the stuff about perl script not running. As mugen kenichi pointed out (How dumb I can be?). But still make localmodconfig does not work because of not having some modules code under source tree. patching streamline_config.pl still valid requirement.
Anyone else trying to build a minimum kernel image also looking for reducing build time, should do the following:
1) copy distribution kernel config in your source tree. It can be done with either command given below:
$zcat /proc/config.gz > .config
or
$cp /boot/config-'uname -r' .config
2) Use localmodconfig target.
$make localmodconfig
It will use lsmod to find which modules are loaded at this moment. Then it will search through distribution's .config to enable them and disable others.
Its important to know that it does not always work flawlessly. So you should tweak your config further using make menuconfig. You will see some modules are still marked to be built which is in reality unnecessary for your system.
Sometimes out of tree modules may cause make localmodconfig to fail. If that's the case you can work around that issue in two ways :
a) unload the out of tree modules and try make localmodconfig again.
b) Run the perl script directly:
$chmod +x script/kconfig/streamline_config.pl
$perl script/kconfig/streamline_config.pl > .config
3) Install ccache[1]. It will improve your build time dramatically. It caches objects. So it will reduce subsequent builds.
Its possible that ccache is included in the distribution's repository so that you can install it through apt-get or yum. In CentOS its available in EPEL repo.[2]
4) Give as many cores as possible for the build job
$make -j8 CC="ccache gcc"
My results are :
real 3m10.871s
user 4m36.949s
sys 1m52.656s
[1] http://ccache.samba.org/
[2] http://fedoraproject.org/wiki/EPEL

Building rpm

Is there an easy procedure to build an RPM.If so Please explain or provide the link.........
My requirement is very simple ..
I have two other RPMs which should be combined into one single RPM....
Please explain the process....
Thanks in advance..........
Building an RPM itself is rather easy, you just need to run
rpmbuild -ba <mypackage.spec>
The more complex task is creating the .spec file, which controls how the rpm itself is built. A good explanation is the book Maximum RPM, which is available on the rpm homepage. Creating a .spec file is handled here. From my own experience building a .spec file is something that's not easy -- but not too complicated either unless you want to make special things. The standard ./configure && make && make install is usually not too complicated.
Not sure what the problem is; if you've already got two RPMs, why do you need to make them into 1 rpm? Why not just use a shell script to install them both at the same time?
The RPM command will take multiple arguments, so for example:
rpm -ivh one.rpm two.rpm three.rpm
Will install one, followed by two, followed by three.
Otherwise, from what I know, you're going to have to build the packages first, and then build them into an RPM, at which point you will have a custom RPM that will have to be manually updated every time one of the component packages changes. Yuck.
Basic guide for RPM creation is available at:
http://fedoraproject.org/wiki/How_to_create_an_RPM_package
A very good and complete guide for RPM creation (by Fedora community) is available at link: http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/
It is is wonderful.
BTW, for straight answer of your question, you might want to add two packages as a subpackage of another package. For that there are some specific entries in RPM spec file.
You need to create only one SPEC file for all three packages

Resources