<< Using GRUB instead GRUB2, or using no bootloader >>

Hello,

I have a server from 2009. It was running CentOS 5.11. As I need a modern version of glibc, I decided to install openSUSE Tumbleweed. Now I am facing the problem that GRUB2 do not boot (give the generic message “free magic is broken”). I also trying other distros like openSUSE Leap and CentOS 7.0, all using GRUB2.

My question?

Is it possible to not use a bootloader or to use GRUB Legacy instead GRUB2?

Regards,

Hatuey

Hi
Have you run memtest on the RAM? Is this a fresh install across the disk(s), if so may pay to clean out any remnants (wipefs) and zero out the mbr.

@malcolmlewis,

Yes, I run memory test. No error.

Also, I formatted and used two different disk for clean install.

Hi
Well the error is usually RAM related, no BIOS tweaks for the RAM (speed/clocking) in play?

Nop :frowning:

I use the default BIOS options.

The funny thing is that I can boot openSUSE from the hard disk using the installation DVD without any problem. It is just GRUB2…

Hi
Boot flag set on the boot drive (sda)?


lsblk
fdisk -l /dev/sda

Disk boot order set in the BIOS?

Here are the outputs?

linux-9t8r:~ # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 298.1G  0 disk 
└─sda1   8:1    0 298.1G  0 part /
sdb      8:16   1   7.5G  0 disk 
├─sdb1   8:17   1   3.7M  0 part 
└─sdb2   8:18   1   4.3G  0 part 
sr0     11:0    1  1024M  0 rom

and

linux-9t8r:~ # fdisk -l /dev/sda
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4A327294-4E08-4E81-85E9-130A5179C609

Device     Start       End   Sectors   Size Type
/dev/sda1   2048 625141759 625139712 298.1G Linux filesystem

Hi
So switch to root user and run the following to se the boot flag;


fdisk /dev/sda
a
1
w
systemctl reboot

What are sdb1 and sdb2? Maybe the bootloader was installed on sdb…?

The command “a” give me an error…
The other commands run ok. But at the end, I can not boot.

The sdb is the flashdrive used to install/boot the system.

Also, I run the RESCATUX disk, and I got the log file bellow with information about the system.


Boot Info Script 0.61      [1 April 2012]

Identifying MBRs...
Computing Partition Table of /dev/sda...
Searching sda1 for information... 
                  Boot Info Script 0.61      [1 April 2012]


============================= Boot Info Summary: ===============================

 => Grub2 (v2.00) is installed in the MBR of /dev/sda and looks at sector 
    155500208 of the same hard drive for core.img. core.img is at this 
    location and looks in partition 1 for (,gpt1)/boot/grub2.

sda1: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  Grub2 (v1.99-2.00)
    Boot sector info:  Grub2 (v2.00) is installed in the boot sector of sda1 
                       and looks at sector 155500144 of the same hard drive 
                       for core.img. core.img is at this location and looks 
                       in partition 1 for (,gpt1)/boot/grub2.
    Operating System:  Welcome to openSUSE 20160813 "Tumbleweed" - Kernel ().
    Boot files:        /boot/grub2/grub.cfg /etc/fstab 
                       /boot/grub2/i386-pc/core.img

============================ Drive/Partition Info: =============================

Drive: sda _____________________________________________________________________

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sda1                   1   625,142,447   625,142,447  ee GPT


GUID Partition Table detected.

Partition    Start Sector    End Sector  # of Sectors System
/dev/sda1           2,048   625,141,759   625,139,712 Data partition (Linux)

"blkid" output: ________________________________________________________________

Device           UUID                                   TYPE       LABEL

/dev/loop0                                              squashfs   
/dev/sda1        9497ee90-3970-4350-8a4a-4b11a4e8103e   ext4       
/dev/sr0         2016-08-26-22-46-43-00                 iso9660    Rescatux0.40b9

================================ Mount points: =================================

Device           Mount_Point              Type       Options

