LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   setting up initrd / generic kernel in Grub2...can't load generic (https://www.linuxquestions.org/questions/slackware-14/setting-up-initrd-generic-kernel-in-grub2-cant-load-generic-854190/)

Ubunoob001 01-04-2011 01:34 PM

setting up initrd / generic kernel in Grub2...can't load generic
 
So I am trying to figure out how to load the generic kernel in Grub2.

1. I have run the /usr/hare/mkinitrd/mkinitrd_command_generator.sh and ran the output:
Code:

/usr/share/mkinitrd/mkinitrd_command_generator.sh
#
# mkinitrd_command_generator.sh revision 1.40
#
# This script will now make a recommendation about the command to use
# in case you require an initrd image to boot a kernel that does not
# have support for your storage or root filesystem built in
# (such as the Slackware 'generic' kernels').
# A suitable 'mkinitrd' command will be:

mkinitrd -c -k 2.6.33.4-smp -f ext4 -r /dev/sda5 -m jbd2:mbcache:ext4 -o /boot/initrd.gz
root@laptop1:/home/user1# mkinitrd -c -k 2.6.33.4-smp -f ext4 -r /dev/sda5 -m jbd2:mbcache:ext4 -o /boot/initrd.gz
OK: /lib/modules/2.6.33.4-smp/kernel/fs/jbd2/jbd2.ko added.
OK: /lib/modules/2.6.33.4-smp/kernel/fs/mbcache.ko added.
OK: /lib/modules/2.6.33.4-smp/kernel/fs/ext4/ext4.ko added.
6697 blocks
/boot/initrd.gz created.
Be sure to run lilo again if you use it.

now following this, from Kubuntu, I ran update-grub. The part of grub.cfg that contains the Slackware listings show this:
Code:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-2.6.33.4 root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-huge-2.6.33.4 root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-huge-smp-2.6.33.4-smp root=/dev/sda5
}
### END /etc/grub.d/30_os-prober ###

Since nothing had changed from before (note have been only able to load the huge kernels, generics kernel panic), I then added a custom entry to etc/grub.d/40_custom (as ubuntu asks for) rather than editing the grub.cfg file. My addition is:
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 Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
        intird /boot/initrd.gz
}

which then makes the updated grub.cfg file
Code:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-2.6.33.4 root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-huge-2.6.33.4 root=/dev/sda5
}
menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-huge-smp-2.6.33.4-smp root=/dev/sda5
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# 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 Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
        intird /boot/initrd.gz
}
### END /etc/grub.d/40_custom ###

can someone please point me in the right direction as to why this will not load. Many thanks from a newbie.

Drakeo 01-04-2011 01:44 PM

could you tell me if Ubuntu is on the sda drive also. I have had some problems with install on sdb1 and slackware on sda1 and ubuntu thinking slackware is sdb1 and ubuntu is sda1.
Quote:

insmod ext2
and you see grub may not be loading ext4 but when you load the vmlinuz huge it has the ext4 module. but the generic kernel will not have it.so when it goes to look for the initrd.img it will be unable to mount the ext4 fs . you will be unable to sync or file system.
No root device.
Quote:

The next time you get to the Grub2 menu, type "c" to get to the Grub prompt. Type "lsmod" and it will show which modules are loaded. You will find ext2 listed as one of the loaded modules.

Hint: If too many modules are loaded, they may scroll off the page. To see them all, type "set pager=1" and you will be able to scroll through the list using the ENTER key.

Try to load ext4 with "insmod ext4". On my computer, I get a "error: file not found" since the ext4 module doesn't exist.
How to enter 'Edit Mode'.this link here
Press your 'e' key from your GRUB Menu to switch into 'Edit Mode'.
Use your 'Esc' key to return to the GRUB menu.

