LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2018, 01:17 PM   #1
gr00t
LQ Newbie
 
Registered: Nov 2018
Posts: 2

Rep: Reputation: Disabled
Grub chainloading


Hello lq world. I would really like some help to sort some things out. My current goal is configuring the dedicated -OS indipendent- grub partition to chainload 3 linux and 1 windows OS. Before I begin shooting questions, here is all the important information :
Code:
============================ Drive/Partition Info: =============================

Drive: sda _____________________________________________________________________
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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: dos

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sda1    *          2,048       227,327       225,280   6 FAT16
/dev/sda2             227,328    63,141,887    62,914,560   7 NTFS / exFAT / HPFS
/dev/sda3          63,141,888   976,773,167   913,631,280   5 Extended
/dev/sda5          63,143,936    67,338,239     4,194,304  82 Linux swap / Solaris
/dev/sda6          67,340,288   109,283,327    41,943,040  83 Linux
/dev/sda7         109,285,376   151,228,415    41,943,040  83 Linux
/dev/sda8         151,230,464   172,201,983    20,971,520  83 Linux
/dev/sda9         172,204,032   976,773,167   804,569,136   7 NTFS / exFAT / HPFS


"blkid" output: ________________________________________________________________

Device           UUID                                   TYPE       LABEL

/dev/sda1        0EA1-C938                              vfat       
/dev/sda2        3832A31E681AEC2F                       ntfs       
/dev/sda5        66d265cf-0c88-4296-8cac-f554d2653bb6   swap       
/dev/sda6        98d05dfa-db15-4f1d-aaa9-f7d391ab89c2   ext4       
/dev/sda7        f28e4012-1dff-418e-9804-917831dc7dce   ext4       
/dev/sda8        78b6cb51-477e-4c1d-aa2f-0b83a0bde05e   ext4       
/dev/sda9        5A57CB7B0B27B20A                       ntfs       

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

Device           Mount_Point              Type       Options

/dev/sda7        /                        ext4       (rw,relatime,errors=remount-ro)
  • /dev/sda1: GRUB master
  • /dev/sda2: Windows 7 (not installed)
  • /dev/sda5: Swap to be shared
  • /dev/sda6 : Arch (installed)
  • /dev/sda7: Kali (installed)
  • /dev/sda8: Bunsenlabs (not installed)
  • /dev/sda9: Data to be shared

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

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

sda1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  Grub2 (v1.99)
    Boot sector info:  Grub2 (v1.99) is installed in the boot sector of sda1 
                       and looks at sector 80227016 of the same hard drive 
                       for core.img. core.img is at this location and looks 
                       in partition 80 for . No errors found in the Boot 
                       Parameter Block.
    Operating System:  
    Boot files:        /boot/grub/grub.cfg

sda2: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Unknown
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        

sda3: __________________________________________________________________________

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

sda5: __________________________________________________________________________

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

sda6: __________________________________________________________________________

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

sda7: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  Grub2 (v1.99)
    Boot sector info:  Grub2 (v1.99) is installed in the boot sector of sda7 
                       and looks at sector 127071512 of the same hard drive 
                       for core.img. core.img is at this location and looks 
                       in partition 130 for .
    Operating System:  Kali GNU/Linux Rolling
    Boot files:        /boot/grub/grub.cfg /etc/fstab

sda8: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  
    Boot files:        

