Page 2 of 6

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 13:25
by Shador
globetrotterdk wrote:Does this give some hints about what module needs to be loaded in mkinitrd? It sounds to me like it would be the same procedure used to boot a system installed on a USB pen drive, should someone want to use GRUB rather than Lilo.
Basically yes. Some modules might overlap. But afaik card readers have their own modules. You need to check the output of lsmod for possible candidates. Optimally before attaching the card reader and after attaching it. But it might involve some trial and error until you find the right ones.
Possibly you can find some hints on the net, which modules to load.

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 16:10
by globetrotterdk
Hmm. Not really sure what I am doing here. I booted from a Salix Xfce Live 13.37 CD and ran lsmod before and after I mounted the SD card:

Code: Select all

$ lsmod > 1.txt
$ lsmod > 2.txt
I then ran

Code: Select all

$ diff 1.txt 2.txt
There was no output, so I tried:

Code: Select all

awk ' BEGIN { while ( getline < "1.txt" ) { arr[$1]=$0; } }
{ for( i = 2 ; i <= NF ; ++i ) 
	sub($i,"",arr[$1])  
  gsub("  +"," ",arr[$1])
  print arr[$1] 
} ' 2.txt > 3.txt
I appear to have gotten more output than I should have from a comparison of the two files:

Code: Select all

Module 
snd_seq_dummy 
snd_seq_oss 
snd_seq_midi_event 
snd_seq 
snd_seq_device 
snd_pcm_oss 
snd_mixer_oss 
ipv6 
ppdev 
parport_pc 
lp 
parport 
fan 
snd_hda_codec_realtek 
snd_hda_intel 
snd_hda_codec 
i915 
snd_hwdep 
drm_kms_helper 
drm 
ath5k 
snd_pcm 
ath 
processor 
rtc_cmos 
joydev 
i2c_algo_bit 
thermal 
eeepc_laptop 
snd_timer 
mac8021 1 
video 
atl2 
i2c_i81 0 
rtc_core 
psmouse 
sparse_keymap 
snd 
cfg80211 
battery 
button 
intel_agp 
soundcore 
thermal_sys 
rfkill 
serio_raw 
output 
rtc_lib 
shpchp 
ac 
i2c_core 
snd_page_alloc 
hwmon 
intel_gtt 
evdev 
sg 
agpgart 
yenta_socket 
pcmcia_rsrc 
pcmcia 
pcmcia_core 
usbhid 
hid 
fuse 
squashfs
Edit:
Hmm. I just ran a

Code: Select all

$ diff -y 1.txt 2.txt
and there doesn't appear to be any difference between the two.

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 16:40
by mimosa
Here is a site which may be useful:
http://en.gentoo-wiki.com/wiki/SD_and_MMC_card_readers

That came up when I did a quick search to see what sort of names the module might have; you can refine this by searching for your particular hardware.

Say you decide to start by trying "tifm", just do

Code: Select all

lsmod | grep tifm
To check *available* modules in your kernel

Code: Select all

modprobe -l | grep tifm
on my machine (with the 3.2.7 kernel, but no SD card) there are several. None of them are loaded.

I don't think you need to actually *mount* the card for the module(s) to be loaded, just have it plugged in. If you are able to mount it, that suggests the modules are loaded and working. So maybe the test you need is booting without the card versus booting with it inserted.

EDIT I've never actually seen one of these cards, but wouldn't it come up in the output of lspci? In which case lspci -k will tell you about the modules - see the man page. But then Shador did say a bit of trial and error might be needed ...

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 17:26
by Shador
globetrotterdk wrote:Hmm. Not really sure what I am doing here. I booted from a Salix Xfce Live 13.37 CD and ran lsmod before and after I mounted the SD card:
Obviously there's no difference. My suggestion only works for removable card READERS (not just cards). Just removing the card or (un)mounting it doesn't change the drivers loaded, because the actual hardware controlled by the driver is still there. If your system would unload the driver, the system wouldn't notice removing/adding of the card anymore. So that's clearly as expected.
mimosa wrote:EDIT I've never actually seen one of these cards, but wouldn't it come up in the output of lspci? In which case lspci -k will tell you about the modules - see the man page. But then Shador did say a bit of trial and error might be needed ...
Yes, that's probably a good starting point. Although the one or other additional module might be still needed. Be sure to check out the dependencies listed by lsmod and include at least them too.

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 17:49
by mimosa
Try also