why does grub see it but vmlinuz generic doesn't? Because when the small system grub2 rleases to the kernel the ext4 module is gone.
now the kernel starts to run but can't load the ext4 because it is on a file system that it cant see.
As you may know grub2 is for ubuntu.
there is a couple other reasons but I need more input on your kernel panic code.

Snark1994 01-04-2011 02:03 PM

Like you, I get a kernel panic in Slackware if I boot using the top menu entry (the "generic" kernel), but boot fine if I use the "huge" kernel. This is (as far as I know / can guess) not a problem with Grub2, it's to do with Slackware configuration - especially considering the huge kernel boots, and the only difference between the menu entries is the "linux /boot..." line. If you wanted to track down the source of the error, then you'd have to look at the difference between the huge and the generic kernels.

EDIT: No luck for me, at least, with Drakeo's suggestion, but that's the sort of thing I would expect it to be :) and the error I get is something like "Unable to mount root VFS filesystem on unknown block (0,18)"

Drakeo 01-04-2011 06:55 PM

Quote:

Quote:

menuentry "Slackware Linux (Slackware 13.1.0) (on /dev/sda5)" {
insmod ext2
set root='(hd0,5)' <--------------this is /dev/sda6
search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5 <------------this is not in sync
intird /boot/initrd.gz <--------------------this is not in sync

do you see that. point it to. this will cause your problem
like I said grub2 has problems with mapping drives and reading bios.
Examples of the difference between Linux and GRUB device names.
Quote:

Linux IDE: GRUB IDE: Linux SCSI: GRUB SCSI:
/dev/hda1 ..... (hd0,0)..... /dev/sda1..... (hd0,0)
/dev/hda2 ..... (hd0,1)..... /dev/sda2..... (hd0,1)
/dev/hda3 ..... (hd0,2)..... /dev/sda3..... (hd0,2)
/dev/hda4 ..... (hd0,3)..... /dev/sda4..... (hd0,3)
/dev/hdb1 ..... (hd1,0)..... /dev/sdb1 ..... (hd1,0)
/dev/hdb2 ..... (hd1,1)..... /dev/sdb2 ..... (hd1,1)
/dev/hdb3 ..... (hd1,2)..... /dev/sdb3 ..... (hd1,2)
/dev/hdb4 ..... (hd1,3)..... /dev/sdb4 ..... (hd1,3)
your best bet is to change root=/dev/sda6 for (hd0,5)

piratesmack 01-04-2011 07:11 PM

There is a typo in your custom menu entry
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 Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
        intird /boot/initrd.gz
}

"intird" should be "initrd"

Also, if you want "update-grub" to detect the initrd automatically, rename it to "initrd.gz-generic-smp-2.6.33.4-smp"

@Drakeo

It's slightly different in Grub2, the first drive is counted as 0, and the first partition is 1.

So
Code:

Linux:      Grub Legacy  Grub2
/dev/sda1...(hd0,0).......(hd0,1)
/dev/sda2...(hd0,1).......(hd0,2)
/dev/sda3...(hd0,2).......(hd0,3)
/dev/sda4...(hd0,3).......(hd0,4)
/dev/sda5...(hd0,4).......(hd0,5)


Ubunoob001 01-04-2011 09:49 PM

Quote:

Originally Posted by piratesmack (Post 4213372)
There is a typo in your custom menu entry
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 Linux (Slackware 13.1.0) (on /dev/sda5)" {
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set da42e122-79d6-4215-aa8c-7b42cdfe8876
        linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
        intird /boot/initrd.gz
}

"intird" should be "initrd"

Also, if you want "update-grub" to detect the initrd automatically, rename it to "initrd.gz-generic-smp-2.6.33.4-smp"


[/code]

Piratesmack, I feel silly for making such a trivial error in spelling, however this did, infact, make the custom menu entry, and thus the generic smp kernel bootable. On to trying to clean up grub and making grub recognize it without the need for a custom additional (5 now) entries for Slackware. Thanks!



Quote:

