You are not logged in.

#1 2013-09-19 21:04:16

labotsirc
Member
Registered: 2013-08-21
Posts: 108

[SOLVED] Using Torvalds kernel, compiles but does not boot

Hello,

I am trying to use Linus Torvalds kernel. It compiles but i cannot make it to run.
This is what i am doing:

1) I downloaded the sources from git repository

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

2) Then i used the default config

make menuconfig

Saved it as .config

3) Compile kernel and modules

make
make modules
make modules_install
sudo make install

At the end i get an error related to LILO not being found but it seems that is not a problem if you run

grub-mkconfig -o /boot/efi/EFI/grub/grub.cfg

I only get a vmlinuz file with no initframs file. My problem is that when i try to boot up that ketnel, i get errors and it fails.
What is the correct way to do this?

I was following this tutoria by the way:
http://www.thegeekstuff.com/2013/06/com … ux-kernel/

Last edited by labotsirc (2013-09-20 02:23:06)

Offline

#2 2013-09-19 21:08:21

Xabre
Member
From: Serbia
Registered: 2009-03-19
Posts: 749

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

https://wiki.archlinux.org/index.php/Ke … ild_System

Please read that carefully and use it.

Offline

#3 2013-09-19 21:10:23

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

Xabre wrote:

https://wiki.archlinux.org/index.php/Ke … ild_System

Please read that carefully and use it.

Hello Xabre,

I do not have problem when using ABS. But for this case i need to build Linus Torvalds kernel from scratch because my final goal of why i am building a kernel did not work under ABS for some reason.
Just for context, i am trying to fix a hardware problem. When patchin the ABS kernel, it did not work, but i have been told that it will work if i patch Torvalds kernel .

Last edited by labotsirc (2013-09-19 21:13:01)

Offline

#4 2013-09-19 21:11:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

I think https://wiki.archlinux.org/index.php/Ke … raditional is more appropriate.
ABS is for Arch packages.

Offline

#5 2013-09-19 21:14:55

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

karol wrote:

I think https://wiki.archlinux.org/index.php/Ke … raditional is more appropriate.
ABS is for Arch packages.

Thanks i will read this. At first glance i was missing some commands.

Offline

#6 2013-09-19 21:26:44

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

If you are going to use a custom kernel without an initrd, you must compile in all of the options you need on your system in order to boot.  These cannot be modules, they must be compiled in.

The default config is not going to cut it.  You might look at this site for suggestions for a starting configuration for your system.  The guy who runs that site is very active on the Gentoo boards.

Alternatively, start with the Arch configuration.  When the Arch kernel is running, you can obtain the configuration that was used for that kernel ar /proc/config.gz.  Copy that  "file" to your build directory and unpack it.  Then, look at the output of lsmod to see which modules you need on your hardware for the Arch kernel.  Then, edit the configuration (either directly, or using make menuconfig) and ensure that all of the modules (M) in use by the kernel are changed to enabled (Y) in the configuration.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2013-09-19 21:47:51

haagch
Member
Registered: 2013-08-17
Posts: 209

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

labotsirc wrote:

I do not have problem when using ABS. But for this case i need to build Linus Torvalds kernel from scratch because my final goal of why i am building a kernel did not work under ABS for some reason.
Just for context, i am trying to fix a hardware problem. When patchin the ABS kernel, it did not work, but i have been told that it will work if i patch Torvalds kernel .

I'm a fan of building archlinux packages for everything so I wonder why nobody else has suggested it: linux-git from AUR (https://wiki.archlinux.org/index.php/AUR): https://aur.archlinux.org/packages/linux-git/
It uses git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git as source already and the PKGBUILD is very, very well commented and even explains how it applies patches.

Offline

#8 2013-09-19 21:51:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

haagch wrote:

I'm a fan of building archlinux packages for everything so I wonder why nobody else has suggested it: linux-git from AUR

I was about to post this, but https://wiki.archlinux.org/index.php/Ke … R_packages took a bit too long to read ;P

Offline

#9 2013-09-19 22:35:50

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

The linux-git package from the AUR builds from Linus' git tree.  That is what I have been using (a bit modified).  It seems to work pretty well.

