Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Best Way to have Grub2 deal with multiple kernel versions?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
cayenne
l33t
l33t


Joined: 17 Oct 2002
Posts: 945
Location: New Orleans

PostPosted: Thu Apr 23, 2015 3:27 pm    Post subject: Best Way to have Grub2 deal with multiple kernel versions? Reply with quote

Hi all,

It has been a LOOOONG time since I last tried a Gentoo install and much has changed.

Grub2 is new to me...

I've done my initial install. I have the system (a dell power edge 2850) running.

I'm now trying to install Xorg on it with a radeon 7000.

I've been going through the docs and I think I have the kernel config I want....HOWEVER, just to be safe I want to keep my current kernel as an option to boot into if the new one doesn't work.

I ran into the new system awhile ago when I had to make 2 attempts to get a working kernel...that if I did a second make && make modules_install and make install

In the /boot directory it had the former kernel with .old appended.

I had gone in, removed all (for house cleaning) from /boot and did the make install and grub config (the auto thing from the install manual) and it put that kernel in there.

However, now, I'm about to compile a kernel I don't know if will work...and wondering the best way to try to name these kernels (working, test1, etc) and put them into /boot and have grub see them and present them by names to choose on boot....

I'm guessing there may be some docs around I haven't found yet...so, links to those and some good advice on how to manage multiple kernels would be greatly appreciated!!!

At the very least, I just want to make sure I have a working one to fall back on at all times....
:)

TIA,

Cayenne
_________________
Light travels faster than sound. This is why some people appear bright until you hear them speak.........
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1908
Location: Switzerland (Romandie)

PostPosted: Thu Apr 23, 2015 9:24 pm    Post subject: Reply with quote

When configuring the kernel with "make menuconfig" or whatever you use, you can put an extra string in "General setup -> Local version - append version information to the version string", you can add an extra string to the version string. This is needed if you want to do more than one kernel from the same kernel sources.

As example, if I put "_2" here, I will get something like
Code:
# uname -r
3.18.0-gentoo_2


This is needed because "make module_install" and the kernel will use it to determine the modules location, in that case "/lib/modules/4.0.0-gentoo_2". I have other kernels with "_3D" as extra string, it show me it is for use with the closed source ATI driver.
_________________
"Confirm You are a robot." - the singularity
Back to top
View user's profile Send private message
wjn
n00b
n00b


Joined: 18 Apr 2015
Posts: 14
Location: JP

PostPosted: Thu Apr 23, 2015 9:31 pm    Post subject: Reply with quote

Hello,

Have you try editing "EXTRAVERSION" in Makefile? (/usr/src/linux/Makefile)

Or you can copy your kernel binary file to /boot instead of "make install". The filename can be as you like.
Back to top
View user's profile Send private message
cayenne
l33t
l33t


Joined: 17 Oct 2002
Posts: 945
Location: New Orleans

PostPosted: Fri Apr 24, 2015 12:00 am    Post subject: Hmm. Reply with quote

wjn wrote:
Hello,

Have you try editing "EXTRAVERSION" in Makefile? (/usr/src/linux/Makefile)

Or you can copy your kernel binary file to /boot instead of "make install". The filename can be as you like.


Thanks let me look into that!!

I thought I'd read that when you run:

grub2-mkconfig -o /boot/grub/grub.cfg

That your kernel naming had to be of a specific format, etc....?

Let me look up EXTRAVERSION and see what that does.

Just as FYI...I went ahead and did a new kernel, did the make install. It renamed the previous kernel there to .old....but and the grub mkconf seemed to see both of them.
However, when I rebooted....the Grub menu didn't give me multple choices of kernel....just the default one and the 'save' one..etc....

I didn't see the .old one as an offering, even though it said it found it....

So much to learn...

cayenne
_________________
Light travels faster than sound. This is why some people appear bright until you hear them speak.........
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1908
Location: Switzerland (Romandie)

PostPosted: Fri Apr 24, 2015 8:14 am    Post subject: Reply with quote

wjn wrote:
Hello,

Have you try editing "EXTRAVERSION" in Makefile? (/usr/src/linux/Makefile)


That do the same than what I wrote in my first post. Separated kernel must have separated paths for their modules, or they will collide.

cayenne wrote:
That your kernel naming had to be of a specific format, etc....?

Use plain ASCII and don't use the special characters like \ or ~.

cayenne wrote:
At the very least, I just want to make sure I have a working one to fall back on at all times....

GNU/linux is a fast moving target, and I would not say "at all times". After some time, an old kernel will boot, but some parts of the system will stop to work, which imply that, depending of which part is failing to work, the system will be more or less usable. Each kernel introduce new functions, and with the kernel, you have the kernel headers (istalled as a separated package by portage). These headers are used by glibc to know what functions are existing and can be used. So, when you update world, glibc is updated. When a new function is called by a software and is not existing in the kernel, anything can append.