sda9: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Unknown
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:
Code:
=========================== sda1/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 [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos6'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,msdos6' --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
else
  search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
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 ###

menuentry 'Arch Linux' {
	insmod part_msdos
	insmod ext2
	search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
	configfile /boot/grub/grub.cfg	
}

menuentry "Kali" {
	insmod part_msdos
	insmod ext2
	insmod chain
        set root=(hd0,7)
        chainloader +1
}

### 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 ###
--------------------------------------------------------------------------------
Code:
=========================== sda6/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 [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos6'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,msdos6' --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
else
  search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
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 ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-98d05dfa-db15-4f1d-aaa9-f7d391ab89c2' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos6'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,msdos6' --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
	else
	  search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
	fi
	echo	'Loading Linux linux ...'
	linux	/boot/vmlinuz-linux root=UUID=98d05dfa-db15-4f1d-aaa9-f7d391ab89c2 rw  quiet
	echo	'Loading initial ramdisk ...'
	initrd	/boot/amd-ucode.img /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-98d05dfa-db15-4f1d-aaa9-f7d391ab89c2' {
	menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-98d05dfa-db15-4f1d-aaa9-f7d391ab89c2' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_msdos
		insmod ext2
		set root='hd0,msdos6'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,msdos6' --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
		else
		  search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
		fi
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=98d05dfa-db15-4f1d-aaa9-f7d391ab89c2 rw  quiet
		echo	'Loading initial ramdisk ...'
		initrd	/boot/amd-ucode.img /boot/initramfs-linux.img
	}
	menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-98d05dfa-db15-4f1d-aaa9-f7d391ab89c2' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_msdos
		insmod ext2
		set root='hd0,msdos6'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,msdos6' --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6  98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
		else
		  search --no-floppy --fs-uuid --set=root 98d05dfa-db15-4f1d-aaa9-f7d391ab89c2
		fi
		echo	'Loading Linux linux ...'
		linux	/boot/vmlinuz-linux root=UUID=98d05dfa-db15-4f1d-aaa9-f7d391ab89c2 rw  quiet
		echo	'Loading initial ramdisk ...'
		initrd	/boot/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/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 ###
--------------------------------------------------------------------------------
Code:
=========================== sda7/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 ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  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_msdos
insmod ext2
set root='hd0,msdos7'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  f28e4012-1dff-418e-9804-917831dc7dce
else
  search --no-floppy --fs-uuid --set=root f28e4012-1dff-418e-9804-917831dc7dce
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_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=-1
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=-1
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  f28e4012-1dff-418e-9804-917831dc7dce
else
  search --no-floppy --fs-uuid --set=root f28e4012-1dff-418e-9804-917831dc7dce
fi
insmod png
if background_image /usr/share/desktop-base/kali-theme/grub/grub-4x3.png; then
  set color_normal=white/black
  set color_highlight=black/white
else
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
	set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Kali GNU/Linux' --class kali --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-f28e4012-1dff-418e-9804-917831dc7dce' {
	load_video
	insmod gzio
	if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos7'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  f28e4012-1dff-418e-9804-917831dc7dce
	else
	  search --no-floppy --fs-uuid --set=root f28e4012-1dff-418e-9804-917831dc7dce
	fi
	echo	'Loading Linux 4.18.0-kali2-amd64 ...'
	linux	/boot/vmlinuz-4.18.0-kali2-amd64 root=UUID=f28e4012-1dff-418e-9804-917831dc7dce ro initrd=/install/initrd.gz 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-4.18.0-kali2-amd64
}
submenu 'Advanced options for Kali GNU/Linux' $menuentry_id_option 'gnulinux-advanced-f28e4012-1dff-418e-9804-917831dc7dce' {
	menuentry 'Kali GNU/Linux, with Linux 4.18.0-kali2-amd64' --class kali --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-kali2-amd64-advanced-f28e4012-1dff-418e-9804-917831dc7dce' {
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_msdos
		insmod ext2
		set root='hd0,msdos7'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  f28e4012-1dff-418e-9804-917831dc7dce
		else
		  search --no-floppy --fs-uuid --set=root f28e4012-1dff-418e-9804-917831dc7dce
		fi
		echo	'Loading Linux 4.18.0-kali2-amd64 ...'
		linux	/boot/vmlinuz-4.18.0-kali2-amd64 root=UUID=f28e4012-1dff-418e-9804-917831dc7dce ro initrd=/install/initrd.gz 
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-4.18.0-kali2-amd64
	}
}