Code: Select all

modprobe --show-depends [module_foo_bar]
... once you think you've got your module.

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 20:10
by globetrotterdk
There has got to be an easier way. The problem isn't loading the correct modules, the problem is installing GRUB on the SD card. An SD card is in it's nature portable and can be transferred to any device that has a card reader. I tried booting a Salix live cd from another 32-bit computer, with the SD card in an external card reader and ran the following:

Code: Select all

# grub-install /dev/sdc
/usr/sbin/grub-probe: error: cannot stat `none'.
This wasn't successful, possibly because it doesn't detect the SD card as "bootable", but it should be a possible work around, as long as the computer is 32-bit or at least boots a 32-bit live CD. I also tried the following from the live cd, but something weird seems to be going on:

Code: Select all

# slapt-get -u
Retrieving package data [http://salix.enialis.net/i486/slackware-13.37/]...Done
Retrieving patch list [http://salix.enialis.net/i486/slackware-13.37/]...Done
Retrieving checksum list [http://salix.enialis.net/i486/slackware-13.37/]...Done
Retrieving checksum signature [http://salix.enialis.net/i486/slackware-13.37/]...Done
Verifying checksum signature [http://salix.enialis.net/i486/slackware-13.37/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/slackware-13.37/]...Done
Reading Package Lists...Done
Retrieving package data [http://salix.enialis.net/i486/slackware-13.37/extra/]...Done
Retrieving patch list [http://salix.enialis.net/i486/slackware-13.37/extra/]... Done
Retrieving checksum list [http://salix.enialis.net/i486/slackware-13.37/extra/]...Done
Retrieving checksum signature [http://salix.enialis.net/i486/slackware-13.37/extra/]...Done
Verifying checksum signature [http://salix.enialis.net/i486/slackware-13.37/extra/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/slackware-13.37/extra/]...Done
Reading Package Lists...Done
Retrieving package data [http://salix.enialis.net/i486/13.37/]...Done
Retrieving patch list [http://salix.enialis.net/i486/13.37/]...Done
Retrieving checksum list [http://salix.enialis.net/i486/13.37/]...Done
Retrieving checksum signature [http://salix.enialis.net/i486/13.37/]...Done
Verifying checksum signature [http://salix.enialis.net/i486/13.37/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/13.37/]...Done
Reading Package Lists...Done
root[one]# mount /dev/sdc1 /media/disk
mount: mount point /media/disk does not exist
root[one]# mkdir /media/disk
root[one]# mount /dev/sdc1 /media/disk
root[one]# chroot /media/disk /bin/bash
root[/]# grub-install /dev/sdc1
bash: grub-install: command not found
root[/]# slapt-get -i grub2
Reading Package Lists...Failed to open package_data
package_data: No such file or directory
Perhaps you want to run --update?
root[/]# slapt-get -u
Retrieving package data [http://salix.enialis.net/i486/slackware-13.37/]...Cached
Retrieving patch list [http://salix.enialis.net/i486/slackware-13.37/]...Cached
Retrieving checksum list [http://salix.enialis.net/i486/slackware-13.37/]...Cached
Retrieving checksum signature [http://salix.enialis.net/i486/slackware-13.37/]...Cached
Verifying checksum signature [http://salix.enialis.net/i486/slackware-13.37/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/slackware-13.37/]...Cached
Reading Package Lists...Done
Retrieving package data [http://salix.enialis.net/i486/slackware-13.37/extra/]...Cached
Retrieving patch list [http://salix.enialis.net/i486/slackware-13.37/extra/]... Done
Retrieving checksum list [http://salix.enialis.net/i486/slackware-13.37/extra/]...Cached
Retrieving checksum signature [http://salix.enialis.net/i486/slackware-13.37/extra/]...Cached
Verifying checksum signature [http://salix.enialis.net/i486/slackware-13.37/extra/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/slackware-13.37/extra/]...Done
Reading Package Lists...Done
Retrieving package data [http://salix.enialis.net/i486/13.37/]...Cached
Retrieving patch list [http://salix.enialis.net/i486/13.37/]...Done
Retrieving checksum list [http://salix.enialis.net/i486/13.37/]...Cached
Retrieving checksum signature [http://salix.enialis.net/i486/13.37/]...Cached
Verifying checksum signature [http://salix.enialis.net/i486/13.37/]...No key for verification
Retrieving ChangeLog.txt [http://salix.enialis.net/i486/13.37/]...Cached
Reading Package Lists...Done
root[one]# slapt-get -i grub2
Reading Package Lists...Done
grub2 is up to date.
0 upgraded, 0 reinstalled, 0 newly installed, 0 to remove, 0 not upgraded.

Done
root[one]# grub-install /dev/sdc1
/usr/sbin/grub-probe: error: cannot stat `none'.

Re: Kernel panic at boot from CD to install GRUB.

Posted: 25. Mar 2012, 20:45
by Shador
The problem with Grub2 just arises from your wrong usage of it. The invocation of grub-install you used tells grub to install itself to the mbr on /dev/sdc and to put its files like modules and configuration into /boot/grub. For a LiveCD /boot/grub is an in-memory filesystem, which is lost on reboot and not accessible to grub. So it's only natural that grub fails to install like this. You need to use chroot or the --boot-directory option to change that location to /boot on /dev/sdc1. E.g. if you mounted /dev/sdc1 on /mnt/sdc1:

Code: Select all

grub-install --boot-directory=/mnt/sdc1/boot /dev/sdc
And don't forget to generate a config using grub-mkconfig (you definitely need to chroot for that one) or handcraft a /mnt/sdc1/boot/grub/grub.cfg.

Code: Select all

mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev # most likely you can omit this
chroot /mnt/sdc1
grub-mkconfig -o /boot/grub/grub.cfg

Re: Kernel panic at boot from CD to install GRUB.

Posted: 27. Mar 2012, 10:26
by globetrotterdk
That looks good :) Thanks. I received the following errror, unfortunately:

Code: Select all

# grub-mkconfig -o /boot/grub/grub.cfg
bash: grub-mkconfig: command not found
Shouldn't this read

Code: Select all

# update-grub -o /boot/grub/grub.cfg
???

Re: Kernel panic at boot from CD to install GRUB.

Posted: 27. Mar 2012, 10:58
by Shador
globetrotterdk wrote:Shouldn't this read

Code: Select all

# update-grub -o /boot/grub/grub.cfg
???
No. update-grub is just a convenience wrapper for grub-mkconfig, so you don't have to specify '-o /boot/grub/grub.cfg' everytime. Additionally it backs up the old config. So update-grub is pretty exactly the same as 'grub-mkconfig -o /boot/grub/grub.cfg' + backup.
update-grub is actually a debian invention and not shipped with the vanilla grub sources. Unlike Arch Linux, I added it in our package as it's commonly used and thought to be part of grub.
globetrotterdk wrote:That looks good :) Thanks. I received the following errror, unfortunately:

Code: Select all

# grub-mkconfig -o /boot/grub/grub.cfg
bash: grub-mkconfig: command not found
I guess you don't have installed grub2 yet, on your Salix installation on the card?
Try it like this with wired ethernet plugged in:

Code: Select all

mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev # most likely you can omit this
chroot /mnt/sdc1
dhcpcd eth0 # brings up your first network interface eth0
slapt-get -u
slapt-get -i grub2
grub-mkconfig -o /boot/grub/grub.cfg

Re: Kernel panic at boot from CD to install GRUB.

Posted: 27. Mar 2012, 11:48
by globetrotterdk
Shador wrote:I guess you don't have installed grub2 yet, on your Salix installation on the card?
How could I run this without any errors, and do I need to repeat it?

Code: Select all

grub-install --boot-directory=/mnt/sdc1/boot /dev/sdc