You are not logged in.

#1 2014-07-25 18:48:33

stefano
Member
Registered: 2011-04-09
Posts: 269

Grub-install fails to install core.img to boot partition

I am trying to reinstall Arch onto a Dell Precision T3600 workstation, where it used to work fine, but I am stuck at the booloader step.
Details:

1. I have only one disk, partioned with gpt.
2. I am using Grub with Bios
3. As per installation instructions (preliminary requirements, BIOS systems), I created a 1007KiB boot partition at the beginning of the disk, of type ef02.
    The partition (which is umber 5 in my partition table) goes from sector 34 to sector 2047
4. I mounted the root partition to /mnt, arch-chroot'd into it, and ran

# grub-install --target=i386-pc --recheck --debug /dev/sdx
# grub-mkconfig -o /boot/grub/grub.cfg

5. I generated the /boot/grub.cfg file with the recommended

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

Results:

when I try to boot, grub starts, but it cannot find anything to boot from and drops me into its shell.

Furthermore (this may be unrelated), when I take a look at the dis again (after rebooting from the install disk), I see that the gpt partition table is corrupted. Exact message  from gdisk is:

Caution: invalid backup GPT header, but valid main header: regenerating backup header from main  header:

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

Can anyone tell me where I am going wrong? The Installation manual is not very explicit on how to deal with the (very small) boot partition. Is grub-install supposed to create the core.img file even when the partition is not mounted? Or should it be mounted. It certainly cannot contain eveyrthing that goes into /boot (which is over 100Mb).

Thanks for the help

Offline

#2 2014-07-25 20:07:23

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

Your partition table is corrupted; you could clear it using:

# dd if=/dev/zero of=/dev/sd<x> bs=512 count=1; sync

Then use gdisk to recreate your partition table and re-install.
Alternatively, you could ask gdisk to re-create the backup GPT header from the main header: start up the program & press "r" followed by "d"...
If it still will not boot, post your /boot/grub/grub.cfg along with the output of:

# gdisk -l /dev/sd<x>

&

lsblk -f

Last edited by Head_on_a_Stick (2014-07-25 20:07:55)


Jin, Jîyan, Azadî

Offline

#3 2014-07-25 21:20:05

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

Head_on_a_Stick wrote:

Your partition table is corrupted; you could clear it using:

# dd if=/dev/zero of=/dev/sd<x> bs=512 count=1; sync

Then use gdisk to recreate your partition table and re-install.
Alternatively, you could ask gdisk to re-create the backup GPT header from the main header: start up the program & press "r" followed by "d".

I had already fixed the partition table exactly as you suggested---sorry for not having been clear. It still does not boot. 

Head_on_a_Stick wrote:

Your partition table is corrupted; you could clear it using:
If it still will not boot, post your /boot/grub/grub.cfg along with the output of:

# gdisk -l /dev/sd<x>

&

lsblk -f

Here they are:
/boot/grub.cfg:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt 
insmod ext2
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  74c69286-1775-44de-90c8-3834585da6b6
else
  search --no-floppy --fs-uuid --set=root 74c69286-1775-44de-90c8-3834585da6b6
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
### 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.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/60_memtest86+ ###
### END /etc/grub.d/60_memtest86+ ###

lsblk -f (sda1 is the swap partition, sda5 is the boot partition):

NAME              FSTYPE LABEL UUID MOUNTPOINT
sda                                 
  sda1                              
  sda3                              /
  sda4                              /home
 sda5                              
sr0                                 
loop0                               
loop1                               
  arch_root-image                   /etc/resolv.conf
loop2                               
   arch_root-image                   /etc/resolv.conf

Finally, here is the partition table from gdisk -l

GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 8B675D08-1A4A-44D3-ADC3-A7763E331455
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 8-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        67112959   32.0 GiB    8200  Linux swap
   3        67112960       276828159   100.0 GiB   8300  Linux filesystem
   4       276828160      1953525134   799.5 GiB   8300  Linux filesystem
   5              34            2047   1007.0 KiB  EF02  BIOS boot partition

Offline

#4 2014-07-25 21:43:34

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

A few points:

  • Your grub.cfg has no menu entries, no wonder it doesn't boot...

  • Where is /dev/sda2?

  • Is that the full output of lsblk -f? Mine shows the UUIDs & filesystem type.

In post #1, stefano wrote:

4. I mounted the root partition to /mnt, arch-chroot'd into it, and ran

# grub-install --target=i386-pc --recheck --debug /dev/sdx

Maybe try it without the --debug flag?
EDIT: you didn't actually use "sdx" did you? I'm sure you didn't, but it should be "sda"...

Last edited by Head_on_a_Stick (2014-07-25 21:52:10)


Jin, Jîyan, Azadî

Offline

#5 2014-07-25 22:01:27

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

