You are not logged in.

#1 2019-05-02 09:21:53

duane
Member
Registered: 2016-05-25
Posts: 8

Grub: loading Linux ... invalid magic number

I have LVM (vg-root, vg-data, vg-swap) on LUKS on RAID5 (mdadm).
After the grub boot menu, I'm getting:

Loading Linux linux-lts ...
error: invalid magic number.
Loading initial ramdisk ...
error: you need to load the kernel first.

I copied /boot to a USB drive and edited the menu entry from:

setparams 'Arch Linux'

        load_video
        set gfxpayload=keep
        insmod gzio

        echo    'Loading Linux linux-lts ...'
        linux   /boot/vmlinuz-linux-lts root=/dev/mapper/vg-root rw cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initramfs-linux-lts.img

to

setparams 'Arch Linux'

        load_video
        set gfxpayload=keep
        insmod gzio
set root=(hd0,msdos1)
        echo    'Loading Linux linux-lts ...'
        linux   /boot/vmlinuz-linux-lts root=/dev/mapper/vg-root rw cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initramfs-linux-lts.img

which sets me to use the copy on the USB drive. It works.

I figured that grub was finding the filesystem OK since it was getting grub.cfg for the menu, but I still went and tried "insmod"ing several modules including many gcry-* modules. Nothing worked.
fsck shows a clean root filesystem.
Has anyone a suggestion?
TIA

My grub config file is:
/boot/grub/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 loadfont unicode ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_CA
  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 ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-/dev/mapper/vg-root' {
        load_video
        set gfxpayload=keep
        insmod gzio

        echo    'Loading Linux linux-lts ...'
        linux   /boot/vmlinuz-linux-lts root=/dev/mapper/vg-root rw cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initramfs-linux-lts.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-/dev/mapper/vg-root' {
        menuentry 'Arch Linux, with Linux linux-lts' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-advanced-/dev/mapper/vg-root' {
                load_video
                set gfxpayload=keep
                insmod gzio

                echo    'Loading Linux linux-lts ...'
                linux   /boot/vmlinuz-linux-lts root=/dev/mapper/vg-root rw cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft 
                echo    'Loading initial ramdisk ...'
                initrd  /boot/initramfs-linux-lts.img
        }
        menuentry 'Arch Linux, with Linux linux-lts (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-fallback-/dev/mapper/vg-root' {
                load_video
                set gfxpayload=keep
                insmod gzio

                echo    'Loading Linux linux-lts ...'
                linux   /boot/vmlinuz-linux-lts root=/dev/mapper/vg-root rw cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft 
                echo    'Loading initial ramdisk ...'
                initrd  /boot/initramfs-linux-lts-fallback.img
        }
}

### 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 ###

/etc/default/grub:

grep -v -E '^#|^$' /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="cryptdevice=UUID=226f5978-ccac-42bd-9c81-629dcd1d8c39:md cryptkey=rootfs:/etc/keys/luks-md0.key drm_kms_helper.edid_firmware=edid/dynex-edid.bin iommu=soft"
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
GRUB_ENABLE_CRYPTODISK=y
GRUB_TERMINAL_INPUT=console
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_DISABLE_RECOVERY=true
GRUB_THEME="/boot/grub/themes/breeze"

Offline

#2 2019-05-03 18:23:16

Mortimer Houghton
Member
Registered: 2014-09-28
Posts: 85

Re: Grub: loading Linux ... invalid magic number

Look in this thread: Update problem: invalid magic number.  Something may not have updated correctly.  Using a liveusb and chroot into your system to update might fix this.

Offline

#3 2019-05-04 03:38:36

duane
Member
Registered: 2016-05-25
Posts: 8

Re: Grub: loading Linux ... invalid magic number

I saw that thread. I looks that the system somehow corrected itself -- not a lot of helpful info there. I am able to boot using the copy of the kernel and initramfs on the USB drive.

After each pacman upgrade where the kernel and/or initramfs is updated, I need to copy the files to the USB (mounted temporarily on /mnt/1):
cp /boot/vmlinuz-linux-lts /boot/initramfs-linux-lts.img  /mnt/1/boot/

Offline

#4 2019-05-04 05:55:01

duane
Member
Registered: 2016-05-25
Posts: 8

Re: Grub: loading Linux ... invalid magic number

I've removed and reinstalled grub and breeze-grub.

There exists "grub-file", which I don't know if it uses the same routines as the grub loader, but testing the kernel with it provided the following info:

for x in i386-xen-pae-domu x86_64-xen-domu x86-xen-dom0 x86-multiboot x86-multiboot2 arm-linux arm64-linux ia64-linux mips-linux mipsel-linux sparc64-linux powerpc-linux x86-linux x86-linux32 x86-kfreebsd i386-kfreebsd x86_64-kfreebsd x86-knetbsd i386-knetbsd x86_64-knetbsd i386-efi x86_64-efi ia64-efi arm64-efi arm-efi hibernated-hiberfil x86_64-xnu i386-xnu xnu-hibr x86-bios-bootsector;do grub-file "--is-$x" /boot/vmlinuz-linux-lts && echo "yes   $x"|| echo "no    $x";done    
no    i386-xen-pae-domu
yes   x86_64-xen-domu
yes   x86-xen-dom0
no    x86-multiboot
no    x86-multiboot2
no    arm-linux
no    arm64-linux
no    ia64-linux
no    mips-linux
no    mipsel-linux
no    sparc64-linux
no    powerpc-linux
yes   x86-linux
yes   x86-linux32
no    x86-kfreebsd
no    i386-kfreebsd
no    x86_64-kfreebsd
Segmentation fault (core dumped)
no    x86-knetbsd
Segmentation fault (core dumped)
no    i386-knetbsd
Segmentation fault (core dumped)
no    x86_64-knetbsd
no    i386-efi
yes   x86_64-efi
no    ia64-efi
no    arm64-efi
no    arm-efi
no    hibernated-hiberfil
no    x86_64-xnu
no    i386-xnu
no    xnu-hibr
no    x86-bios-bootsector

This seems a loose test, but at least it says the kernel is a x86_64-efi kernel.

Offline

#5 2021-04-14 21:27:40

duane
Member
Registered: 2016-05-25
Posts: 8

Re: Grub: loading Linux ... invalid magic number

This problem quietly disappeared and now has reappeared after an upgrade. This is a workaround that works for some reason.

copy vmlinux-linux-lts to some other directory. I was initially using a USB flash drive, but now I just create a subdirectory in /boot like /boot/5.10.29.
In grub, hit 'e' to edit the menu entry. Change the linux line from
linux /boot/vmlinux-linux-lts ...
to
linux /boot/5.10.29/vmlinux-linux-lts ...
.
This works.
Change /boot/grub/grub.cfg to fix things until the next grub-mkconfig.
Both files are identical with the same permissions.

Maybe someone more knowledgeable can explain why this hack is required and why it works.

Offline

Board footer

Powered by FluxBB