/dev/loop0       /lib/live/mount/rootfs/filesystem.squashfs squashfs   (ro,noatime,seclabel)
/dev/sr0         /lib/live/mount/medium   iso9660    (ro,noatime)


========================== sda1/boot/grub2/grub.cfg: ===========================

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

### BEGIN /etc/grub.d/00_header ###
if  -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif  -s $prefix/grubenv ]; then
  load_env
fi

if  "${env_block}" ] ; then
  load_env -f "${env_block}"
fi

if  "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   if  "${env_block}" ] ; then
     save_env -f "${env_block}" next_entry
   fi
   set boot_once=true
else
   set default="${saved_entry}"
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,gpt1'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 --hint='hd0,gpt1'  9497ee90-3970-4350-8a4a-4b11a4e8103e
else
  search --no-floppy --fs-uuid --set=root 9497ee90-3970-4350-8a4a-4b11a4e8103e
fi
    font="/usr/share/grub2/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_output gfxterm
insmod part_gpt
insmod ext2
set root='hd0,gpt1'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 --hint='hd0,gpt1'  9497ee90-3970-4350-8a4a-4b11a4e8103e
else
  search --no-floppy --fs-uuid --set=root 9497ee90-3970-4350-8a4a-4b11a4e8103e
fi
insmod gfxmenu
loadfont ($root)/boot/grub2/themes/openSUSE/ascii.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans10.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans12.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
insmod png
set theme=($root)/boot/grub2/themes/openSUSE/theme.txt
export theme
if  x${boot_once} = xtrue ]; then
  set timeout=0
elif  x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=8
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=8
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE Tumbleweed'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9497ee90-3970-4350-8a4a-4b11a4e8103e' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt1'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 --hint='hd0,gpt1'  9497ee90-3970-4350-8a4a-4b11a4e8103e
    else
      search --no-floppy --fs-uuid --set=root 9497ee90-3970-4350-8a4a-4b11a4e8103e
    fi
    echo    'Loading Linux 4.7.0-2-default ...'
    linux    /boot/vmlinuz-4.7.0-2-default root=UUID=9497ee90-3970-4350-8a4a-4b11a4e8103e  splash=silent quiet showopts
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd-4.7.0-2-default
}
submenu 'Advanced options for openSUSE Tumbleweed' --hotkey=1 $menuentry_id_option 'gnulinux-advanced-9497ee90-3970-4350-8a4a-4b11a4e8103e' {
    menuentry 'openSUSE Tumbleweed, with Linux 4.7.0-2-default' --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.7.0-2-default-advanced-9497ee90-3970-4350-8a4a-4b11a4e8103e' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt1'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 --hint='hd0,gpt1'  9497ee90-3970-4350-8a4a-4b11a4e8103e
        else
          search --no-floppy --fs-uuid --set=root 9497ee90-3970-4350-8a4a-4b11a4e8103e
        fi
        echo    'Loading Linux 4.7.0-2-default ...'
        linux    /boot/vmlinuz-4.7.0-2-default root=UUID=9497ee90-3970-4350-8a4a-4b11a4e8103e  splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-4.7.0-2-default
    }
    menuentry 'openSUSE Tumbleweed, with Linux 4.7.0-2-default (recovery mode)' --hotkey=3 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.7.0-2-default-recovery-9497ee90-3970-4350-8a4a-4b11a4e8103e' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt1'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 --hint='hd0,gpt1'  9497ee90-3970-4350-8a4a-4b11a4e8103e
        else
          search --no-floppy --fs-uuid --set=root 9497ee90-3970-4350-8a4a-4b11a4e8103e
        fi
        echo    'Loading Linux 4.7.0-2-default ...'
        linux    /boot/vmlinuz-4.7.0-2-default root=UUID=9497ee90-3970-4350-8a4a-4b11a4e8103e  
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-4.7.0-2-default
    }
}

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

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

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

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