It seems as though you have just happened to choose a time to use Linus' git kernel when it is typically not recommended to do so unless you really know what you are doing.  Typically from the merge window and rc1 through about rc3, things are a little shaky.  I have had the kernel unable to boot for me on several occasions during this time.  In fact right now, rc1 is causing me some real issues with btrfs, so I have had to revert back the the Arch [testing] kernel for the time being (which I guess is the [core] kernel now).

Maybe get your build method down, and then try again every so often to see if things improve.  There are numerous changes merged to this branch everyday (seven days a week), so improvments and stability/bug fixes are constant.

Offline

#10 2013-09-20 01:42:21

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

thanks for the exelent advices guys.

In the end, what is happening is that in the very beginning i first was trying to modify the kernel source file 'drivers/hid/usbhid/hid-core.c' using the PKGBUILD type from arch ABS which is very nice. Then i did "makepkg -e" to build the kernel with my change considered....supposedly, but in the end the change did not occur (because my hardware problem was still there). At that time i was usin 3.9.X i think. My knowledge on kernel is very limited, i was not sure if maybe a patch was doing a final pass to the file, reverting it to as it was originally. 

This was the reason i moved to traditional compilation. My first attempt with default menuconfig has not booted.... Some error of being unable to find the partition ID. Instead of booting correctly, it booted into the basic recovery mode as root, but the hardware
problem was solved which is fantastic (the problem is related to the keyboard, you can realize if its fixed or not just by writing commands). I am assuming that the recovery boot even when it failed to boot correctly, is using the usbhid module i modified, is that right?

Now i am doing my second attemp using ewaller' advice; use the config from /proc/config.gz as indicated in the wiki too, hope this time full correct boot works

Edit: using the config file from my actual kernel fixed the boot problem. Thanks everyone. I will mark this thread as solved.

Last edited by labotsirc (2013-09-20 02:22:44)

Offline

#11 2013-09-20 15:15:55

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

I just want to add that in the end i could not use arch-linux default .config file because it wipes out the extra line i added into drivers/hid/usbhid/hid-core.c and the keyboards works bad again.
Instead, i had to use the default settings from "make menuconfig" and add a couple of modules for efectively booting up the kernel and the keyboard problem was fixed.

However, i have no internet!!, and probably many other things are missing..i will probably realize of them as i keep using it. Weird for me since i was using the default config plus 3 more options related to mounting devices.
I ask just in case, does anyone know what config option arch-linux uses that my change is wiped out? Would be great to still use that config file just removing the conflicting option and keeping the rest.

Last edited by labotsirc (2013-09-20 15:17:20)

Offline

#12 2013-09-20 17:44:46

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

It seems as though you are using makepkg wrong then.  If you want to be making modifications to the actual source before compilation, you have a couple options. 

The first option is to do things the manual way.  That is, use 'makepkg -o' to have the source downloaded and unpacked into src/.  Then navigate to src/linux-3.11/drivers/hid/usbhid/hid-core.c and make your modifcations.  Then use 'makepkg -e' to build the source using the existing files in src/.

Otherwise (and this is what i would do), make a copy of the file you are trying to modify (ie. hid-core.c.orig).  Then make your modifications to hid-core.c.  But before just building it like the last option, use diff to make a patch.  Then include the patch in the sources array of the PKGBUILD and add a line (and maybe a comment) to apply the patch in the build() function.  Of course, at this point it won't pass the checksums, so use updpkgsums to have that checksum for your patch included in the PKGBUILD (this is safe because the rest of the checksums have already been verified when you used 'makepkg -o' to modify the source and make your patch, so the only change will be the inclusion of your new patch).  Now you can simply run makepkg as you normally would in order to have the kernel built with the default Arch config and the minor modifcations you have made to the source.

Of course, continuing on your current path could actually teach you quite a bit about kernel compilation and whatnot.  Jasonwryan has a nice blog post about how he set up the building of his own kernels.  He uses graysky's modprobe_db in combination with 'make localmodconfig' to ensure that he creates a kernel with everything he needs.

Offline

#13 2013-09-20 18:18:04

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

It seems as though you are using makepkg wrong then.  If you want to be making modifications to the actual source before compilation, you have a couple options. 
The first option is to do things the manual way.  That is, use 'makepkg -o' to have the source downloaded and unpacked into src/.  Then navigate to src/linux-3.11/drivers/hid/usbhid/hid-core.c and make your modifcations.  Then use 'makepkg -e' to build the source using the existing files in src/.

Hello WonderWoofy. Indeed, this was what i was doing at the very beginning, tried about 5 times and always the same. Something not trivial (for me at least) occurs because when the kernel is building after 'makepkg -e' i look into the source file and it still has the modified line. However, when booting that kernel, it works as if the line never made effect.

I did research on this, and thought a way of discarding if makepkg is the responsable for this or not:
Build the kernel with my modification and use my actual ARCH config for building

~$ zcat /proc/config.bz > .config

If the keyboard problem still persists, then the problem comes from the configuration...specifically the modules chosen by ARCH, and not from PKGBUILD or makepkg. This is exactly what happened and what i mentioned in my last post. It seems that using or not using makepkg is not making any difference. But using the config file or not using it does, because when i used a basic default .config file my keyboard fix did work.
At this point is when i thought how could i find that specific '.config' option from ARCH that is making my fix not do any effect at all to the keyboard. That way i would not have to make a config file from scratch but instead use the ARCH one with the one module or option removed.

WonderWoofy wrote:

Otherwise (and this is what i would do), make a copy of the file you are trying to modify (ie. hid-core.c.orig).  Then make your modifications to hid-core.c.  But before just building it like the last option, use diff to make a patch.  Then include the patch in the sources array of the PKGBUILD and add a line (and maybe a comment) to apply the patch in the build() function.  Of course, at this point it won't pass the checksums, so use updpkgsums to have that checksum for your patch included in the PKGBUILD (this is safe because the rest of the checksums have already been verified when you used 'makepkg -o' to modify the source and make your patch, so the only change will be the inclusion of your new patch).  Now you can simply run makepkg as you normally would in order to have the kernel built with the default Arch config and the minor modifcations you have made to the source.

Never tried, will do just in case (but it seems that makepkg or PKGBUILD are not the problem, as explained before).

WonderWoofy wrote:

Of course, continuing on your current path could actually teach you quite a bit about kernel compilation and whatnot.  Jasonwryan has a nice blog post about how he set up the building of his own kernels.  He uses graysky's modprobe_db in combination with 'make localmodconfig' to ensure that he creates a kernel with everything he needs.

Thanks, will take a look

Last edited by labotsirc (2013-09-20 18:35:54)

Offline

#14 2013-09-20 18:31:21

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

Ah, I now do see that you mentioned earlier that you used 'makepkg -e'.  This *should* use the existing sources, and this is something I have used before to build my linux-git package to occasionally test small patches for btrfs fixes, and it seemed to work.  But when I did find something that would indeed work to my satisfaction, I would simply make a patch and then include it in the PKGBUILD (actually the linux-git PKGBUILD has a nice little feature that will simply apply any patches that you drop into a patches directory without having the modify the PKGBUILD or add them to the sources array).

You can also get the config from ABS as well.  I have found that often as we approach the end of a given kernel version, a config for the next one will appear in the Arch build sources.  So at around 3.10.6 or so, there was a config.3.11 in ABS.  This is nice if you are still thinking about running Linus' sources.

Offline

#15 2013-09-20 18:33:56

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Using Torvalds kernel, compiles but does not boot

WonderWoofy wrote:

Ah, I now do see that you mentioned earlier that you used 'makepkg -e'.  This *should* use the existing sources, and this is something I have used before to build my linux-git package to occasionally test small patches for btrfs fixes, and it seemed to work.  But when I did find something that would indeed work to my satisfaction, I would simply make a patch and then include it in the PKGBUILD (actually the linux-git PKGBUILD has a nice little feature that will simply apply any patches that you drop into a patches directory without having the modify the PKGBUILD or add them to the sources array).

You can also get the config from ABS as well.  I have found that often as we approach the end of a given kernel version, a config for the next one will appear in the Arch build sources.  So at around 3.10.6 or so, there was a config.3.11 in ABS.  This is nice if you are still thinking about running Linus' sources.

Thanks WonderWoofy. I have updated my last post explaining better the situation. Meanwhile will keep testing things and your suggestion.

Offline

Board footer

Powered by FluxBB