LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-18-2021, 06:46 AM   #1
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Rep: Reputation: 20
Grub2 with generic kernel


The documentation about using the generic Kernel assumes that one uses lilo, but I'm using Grub2. I created inird.gz and when I select the generic Kernel in the Grub menu it works fine. But by default it still boots the huge kernel. So what should I do to boot the generic Kernel by default?
 
Old 02-18-2021, 06:55 AM   #2
teoberi
Member
 
Registered: Jan 2018
Location: Romania
Distribution: Slackware64-current (servers)/Windows 11/Ubuntu (workstations)
Posts: 614

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
/etc/default/grub
Options:
Code:
GRUB_DEFAULT
Code:
GRUB_DISABLE_RECOVERY="true"
and
Code:
GRUB_DISABLE_SUBMENU=y
/etc/grub.d/10_linux
the line:
Quote:
for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
allows you to configure menu lines for the desired kernels.
In order not to load initrd to the huge kernel for the time being, the solution found is to comment the line in the /boot/grub/grub.cfg file.

Last edited by teoberi; 02-18-2021 at 07:37 AM.
 
Old 02-18-2021, 06:57 AM   #3
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
For that I stole the generic kernel entry from /boot/grub/grub.cfg and put it in /etc/grub.d/06_custom

I'm sure yours will be different, but just for illustration, my 06_custom file:
Code:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry 'Slackware-14.2+ GNU/Linux (generic)' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd1,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  <drive-uuid>
    else
        search --no-floppy --fs-uuid --set=root <drive-uuid>
    fi
    echo    'Loading Linux ...'
    linux   /vmlinuz-generic root=/dev/mapper/cryptvg-root ro
    echo    'Loading initial ramdisk ...'
    initrd  /initrd.gz
}
After that, a `grub-mkconfig -o /boot/grub/grub.cfg` should generate the right file.
 
1 members found this post helpful.
Old 02-18-2021, 08:07 AM   #4
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by teoberi View Post
/etc/default/grub
Options:
Code:
GRUB_DEFAULT
Code:
GRUB_DISABLE_RECOVERY="true"
and
Code:
GRUB_DISABLE_SUBMENU=y
/etc/grub.d/10_linux
the line:

allows you to configure menu lines for the desired kernels.
In order not to load initrd to the huge kernel for the time being, the solution found is to comment the line in the /boot/grub/grub.cfg file.
Thanks for your reply! But I do not understand what I should do. If never done any configuration on grub, so how should I configure this line?
Also you suggested to configure /boot/grub/grub.cfg but this files says that it shouldn't be modified so I'm not sure if this is the correct approach.
 
Old 02-18-2021, 08:09 AM   #5
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by drgibbon View Post
For that I stole the generic kernel entry from /boot/grub/grub.cfg and put it in /etc/grub.d/06_custom

I'm sure yours will be different, but just for illustration, my 06_custom file:
Code:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry 'Slackware-14.2+ GNU/Linux (generic)' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd1,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  <drive-uuid>
    else
        search --no-floppy --fs-uuid --set=root <drive-uuid>
    fi
    echo    'Loading Linux ...'
    linux   /vmlinuz-generic root=/dev/mapper/cryptvg-root ro
    echo    'Loading initial ramdisk ...'
    initrd  /initrd.gz
}
After that, a `grub-mkconfig -o /boot/grub/grub.cfg` should generate the right file.
There is no 06_custom file. I have a 40_custom and a 41_custom. So which one should I modify?
 
Old 02-18-2021, 08:34 AM   #6
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Quote:
Originally Posted by M0M0 View Post
There is no 06_custom file. I have a 40_custom and a 41_custom. So which one should I modify?
Neither, you create a new custom file, but make it a number lower than the 10_linux (which detects Linux kernels). That way when you run `grub-mkconfig -o /boot/grub/grub.cfg` the 06_custom stuff ("06" is not forced, just <10) will come before the auto-detected 10_linux stuff. You set your custom file to pick up your generic kernel only, and then grub will always boot that one first.

No doubt there's other ways to do it, but that's how I've got my system set up. The benefit is that after kernel upgrades it's enough to:

# generate new initrd if necessary (I use `mkinitrd -F`)
# grub-mkconfig -o /boot/grub/grub.cfg

and you're done (no need to edit grub.cfg or anything like that).
 
2 members found this post helpful.
Old 02-18-2021, 10:30 AM   #7
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,371

Rep: Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593
Another option If your not multi-booting with other linux distros is to edit the first menu entry in /boot/grub/grub.cfg and don’t never run grub-mkconfig again.
 
1 members found this post helpful.
Old 02-18-2021, 11:28 AM   #8
teoberi
Member
 
Registered: Jan 2018
Location: Romania
Distribution: Slackware64-current (servers)/Windows 11/Ubuntu (workstations)
Posts: 614

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by M0M0 View Post
Thanks for your reply! But I do not understand what I should do. If never done any configuration on grub, so how should I configure this line?
Also you suggested to configure /boot/grub/grub.cfg but this files says that it shouldn't be modified so I'm not sure if this is the correct approach.