### 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/80_suse_btrfs_snapshot ###
### END /etc/grub.d/80_suse_btrfs_snapshot ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###

### BEGIN /etc/grub.d/95_textmode ###
### END /etc/grub.d/95_textmode ###
--------------------------------------------------------------------------------

=============================== sda1/etc/fstab: ================================

--------------------------------------------------------------------------------
UUID=9497ee90-3970-4350-8a4a-4b11a4e8103e /                    ext4       acl,user_xattr        1 1
--------------------------------------------------------------------------------

=================== sda1: Location of files loaded by Grub: ====================

           GiB - GB             File                                 Fragment(s)


=============================== StdErr Messages: ===============================

cat: write error: Broken pipe
cat: write error: Broken pipe
cat: /tmp/BootInfo-QE5nIJc4/Tmp_Log: No such file or directory
  No volume groups found
mdadm: No arrays found in config file or automatically

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.


Hi
Ahh, it’s moved to e(x)pert mode, and a A (A toggle the legacy BIOS bootable flag)

So it’s;


fdisk /dev/sda
x
A
r
w
fdisk -l /dev/sda

Should show a * against sda1.

ok. I did that in two ways:

  • boot into my system using “Boot into Linux” DVD option. In this case, I have to reboot the system. No * against sda1. No boot.
  • boot using the “Rescue System” DVD option. In this case there is no need to reboot. No * against sda1. No boot.

Hi
So the disk is gpt, not dos…?

What is the output from;


gdisk -l /dev/sda

The system is set to UEFI mode, not Legacy?

It looks like. But I do not know when I select this. I just delete the partition scheme proposed and use the whole disk for the system files and select to mount “/” on it.

Is:

gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 625142448 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4A327294-4E08-4E81-85E9-130A5179C609
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 625142414
Partitions will be aligned on 2048-sector boundaries
Total free space is 2669 sectors (1.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       625141759   298.1 GiB   8300  primary

I really do not know. The BIOS has no option about UEFI and the disk is old too.

You should have a swap and home partition.

If this is older machine then it would have a BIOS any since last 5 or 6 years should have a UEFI. It is important to know which.

For a MBR boot using generic boot code you must have a boot flag on the partition that is to be booted and grub code needs installed to the partition to be booted. If you put grub code in the MBR the boot flag is not required. Perhaps you did not select any boot code since you did not use the recommended partition scheme???

You can use MBR boot (legacy) on a UEFI machine but you must set the BIOS to boot in legacy mode

If UEFI and booting EFI mode then you must have a small (100 meg or so) FAT format partition to be used as a EFI boot partition.

If multi-booting then all OS must use the same boot method

Hi
So you need to sort out the disk (swap from gpt to dos) and re-install…

Boot from a rescue usb device, grab a Tumbleweed live or 13.2 rescue iso image and burn to disk or USB…

Once booted to the rescue system, I would then open a terminal and switch to root user and run (note use gdisk and fdisk);


wipefs -a /dev/sda1
wipefs -a /dev/sda
gdisk /dev/sda
x
z
Y
Y
fdisk /dev/sda
sda1 size 500MB type 8300 for /boot
sda2 extended (rest of disk)
sda5 size (1.5 times installed RAM) type 8200 for swap
sda6 size 40 GB for / (for btrfs? or how you like for say ext4)

You can of course split up as required for your end use of the server eg for mail or a database etc.

So Once cobfigured above to your requirements, then during the re-install select expert partitioner and then hit the ‘rescan disk button’ then go in and select partitions as required for install.

Well, you have GPT partition label which means that to install GRUB2 in MBR you must have additional BIOS Boot partition; but it is not present. Still you have GRUB2 code in MBR that points to some disk location; and another GRUB2 in partition boot sector on sda1 that points to different disk location. Not sure where GRUB2 in MBR comes from, but it may point to garbage. In this configuration you need generic GPT MBR code and install GRUB2 in partition. What was on this disk before? How did you install, what bootloader configuration was chosen during installation?