Head_on_a_Stick wrote:

A few points:

  • Your grub.cfg has no menu entries, no wonder it doesn't boot...

I realize grub.cfg has no menu entries. But isn't grub-mkconfig suppose to create them?

Head_on_a_Stick wrote:
  • Where is /dev/sda2?

I deleted it. I first tried to create a boot partition after I created swap, then I realized  it can only be created at sector 34 if you create it last (as the installation manual says). Shouldn't be a problem, though, I think

Head_on_a_Stick wrote:
  • Is that the full output of lsblk -f? Mine shows the UUIDs & filesystem type.

That is the full output. No other info are present

Head_on_a_Stick wrote:
In post #1, stefano wrote:

4. I mounted the root partition to /mnt, arch-chroot'd into it, and ran

# grub-install --target=i386-pc --recheck --debug /dev/sdx

Maybe try it without the --debug flag?

Tried. Nothing changes in the grub.cfg file (after grub-install and grub-mkconfig)

Offline

#6 2014-07-25 22:06:59

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

Just to be absolutely sure: in your first post & in post #5 above, your command uses "sdx". Which exact commands are you using?
It should be:

# grub-install --target=i386-pc --recheck /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

Jin, Jîyan, Azadî

Offline

#7 2014-07-25 22:08:19

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

Yeah, sorry for that. It is "sda" not "sdx"

Offline

#8 2014-07-25 22:09:57

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

What I don't understand is the (allegedly necessary) role of the 1Mb boot partition at sectors 34-2047. Which installation program is supposed to write to it? And how can I check?

Offline

#9 2014-07-25 22:14:12

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

GRUB installs the bootloader to those sectors & that parses grub.cfg...
From the wiki:

The GPT partition also creates a protective MBR partition to stop unsupported tools from modifying it. You may need to set a bootable flag on this protective MBR e.g., using cfdisk, or some BIOSes/EFIs will refuse to boot.


Jin, Jîyan, Azadî

Offline

#10 2014-07-25 22:58:01

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

Head_on_a_Stick wrote:

GRUB installs the bootloader to those sectors & that parses grub.cfg...
From the wiki:

The GPT partition also creates a protective MBR partition to stop unsupported tools from modifying it. You may need to set a bootable flag on this protective MBR e.g., using cfdisk, or some BIOSes/EFIs will refuse to boot.


I read that, and it's pretty opaque to me. If I try to use cfdisk I can only see /dev/sda1 (although I am not sure if it really is my first partition), instead of seeing a list of all the partition on the drive.
How do I set the bootable flag on this protective MBR partition?
I tried to change the attributes of the boot partition with gdisk and make it legacy, BIOS-bootable (gdisk, then x, a, and then attribute 2 (Legacy-BIOS bootable). No effect

Furthermore,  the wiki says:

GRUB in BIOS-GPT configuration requires a BIOS boot partition to embed its core.img in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of boot sectors takes place in that case.

But this is no what happens in my case, I guess. The output of grub-install has this line:

grub-install: info: grub-mkimage --directory '/usr/lib/grub/i386-pc' --prefix '(,gpt2)/boot/grub' --output '/boot/grub/i386-pc/core.img' --format 'i386-pc' --compression 'auto' 'ext2' 'part-gpt' 'biosdisk'

which seems to indicate the core.img file ends up on the root partition (at /boot/grub...etcetera) and not on the small partition I created for this purpose.
I am more and more puzzled

Offline

#11 2014-07-25 23:52:44

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

Use gparted from the live environment & set sda5 with the "bios_grub" flag (select /dev/sda5, right click on sda5, go to "Manage Flags", enable the "bios_grub" tick-box).
From the gparted manual:

BIOS_GRUB indicates a BIOS boot partition often used by the GRUB 2 boot loader.


Jin, Jîyan, Azadî

Offline

#12 2014-07-26 00:19:04

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,776
Website

Re: Grub-install fails to install core.img to boot partition

Also from the wiki:

A sample /boot/grub/grub.cfg gets installed as part of the grub package, and subsequent grub-* commands may not over-write it. Ensure that your intended changes are in grub.cfg, rather than in grub.cfg.new or some such file.

If this is true in your case, use:

# grub-mkconfig -o ~/newgrub

Then copy ~/newgrub to /boot/grub/grub/.cfg...


Jin, Jîyan, Azadî

Offline

#13 2014-07-26 04:04:31

stefano
Member
Registered: 2011-04-09
Posts: 269

Re: Grub-install fails to install core.img to boot partition

I gave up on BIOS-GPT-Grub.
I think I tried every possible suggestions I could find, but I could not get it to work.

I restarted from scratch with UEFI-GPT-gummiboot. It worked.

Cheers,

S.

Offline

Board footer

Powered by FluxBB