My boot partition is very small, I can only have 4 kernels in it, and before to install a new one, I remove the oldest one. That way, I am forced to only have 2 or 3 working kernels and 1 or 2 test kernels.
_________________
"Confirm You are a robot." - the singularity
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3999

PostPosted: Fri Apr 24, 2015 11:45 am    Post subject: Reply with quote

Hi,
Here we have multiple kernels versions with multiples configs such as:
Latest stable.
Any Latest unstable version above the previous.

All are generated in 2 flavors: Classic & Xen.

As of today that leads to:
3.18.11 stable x 2
3.19.5 unstable x 2
4.0.0 unstable x 2

In order to prevent from a total mess in .config files & generation as well as minimal recompile duration:
Original kernel directory remains untouched.
DIY script with 3 arguments such as:
new_kernel_version (ie 4.0.0-gentoo)
flavoring string (ie VGA0-KMS)
source kernel_version (ie 3.19.5-gentoo)

The script duplicates new kernel untouched directory to a renamed one new_kernel_version + flavoring string.
It appends flavoring string to EXTRAVERSION variable in Makefile of the duplicated kernel.
It duplicates .config* files from the already existing source kernel version directory that is flavored the same.
Calls for make && make modules_install for the new kernel flavored directory.
Alternatively compiles out of kernel/tree kernel modules
Duplicates generated files to proper location when required (bzImage to /boot/kernel-flavored-name & .config @ /etc/default when XEN & out of the tree kernel modules (ie SD card + Bluetooth + Wifi thanks to realtek & mediatek :twisted:)
Calls for grub-mkconfig -o /boot/grub/grub.cfg

So I choosed to go for the Makefile EXTRAVERSION variable change that reflects the name of the flavored kernel directory.
uname -r display information accordingly.
/lib/modules contains as many directories as generated kernels.

Alternatively,
Seems like CONFIG_LOCALVERSION in kernel may also somehow fit.
Seems like kernel source replication is avoidable (that would save quite some storage space)
But when it comes to pointing at a specific .config when doing some emerge jobs that would check:warns against kernel configuration, I"m stuck.

For the record, something I don't do that would save some storage space is to unemerge gentoo-sources-X-X-X once all required new kernels have been generated. I hope to get to a leaner solution in the future.

Thks 4 your attention.


Last edited by CaptainBlood on Mon Apr 27, 2015 3:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1908
Location: Switzerland (Romandie)

PostPosted: Fri Apr 24, 2015 12:17 pm    Post subject: Reply with quote

CaptainBlood wrote:

Alternatively,
Seems like CONFIG_LOCALVERSION in kernel may also somehow fit.
Seems like kernel source replication is avoidable (that would save quite some storage space)
But when it comes to pointing at a specific .config when doing some emerge jobs that would check:warns against kernel configuration, I"m stuck.

To make multiple kernels from the same sources, I backup the .config, as example in /boot and rename it like config-${uname -r}, do "make mrproper" which clean the sources, restore the .config, "make oldconfig" and "make menuconfig". Of course, "emerge @module-rebuild" will work only with the current .config in the sources, but that's not an issue, it is just to run it before "make mrproper". If you want to run it against a precedent kernel, you can run "make mrproper", restore its .config, "make oldconfig" and "make module_prepare".
_________________
"Confirm You are a robot." - the singularity
Back to top
View user's profile Send private message
cayenne
l33t
l33t


Joined: 17 Oct 2002
Posts: 945
Location: New Orleans

PostPosted: Fri Apr 24, 2015 4:37 pm    Post subject: Wow Reply with quote

Wow...lots of good stuff here!!

Ok, thanks everyone...

Let me try to digest all this.

MUCH appreciated!!


cayenne
_________________
Light travels faster than sound. This is why some people appear bright until you hear them speak.........
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3942
Location: Hamburg

PostPosted: Fri Apr 24, 2015 4:50 pm    Post subject: Reply with quote

What's just a little bit annoying, is that 4.0.0-rcX would be listed before 4.0.0 so each time a new kernel is there I'd to tweak for a given time my work flow.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3999

PostPosted: Mon Apr 27, 2015 3:57 pm    Post subject: Reply with quote

Dominique_71 wrote:

To make multiple kernels from the same sources, I backup the .config, as example in /boot and rename it like config-${uname -r}, do "make mrproper" which clean the sources, restore the .config, "make oldconfig" and "make menuconfig". Of course, "emerge @module-rebuild" will work only with the current .config in the sources, but that's not an issue, it is just to run it before "make mrproper". If you want to run it against a precedent kernel, you can run "make mrproper", restore its .config, "make oldconfig" and "make module_prepare".


Sorry to ask, but AFAIU you are fully recompiling kernel at any .config swap/switch, aren't you?

Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum