LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   GRUB2 Problems (https://www.linuxquestions.org/questions/linux-general-1/grub2-problems-4175454459/)

Inphi 03-17-2013 08:02 PM

GRUB2 Problems
 
Hello.
I'm trying to deal with a booting issue. Haven't been able to get much help from google, other forums, etc, because I believe my problem is peculiar.
My HDD setup like sometime like this
Code:

Disk /dev/sdb  - 320GB
/dev/sdb1 - NTFS/exFAT (Windows Vista)                  *bootable (Start: 63; End: 47513847; ID: 7)
/dev/sdb2 - NTFS/exFAT (Windows Recovery)                          (Start: 598982656; End: 625135615; ID: 7)
/dev/sdb3 - Linux      (/root)                          *bootable (ID: 83)
/dev/sdb4 - Extended Partition                                    (ID: 5)
/dev/sdb5 - Linux Swap/Solaris (Logical Partition)                (ID: 82)
/dev/sdb6 - Linux      (/home - logical paritition)                (ID: 83)

I am attempting to dual-boot Windows Vista and Arch linux that was newly installed.

The problem:
After installing Arch-linux and GRUB2 (unsuccessfully), I was presented with the Windows Boot Manager. However, Arch wasn't listed in the bootup menu. I tried a Windows utility called EasyBCD to edit the windows boot config file to show Arch OS. It did show the Arch. However when I chose to boot Arch, I was greeted with the notorious GRUB2 CLI.
I was unable to perform a manual boot (via linux vm* /dev/sdb3; initrd init*; boot). I then tried to overwrite the MBR with just GRUB2, but I lost the Windows bootloader entry (as expected) and I was still presented with GRUB2 CLI.
I tried to reinstall GRUB2 again, but this time editing /etc/grub.d/40_custom to show Windows Vista. At bootup, I was presented with the familiar GRUB2 screen, however only the Windows OS was listed. On selecting the Windows OS, I was presented with the windows boot manager that lists both Windows Vista and Arch linux. Booting into Windows was successful. Booting into Arch was not. In fact, booting into Arch takes me back to the GRUB2 screen, which would chainload Windows Vista boot loader again upon selection, and an infinite loop occurs.

My Current MBR
Code:

mbr: x86 boot sector: partition 1: ID=0x7, active, starthead 1, startsector 63, 475137985 sectors; partition 2: ID=0x7, starthead 254, startsector 598982656, 26152960 sectors; partition 3: ID=0x83, active, starthead 254, startsector 475138048, 1992060 sectors; partition 4: ID=0x5, starthead 254, startsector 477130108, 12182548 sectors, code offset 0x63.
My Analysis
I believe I am having problems with booting because, my boot partition is at /dev/sdb3 and not /dev/sdb1. Since the grub2 configuration files are at /dev/sdb3, the GRUB2 code at MBR is unable to locate them, hence fubar'ing the boot-up sequence (prolly in stage 2).
Another reason why I think I'm having problems is because for some reason, the kernel image and the ram disk aren't at the default locations, i.e. /boot. Instead they're at root.
According to http://www.dedoimedo.com/computers/grub.html:
Quote:

By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.
Does that mean that I should mark my Windows partition as inactive so that the MBR code would locate GRUB2 at sdb3?

I cannot think of any ideas, so I'm hoping someone here would provide me with a solution.

Thanks.

syg00 03-18-2013 03:16 AM

Quote:

Originally Posted by Inphi (Post 4913553)
I believe I am having problems with booting because, my boot partition is at /dev/sdb3 and not /dev/sdb1. Since the grub2 configuration files are at /dev/sdb3, the GRUB2 code at MBR is unable to locate them, hence fubar'ing the boot-up sequence (prolly in stage 2).

Nope. Grub (of any vintage) is well able to find it's code - I regularly (normally even) boot from a logical partition for example.
Quote:

Another reason why I think I'm having problems is because for some reason, the kernel image and the ram disk aren't at the default locations, i.e. /boot. Instead they're at root.
Yep, that's more of an issue, but will rear it's head later in the boot cycle.M$oft propaganda repeated endlessly on the web. Not relevant to Linux boot-loaders that ignore the boot flag entirely. Windoze will get more confused - remove the boot flag from the Linux partition to keep it (Windoze) happy.

So we can get a real picture of your current boot structure, go here, do as it says and post the RESULTS.txt

Inphi 03-18-2013 11:44 AM

Here's my RESULTS.txt:
Please note that my /dev/sdc below refers to /dev/sdb above. It's the same, only the letters of the block device changed.

Code:

                  Boot Info Script 0.61      [1 April 2012]


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

 => Grub2 (v1.99) is installed in the MBR of /dev/sdc and looks at sector 1 of
    the same hard drive for core.img. core.img is at this location and looks
    in partition 99 for .

sdc1: __________________________________________________________________________

    File system:      ntfs
    Boot sector type:  Windows Vista/7: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  Windows 7
    Boot files:        /bootmgr /boot/bcd /Windows/System32/winload.exe

sdc2: __________________________________________________________________________

    File system:      ntfs
    Boot sector type:  Windows Vista/7: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System: 
    Boot files:        /bootmgr

sdc3: __________________________________________________________________________

    File system:      ext4
    Boot sector type:  -
    Boot sector info:
    Operating System: 
    Boot files:        /grub/grub.cfg /boot/grub/grub.cfg /boot/grub/grub.conf

sdc4: __________________________________________________________________________

    File system:      Extended Partition
    Boot sector type:  -
    Boot sector info:

sdc5: __________________________________________________________________________

    File system:      swap
    Boot sector type:  -
    Boot sector info:

sdc6: __________________________________________________________________________

    File system:      ext4
    Boot sector type:  -
    Boot sector info:
    Operating System:  Arch Linux ()
    Boot files:        /etc/fstab

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

Drive: sdc _____________________________________________________________________

Disk /dev/sdc: 320.1 GB, 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/sdc1    *            63  475,138,047  475,137,985  7 NTFS / exFAT / HPFS
/dev/sdc2        598,982,656  625,135,615    26,152,960  7 NTFS / exFAT / HPFS
/dev/sdc3    *    475,138,048  477,130,107    1,992,060  83 Linux
/dev/sdc4        477,130,108  598,982,655  121,852,548  5 Extended
/dev/sdc5        477,130,171  481,130,292    4,000,122  82 Linux swap / Solaris
/dev/sdc6        481,130,356  598,982,655  117,852,300  83 Linux


"blkid" output: ________________________________________________________________

Device          UUID                                  TYPE      LABEL

/dev/loop0                                              squashfs 
/dev/loop1      578f4f7a-123c-4d94-a4fc-3104a3e41cd9  ext4     
/dev/loop2      578f4f7a-123c-4d94-a4fc-3104a3e41cd9  ext4     
/dev/mapper/arch_root-image 578f4f7a-123c-4d94-a4fc-3104a3e41cd9  ext4     
/dev/sdc1        6375AF0777B0FCAD                      ntfs     
/dev/sdc2        B03629ED3629B56E                      ntfs      RECOVERY
/dev/sdc3        11960aea-2a84-425b-8557-430938a64f0f  ext4     
/dev/sdc5        301a459f-a217-469b-97e2-fae3c8f1c9fd  swap     
/dev/sdc6        874ad8a6-7516-49dc-9467-e1e603b751c4  ext4     
/dev/sr0        2013-01-04-22-05-45-00                iso9660    ARCH_201301

========================= "ls -R /dev/mapper/" output: =========================

/dev/mapper:
arch_root-image
control

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

Device          Mount_Point              Type      Options

/dev/loop0      /run/archiso/sfs/root-image squashfs  (ro,relatime)
/dev/mapper/arch_root-image /                        ext4      (rw,relatime)
/dev/sr0        /run/archiso/bootmnt    iso9660    (ro,relatime)


============================= sdc3/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
set default="0"

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_msdos
insmod ext2
set root='hd1,msdos6'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos6 --hint-efi=hd1,msdos6 --hint-baremetal=ahci1,msdos6  874ad8a6-7516-49dc-9467-e1e603b751c4
else
  search --no-floppy --fs-uuid --set=root 874ad8a6-7516-49dc-9467-e1e603b751c4
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
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch GNU/Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-874ad8a6-7516-49dc-9467-e1e603b751c4' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos3 --hint-efi=hd1,msdos3 --hint-baremetal=ahci1,msdos3  11960aea-2a84-425b-8557-430938a64f0f
        else
          search --no-floppy --fs-uuid --set=root 11960aea-2a84-425b-8557-430938a64f0f
        fi
        echo        'Loading Linux core repo kernel ...'
        linux        /vmlinuz-linux root=UUID=874ad8a6-7516-49dc-9467-e1e603b751c4 ro  quiet
        echo        'Loading initial ramdisk ...'
        initrd        /initramfs-linux.img
}
menuentry 'Arch GNU/Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-874ad8a6-7516-49dc-9467-e1e603b751c4' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos3 --hint-efi=hd1,msdos3 --hint-baremetal=ahci1,msdos3  11960aea-2a84-425b-8557-430938a64f0f
        else
          search --no-floppy --fs-uuid --set=root 11960aea-2a84-425b-8557-430938a64f0f
        fi
        echo        'Loading Linux core repo kernel ...'
        linux        /vmlinuz-linux root=UUID=874ad8a6-7516-49dc-9467-e1e603b751c4 ro  quiet
        echo        'Loading initial ramdisk ...'
        initrd        /initramfs-linux-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/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 ###
--------------------------------------------------------------------------------

=========================== sdc3/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
set default="0"

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_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### 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/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.
menuentry "Microsoft Windows Vista BIOS-MBR" {
        insmod part_msdos
        insmod ntfs
        insmod search_fs_uuid
        insmod ntldr
        search --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1 6375AF0777B0FCAD
        ntldr /bootmgr
}
### 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 ###
--------------------------------------------------------------------------------

========================== sdc3/boot/grub/grub.conf: ===========================

--------------------------------------------------------------------------------
#
# 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
set default="0"

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_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### 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/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 ###
--------------------------------------------------------------------------------

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

          GiB - GB            File                                Fragment(s)

 226.715972900 = 243.434422272  boot/grub/grub.cfg                            1
 226.698684692 = 243.415859200  boot/grub/grub.conf                            1
 226.692386627 = 243.409096704  grub/grub.cfg                                  1
 226.732765198 = 243.452452864  initramfs-linux-fallback.img                  1
 226.712654114 = 243.430858752  initramfs-linux.img                            1
 226.692138672 = 243.408830464  vmlinuz-linux                                  1

=============================== sdc6/etc/fstab: ================================

--------------------------------------------------------------------------------
#
# /etc/fstab: static file system information
#
# <file system>        <dir>        <type>        <options>        <dump>        <pass>
# UUID=874ad8a6-7516-49dc-9467-e1e603b751c4
/dev/sdb6                  /                ext4              rw,relatime,data=ordered        0 1

# UUID=11960aea-2a84-425b-8557-430938a64f0f
/dev/sdb3                  /boot            ext4              rw,relatime,data=ordered        0 2

# UUID=301a459f-a217-469b-97e2-fae3c8f1c9fd
/dev/sdb5                  none              swap              defaults          0 0

--------------------------------------------------------------------------------

========= Devices which don't seem to have a corresponding hard drive: =========

sda

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

  No volume groups found
mdadm: No arrays found in config file or automatically


amani 03-18-2013 12:02 PM

You can boot from grub2 cli like so

configfile (hd2,3)/grub.cfg

Inphi 03-18-2013 12:12 PM

yeah. I know that would boot it.
But, I want to know how to boot my OS without the GRUB2 CLI like it's supposed to do/

amani 03-20-2013 10:01 AM

Quote:

Originally Posted by Inphi (Post 4913948)
yeah. I know that would boot it.
But, I want to know how to boot my OS without the GRUB2 CLI like it's supposed to do/

The install log of grub2 will help

what happens if you update grub?

check driver modules loaded in grub2, boot order

Inphi 03-20-2013 12:20 PM

So after much strain, I was able to edit the grub.cfg files to include Arch OS in the boot menu and load the appropriate kernel and modules for that entry. It worked!
Thing is, I did this without the use of custom scripts. In fact /boot/grub/grub.cfg had only the Windows Vista menuentry with the 10_linux script entry empty(I really don't know why I didn't see that earlier), and /grub/grub.cfg had only the Arch linux menuentry. This is kinda confusing since I thought grub-update or grub-install should have picked up both scripts when grub.cfg was generated.


All times are GMT -5. The time now is 10:20 PM.