### 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/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### 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 ###
As you see, I implement a configfile boot method to get into Arch as I was getting an 'invalid signature' error. In my journey the lesson I learned was that you cannot chainload if you have no Volume Boot Record. I cannot remember how I messed the grub installation in Arch, I was under the impression that everything was done, especially since everything is in it. So now all I have to do is install grub inside every root partition of any linux to implement a chainload method right? I proceeded with this in my mind so I pointed Kali to install grub into /dev/sda7 during the installation. Then with some trial and error I chainloaded grub and now it works! Next step was reconfiguring Kali's grub to get rid of the double entries in my submenu as Arch had its own. Accomplished implementing GRUB_DISABLE_OS_PROBER=true in /etc/default/grub. Now my menu is cleaner.

Question #1:Why does MBR look at partition 80 for core.img? What partition is this?
Question #2:What is the best method to install grub in Arch and how do I install an already preconfigured version so that I will not have to manually edit again to get rid of prober,etc?
Question #3:How can I read the contents of MBR's grub?
Question #4:GRUB master is defaulting a 5 second delay. All I have inside the grub partition is grub.cfg,its modules,fonts,grubenv,locale and themes so there is no /etc/default settings to play with. Can I just remove all the code and add default grub settings functionality with custom entries inside it? How about theming it?
Question #5:Supposing all is set, I will install Windows 7 at some point. What I know for sure is that I will lose MBR. Will a simple reinstall in /dev/sda from a live cd begin to point sda1 to bring it back to life? Then I assume all I have to do is chainload windows from sda1 and all is done, right? (Windows won't have the 100mb preserved partition as I always omit it.)

I am sorry for the long post and thank you in advance.
 
Old 11-06-2018, 03:29 AM   #2
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,808
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by gr00t View Post
Question #1:Why does MBR look at partition 80 for core.img? What partition is this?
Question #2:What is the best method to install grub in Arch and how do I install an already preconfigured version so that I will not have to manually edit again to get rid of prober,etc?
Question #3:How can I read the contents of MBR's grub?
Question #4:GRUB master is defaulting a 5 second delay. All I have inside the grub partition is grub.cfg,its modules,fonts,grubenv,locale and themes so there is no /etc/default settings to play with. Can I just remove all the code and add default grub settings functionality with custom entries inside it? How about theming it?
Question #5:Supposing all is set, I will install Windows 7 at some point. What I know for sure is that I will lose MBR. Will a simple reinstall in /dev/sda from a live cd begin to point sda1 to bring it back to life? Then I assume all I have to do is chainload windows from sda1 and all is done, right? (Windows won't have the 100mb preserved partition as I always omit it.)
#5: You don't have to "lose MBR" if you don't depend on it in the first place. With Windows compatible boot code on MBR, the only disruption installing Windows will produce is a move of the boot flag that signals generic boot code which partition to jump to. That flag is easily relocated regardless what is currently booted. It's how I've been multibooting more than 2.5 decades.
#4: Have you considered placing a custom menu on your Grub master and loading kernels and initrds directly? All my kernels and initrds have symlinks, so the custom menu on the master Grub infrequently needs any updating. Chainloading from it here represents fallback modes, such as for using previous kernels. I update the symlinks manually at kernel update time for distros that don't provide them automatically. Automatically generated Grub stanzas are very rarely used here, whether with MBR (self-maintained menu.lst on sda[1,2,3]) or UEFI (custom.cfg on ESP).
#3: What do you mean by "read"?
#2: "Best" is subjective. Here, each distro gets it's bootloader limited to its / partition and os-prober disabled. Installers that don't provide either that option or an option for no bootloader at all get aborted. More I defer to others, since I've never used Arch.
#1: 80 represents the primary partition with the boot flag set. The MBR is a very small space. What grub can do with it is limited to locating code that enables proceeding further, which core.img contains.
 