Also, if you want "update-grub" to detect the initrd automatically, rename it to "initrd.gz-generic-smp-2.6.33.4-smp"
in which config file are you referring to? Editing the main grub.cfg file so I dont have to have the custom boot option? Thanks again for helping a novice. I'm sure it should be taken with a grain of salt, but Ubuntu warns in bold "DO NOT EDIT THIS FILE, it is genated using templates from /etc/grub.d and settings from /etc/default/grub".

Can i Just ignore this and edit the non-working generic boot option to be the same as the current (spelling corrected) custom entry?


---------

also thanks to Drakeo

Richard Cranium 01-04-2011 11:22 PM

See http://www.linuxquestions.org/questi...2/#post4211074

Ubunoob001 01-05-2011 10:24 AM

Quote:

Originally Posted by Richard Cranium (Post 4213518)

Okay thanks.

Drakeo 01-05-2011 11:37 PM

guess I learn every day. thanks

nycace36 03-18-2015 01:09 AM

Very helpful for Grub2'ers!
 
Have been fairly annoyed over the years that most "solutions" to getting a /boot initrd working seem to automatically keep **ASSUMING** that the Slackware bootloader is LILO instead of grub2. :mad:

This false assumption continues to be problematic for those having Grub2 load other distros and then getting continually, almost blindingly, push-pushed within the Slackware help guides into install the generic Slackware kernel with an initrd (of course using LILO) for maximum efficiency. Encouragement as in http://docs.slackware.com/slackware:beginners_guide and http://docs.slackware.com/slackbook:booting

I think that the better solution is to go ahead and follow the 'mkinitrd' suggestions at http://docs.slackware.com/slackbook:booting and then halt before doing all that LILO junk the Slackware guides keep throwing at you. At that point, the previously mentioned steps for adding one or more file entry for /etc/grub.d/* are immensely helpful, followed by manually adding the ending generic kernel and initrd lines as
Code:

linux /boot/vmlinuz-generic-smp-2.6.33.4-smp root=/dev/sda5
initrd /boot/initrd.gz-generic-smp-2.6.33.4-smp

Then run "update-grub" to detect the initrd here automatically and form a good working /boot/grub/grub.cfg

My hearty :twocents:

bassmadrigal 03-18-2015 06:50 AM

Quote:

Originally Posted by nycace36 (Post 5333856)
seem to automatically keep **ASSUMING** that the Slackware bootloader is LILO instead of grub2. :mad:

Quote:

Originally Posted by nycace36 (Post 5333856)
This false assumption

Quote:

Originally Posted by nycace36 (Post 5333856)
that LILO junk the Slackware guides keep throwing at you

There is a reason people do that. Slackware uses LILO by default. Of course the guides are going to mention how to use the default setup. Not everyone runs dual boot with other distros that use grub, and while there are some Slackers that prefer grub(2) over LILO, many do not and they like the fact that Slackware uses LILO.

All that being said, if you feel that a lot of users are running into the same issues as you, you're more than welcome to update the Slackware docs. The forum isn't always the easiest place for other users to find information like this, since the terms in a search engine would turn up a lot of unrelated results.

Richard Cranium 03-20-2015 02:39 AM

And maybe don't bring a 3 year old thread to life the next time.

Alien Bob 03-20-2015 07:32 AM

Quote:

Originally Posted by nycace36 (Post 5333856)
I think that the better solution is to go ahead and follow the 'mkinitrd' suggestions at http://docs.slackware.com/slackbook:booting and then halt before doing all that LILO junk the Slackware guides keep throwing at you.

You know that that is a Wiki link, right?
Instead of spewing your angry words, get wise and request a Wiki account or join the mailing list, so that you can propose a modification to that page. Or if you do not want an account, use the "Discussion" page to write your suggestions.

Creating good documentation is not trivial, and it's very easy to stand at the sideline and point your finger. The Wiki team is always glad to get suggestions.


All times are GMT -5. The time now is 01:05 AM.