Code:
        for i in /boot/vmlinuz /boot/vmlinuz-generic ; do
This way you will only have the menu lines for vmlinuz and vmlinuz-generic.
GRUB_DISABLE_SUBMENU and GRUB_DISABLE_RECOVERY from /etc/default/grub (the GRUB configuration file) are easy to understand.

GRUB_DEFAULT=0 defaults to first menu option (vmlinuz)
GRUB_DEFAULT=1 defaults to the second menu option (vmlinuz-generic)
In this way it is not necessary to run the command:
Code:
grub-mkconfig -o /boot/grub/grub.cfg
when updating the kernel but it is still necessary to create initrd.
If you can, try in a virtual machine eg. VirtualBox.

Last edited by teoberi; 02-18-2021 at 11:31 AM.
 
Old 02-18-2021, 11:47 AM   #9
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Quote:
So what should I do to boot the generic Kernel by default?
That is because by default /boot/vmlinuz is sym linked to the huge kernel.

The problem can be avoided by not using the sym link vmlinuz in grub.cfg and instead use the full file name /boot/vmlinuz-generic-4.4.240.
 
Old 02-18-2021, 11:52 AM   #10
Hangaber
Member
 
Registered: Sep 2004
Location: USA
Distribution: Slackware
Posts: 163

Rep: Reputation: 51
Possibly just a typo, but if your initrd file is called "inird", change it to initrd.gz or something that the "11_linux_slackcustom" looks for (lines 194 to 204).

The exact filename of the generic kernel is important too. When I run grub-mkconfig, the generic kernel is added first (with the initrd) and so that boots by default.

You can test what order the line teoberi posted is finding files by running something like this one-liner;
Code:
for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-*; do echo $i; done
 
Old 02-19-2021, 01:33 AM   #11
aikempshall
Member
 
Registered: Nov 2003
Location: Bristol, Britain
Distribution: Slackware
Posts: 902

Rep: Reputation: 153Reputation: 153
Quote:
Originally Posted by M0M0 View Post
The documentation about using the generic Kernel assumes that one uses lilo, but I'm using Grub2. I created inird.gz and when I select the generic Kernel in the Grub menu it works fine. But by default it still boots the huge kernel. So what should I do to boot the generic Kernel by default?
Once I've convinced myself that the generic kernel gives me all I need, I do this. Delete kernel-huge via slackpkg, then recreate initrd and grub.cfg.
 
Old 02-19-2021, 02:25 AM   #12
teoberi
Member
 
Registered: Jan 2018
Location: Romania
Distribution: Slackware64-current (servers)/Windows 11/Ubuntu (workstations)
Posts: 614

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Kernel-huge without loading microcode for the processor and without initrd can be considered as a backup solution in case of problems related to loading microcode or initrd.
I leave it as the first option in the GRUB menu without any changes.
There is also the alternative with Slackware DVD + chroot but it is a bit more work!

Last edited by teoberi; 02-19-2021 at 02:30 AM.
 
Old 02-19-2021, 02:30 AM   #13
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by upnort View Post
That is because by default /boot/vmlinuz is sym linked to the huge kernel.
So could I just symlink vmlinuz to the generic kernel? That sounds easiest and least scary to me
 
Old 02-19-2021, 02:32 AM   #14
teoberi
Member
 
Registered: Jan 2018
Location: Romania
Distribution: Slackware64-current (servers)/Windows 11/Ubuntu (workstations)
Posts: 614

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by M0M0 View Post
So could I just symlink vmlinuz to the generic kernel? That sounds easiest and least scary to me
Not!
If you want GRUB, document yourself first, eventually test it in a virtual machine (VirtualBox) and it won't scare you so much!

Last edited by teoberi; 02-19-2021 at 02:34 AM.
 
Old 02-19-2021, 02:32 AM   #15
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by aikempshall View Post
Once I've convinced myself that the generic kernel gives me all I need, I do this. Delete kernel-huge via slackpkg, then recreate initrd and grub.cfg.
Thanks, but I would like to keep the huge kernel for a reason: If I move the boot drive to another machine with different hardware I need the huge kernel, right? This is something I need to do some times.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem upgrading to new kernel 5.3.0-45-generic from 4.18.0-25-generic fgonza1971 Linux - Laptop and Netbook 1 04-01-2020 02:54 PM
[SOLVED] [slackware novice] setting generic kernel for grub2 gnus Slackware 8 07-05-2016 09:04 AM
[SOLVED] setting up initrd / generic kernel in Grub2...can't load generic Ubunoob001 Slackware 12 03-20-2015 07:32 AM
kernel-generic and kernel-generic-smp ?? liuyug Slackware - Installation 5 06-01-2014 07:01 PM
[SOLVED] Can't Get GRUB2 To Boot Slack Generic Kernel Sumguy Slackware 22 05-15-2014 03:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration