[lfs-support] Grub 2.0 problem

Tobias Gasser lfs at ebp-gasser.ch
Fri Nov 16 03:06:03 PST 2012


> You should have /boot/grub/i386-pc/core.img.
yes. it's size is 26433


> grub-install is a script.  Lets try to look at that to see if we can
> figure it out.  Adding a few echo commands can confirm some of the
> settings.  You can also try 'grub-install --verbose /dev/sda'.  You may
> want to add --recheck.  See below.

--verbose is unknow, but --debug is available

if --debug is given, in linne 378 (grub-install)
setup_verbose="--verbose"
is set. thus i guess --debug is fine



> First, check that /usr/sbin/grub-install and
> /usr/share/grub/grub-mkconfig_lib exist.  I suspect that is OK.
yes


> Reading through grub-install, at line 336. we should have:
>
> source_dir=/usr/lib/grub/i386-pc
> target=i386-pc
yes


> The file /usr/lib/grub/i386-pc/modinfo.sh shoul have:
> #!/bin/sh
>
> grub_modinfo_target_cpu=i386
> grub_modinfo_platform=pc
yes

>
> A few lines later, it should set
>
> grub_setup=/usr/sbin/grub-bios-setup
yes


> This is a binary executable.
>
> Later, it sets device_map="/boot/grub/device.map"
yes


> It would be good to see if this file exists.  Mine has the contents:
>
> (hd0)   /dev/sda
>
> --recheck should recreate device.map.
nope.
the file does not exist.

--recheck alone fails,
--recheck /dev/sda is fine, but no device.map is built

find / | grep "device\.map"
does not find the file

older grub versions had something like 'grub-mkdevicemap' as far as i 
remember. but 2.00 doesn't have it any more.

i copied from the ubuntu-version to /boot/grub, but i still just reach 
the grub-rescue-console. so probably the missing device.map is not the 
problem.




> The script then copies a lot of files to /boot/grub/{i386-pc,locale} and
> possibly (not for lfs) /boot/grub/{themes,fonts}.
yes


> It runs grub-probe.  It should result in /dev/sda1.  This could be
> where the problem is:
>
> $sudo /usr/sbin/grub-probe --device-map="" --target=device /boot
> /dev/sda1
no problem, the response is /dev/sda1 as expected


> It then creates /boot/grub/grubenv which for me is just a lot of # marks.
yes.


> Next, figure out what it things $fs_module, $disk_module,
> $partmap_module, and $devabstraction_module should be by checking what
> $modules is.
fs: ext2
disk: biosdisk
part: part_msdos
modules: biosdisk ext2 part_msdos

looks ok for me


> It then runs grub-mkimage.  See what the parameters are being used for
> that.  This is what should create core.img.

i just put "echo" before "$grub_mkimage..."
in lines 720 and 722 and got:

bash-4.2# ./grub-install /dev/sda
/usr/bin/grub-mkimage -d /usr/lib/grub/i386-pc -O i386-pc 
--output=/boot/grub/i386-pc/core.img --prefix=(,msdos1)/grub biosdisk 
ext2 part_msdos

what is NOT what i expect

1) there is no load.cfg, but maybe that's ok
2) the prefix is WRONG, it should be either "/boot" or "(hd0,msdos1)"

i went back to line 642 an got
drive: (hostdisk//dev/sda,msdos1)
and after the sed
partition: ,msdos1
drive: hostdisk//dev/sda



i now just added
prefix_drive="(hd0,msdos1)"
in line 717 to force the correct value

bash-4.2# ./grub-install /dev/sda
/usr/bin/grub-mkimage -d /usr/lib/grub/i386-pc -O i386-pc 
--output=/boot/grub/i386-pc/core.img --prefix=(hd0,msdos1)/grub biosdisk 
ext2 part_msdos

which looks more reasonable to me.



> Finally, it runs grub-setup.  See what parameters are being used for
> that also.


bash-4.2# ./grub-install /dev/sda
/usr/sbin/grub-bios-setup --directory=/boot/grub/i386-pc --device-map= 
/dev/sda

(same with and without my inserted line 717)


i now run "grub-install /dev/sda" with my inserted line 717.
i'll be back in either 2 minutes after sucessful reboot, or 15 minutes 
id i have to use the live-cd to reinstall grub...

tobias




More information about the lfs-support mailing list