Old 11-06-2018, 05:33 AM   #3
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
Quote:
Originally Posted by gr00t View Post
Question #2:What is the best method to install grub in Arch and how do I install an already preconfigured version so that I will not have to manually edit again to get rid of prober,etc?
Perhaps the best way is to chroot into arch and install grub2 there with your current grub tools. Preconfigured version? Grub2 uses /etc/grub.d scripts. You could copy these and/or modify them as you wish to create the basis of your grub2 config.

Quote:
Originally Posted by gr00t View Post
Question #4:GRUB master is defaulting a 5 second delay. All I have inside the grub partition is grub.cfg,its modules,fonts,grubenv,locale and themes so there is no /etc/default settings to play with. Can I just remove all the code and add default grub settings functionality with custom entries inside it? How about theming it?
Those settings are in the same place. Personally I can't stand grub2, especially after learning how to use it properly. I could advise you to use grub legacy as an easier solution to resolve what you want to do, and with a way easier way to configure and fix your grub if something goes wrong. And much better to use as a chainloader to 3 other grub's and 1x windows bootloader.

Quote:
Originally Posted by gr00t View Post
Question #5:Supposing all is set, I will install Windows 7 at some point. What I know for sure is that I will lose MBR. Will a simple reinstall in /dev/sda from a live cd begin to point sda1 to bring it back to life? Then I assume all I have to do is chainload windows from sda1 and all is done, right? (Windows won't have the 100mb preserved partition as I always omit it.)
Yup, pretty much as you say.
 
Old 11-06-2018, 09:05 AM   #4
gr00t
LQ Newbie
 
Registered: Nov 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
First of all, thank you both for your answers.

Quote:
Originally Posted by mrmazda View Post
#5: You don't have to "lose MBR" if you don't depend on it in the first place. With Windows compatible boot code on MBR, the only disruption installing Windows will produce is a move of the boot flag that signals generic boot code which partition to jump to. That flag is easily relocated regardless what is currently booted. It's how I've been multibooting more than 2.5 decades.
So what you're saying is that Windows won't replace the current MBR boot code when installed but only move the flag bit and point to its own partition.

Quote:
Originally Posted by mrmazda View Post
#4: Have you considered placing a custom menu on your Grub master and loading kernels and initrds directly? All my kernels and initrds have symlinks, so the custom menu on the master Grub infrequently needs any updating. Chainloading from it here represents fallback modes, such as for using previous kernels. I update the symlinks manually at kernel update time for distros that don't provide them automatically. Automatically generated Grub stanzas are very rarely used here, whether with MBR (self-maintained menu.lst on sda[1,2,3]) or UEFI (custom.cfg on ESP).
Of course I have considered a custom menu but direct booting is what I don't want to implement. I would probably have it setup already if I used this method as it is much more straightforward. I will most likely handle older kernels with submenus. To make this question more clear, is there a place where I can find how GRUB keys used by grub-mkconfig are translated? For example, 'GRUB_DEFAULT_TIMEOUT' can be translated to 'set timeout=x'. Here is an alpha version of the custom master grub:

Code:
## ========== MASTER GRUB CFG ========== ##

### DEVICE NAME CONVERSIONS ###
#
# Linux		GRUB
#------------------------------
# /dev/fd0	(fd0)
# /dev/sda	(hd0)
# /dev/sdb2	(hd1,2)

### MENU TIMEOUT ###
set timeout=60

### DEFAULT BOOT ENTRY ###
set default=1

### BEGIN MENU SETUP ###

font='/boot/grub/fonts/unicode.pf2'
if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
#  set locale_dir=/boot/grub/locale
#  set lang=en_US
#  insmod gettext
fi
terminal_output gfxterm

### Background ###
insmod png
background_image /boot/image.png
set menu_color_normal=white/black
set menu_color_highlight=black/white
set gfxpayload=1366x768

### END MENU SETUP ###

### ENTRY LIST ###

# Menu Entry Number ---> 0
menuentry "Windows" 	{
	insmod ntfs
	insmod chain
	set root=(hd0,2)
	chainloader +1
}

# Menu Entry Number ---> 1
menuentry "Arch" 	{
	insmod ext2
	insmod chain
	set root=(hd0,6)
	chainloader +1
}

# Menu Entry Number ---> 2
menuentry "Kali"	{
	insmod ext2
	insmod chain
	set root=(hd0,7)
	chainloader +1
}

# Menu Entry Number ---> 3
menuentry "Bunsenlabs"	{
	insmod ext2
	insmod chain
	set root=(hd0,8)
	chainloader +1
}
I'm still searching and reading .cfg codes and try to understand what is going on and what code I can omit so that I can have a very clear and fully functional cfg master. Is it possible to theme it using themes.txt like this one even though there is no grub-mkconfig to generate?

Quote:
Originally Posted by mrmazda View Post
#3: What do you mean by "read"?
Nevermind this, my brain farted when I was posting and somehow I thought I also had grub inside MBR to read from. Heck, I even started from reading what MBR is, what its contents are and how the boot process works. On further analysis, I found this which shows how to decrypt and read MBR record.


Quote:
Originally Posted by zeebra View Post
Perhaps the best way is to chroot into arch and install grub2 there with your current grub tools. Preconfigured version? Grub2 uses /etc/grub.d scripts. You could copy these and/or modify them as you wish to create the basis of your grub2 config.
Avoiding configuring grub.d scripts was that question all about. If I copy the preconfigured scripts from Kali and move them to Arch will it properly generate stuff? Can we at this point say that scripts can be used universally and are not bound to anything except grub-mkconfig itself?

Quote:
Originally Posted by zeebra View Post
Those settings are in the same place. Personally I can't stand grub2, especially after learning how to use it properly. I could advise you to use grub legacy as an easier solution to resolve what you want to do, and with a way easier way to configure and fix your grub if something goes wrong. And much better to use as a chainloader to 3 other grub's and 1x windows bootloader.
It's funny because well, I didn't wake up one day and said "GRUB2 CHAINLOAD, I CHOOSE YOUUUU!". I was actually inspired by saikee, a guy from justlinux forums who used GRUB LEGACY to boot 145+ operating systems. I already know that if I went the legacy way it would be easier. I also never took it well when grub2 started being used. Yes, I was there before GRUB2 took over. But one has to overcome and adapt since legacy is left behind to rot in a dark forest. What convinced me is this:
  • GRUB 2 is available for several other types of system in addition to the PC BIOS systems supported by GRUB Legacy: PC EFI, PC coreboot, PowerPC, SPARC, and MIPS Lemote Yeeloong are all supported.
  • Many more file systems are supported, including but not limited to ext4, HFS+, and NTFS.
  • GRUB 2 can read files directly from LVM and RAID devices.

After all, gaining the knowledge of GRUB2 benefits me (and others apparently) in the future. Right now I'm left with this laptop but my future PC will be EFI capable, I plan on using encrypted partitions, ..
 
Old 11-06-2018, 10:51 AM   #5
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
Quote:
Question #4:GRUB master is defaulting a 5 second delay. All I have inside the grub partition is grub.cfg,its modules,fonts,grubenv,locale and themes so there is no /etc/default settings to play with
If no disto will make changes to the grub.cfg, then edit it directly. editing the grub.cfg directly becomes an issue whenever update-grub/grub-mkconfig is ran either manually or by an update as it will overwrite any edits that are done to grub.cfg.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help chainloading grub to my SD card shadowbox12 Linux - Laptop and Netbook 12 11-06-2011 06:58 PM
[SOLVED] Chainloading GRUB from Win7 TheStarLion Linux - Software 4 04-13-2011 09:19 AM
chainloading to grub 2handband Slackware 38 12-24-2010 07:25 AM
Chainloading Grub from Lilo Unr3a164 Slackware 5 06-04-2008 10:35 AM
GRUB & XP w/out Chainloading: Possible? Computer Guru Linux - Software 5 06-14-2006 12:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration