lost and found ( for me ? )

Grub2 chainloader : Linux Mint 12 , Fedora 16 ( Linux dual boot )


Here’s an explanation of how to update the grub2 configuration.

I’ve dual-booted two Linux distributions , Linux Mint 12 and Fedora 16.

MBR (Master Boot Record ) : Linux Mint's Grub2
Linux Mint : /dev/sda6
Fedora's Grub : /dev/sda1

When upgrading the Fedora’s kernels , I need to update Linux Mint’s Grub2 configuration (MBR) so that I can boot the new Fedora’s kernel via Linux Mint’s Grub(MBR).

I’d like to change MBR :

from

Linux mint 12
Fedora 16 ( 3.1.0-7 )

to

Linux mint 12
Fedora 16 ( 3.1.0-7 )
Fedora 16 ( 3.1.6-1 ) <- boot this kernel ver. via Mint’s grub

before updating Mint’s Grub ( MBR )

Let’s check the current /boot/grub/grub.cfg on Mint.

The following lines are  for Linux mint ( Linux Mint’s Grub )
### BEGIN /etc/grub.d/10_linux ###
<snip>
menuentry 'Linux Mint 12 32-bit, 3.0.0-14-generic (/dev/sda6)' --class linuxmint --class gnu-linux --class gnu --class os {
       recordfail
       set gfxpayload=$linux_gfx_mode
       insmod gzio
       insmod part_msdos
       insmod ext2
       set root='(hd0,msdos6)'
       search --no-floppy --fs-uuid --set=root b3a1ec63-246c-4711-b0ba-b14584205b71
       linux   /boot/vmlinuz-3.0.0-14-generic root=UUID=b3a1ec63-246c-4711-b0ba-b14584205b71 ro   quiet splash vt.handoff=7
       initrd  /boot/initrd.img-3.0.0-14-generic
}
<snip>
### END /etc/grub.d/10_linux ###


The followings are for Fedora 16 ( Linux Mint’s Grub )
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Fedora release 16 (Verne) (on /dev/sda1)" --class gnu-linux --class gnu --class os {
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fea960
       linux /boot/vmlinuz-3.1.0-7.fc16.i686.PAE root=/dev/sda1
       initrd /boot/initramfs-3.1.0-7.fc16.i686.PAE.img
}
### END /etc/grub.d/30_os-prober ###


There are two ways :

- have MBR ( Mint’s Grub ) load Fedora’s grub ( chainloader )
- add Fedora’s new kernel parameters in MBR

way1 : have MBR ( Mint’s Grub ) load Fedora’s grub ( chainload )

on Mint , iinstall os-prober to find installed other OSes
# apt-get install os-prober -y


Fedora 16 has been installed in /dev/sda1
# os-prober
/dev/sda1:Fedora release 16 (Verne):Fedora:linux


make 15_Fedora file to have MBR load Fedora’s grub
# cat /etc/grub.d/15_Fedora
#!/bin/sh
cat << \EOF
menuentry "Fedora" {
   set root='(hd0,msdos1)'  # hd0 = /dev/sda  msdos1 = sda1
   chainloader +1
}
EOF

# chmod u+x 15_Fedora


update grub.cfg ( MBR )
# update-grub2


The red lines are added in /boot/grub/grub.cfg
### BEGIN /etc/grub.d/15_Fedora ###
menuentry "Fedora" {
   set root='(hd0,msdos1)'
   chainloader +1
}
### END /etc/grub.d/15_Fedora ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Fedora release 16 (Verne) (on /dev/sda1)" --class gnu-linux --class g
nu --class os {
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fe
a960
       linux /boot/vmlinuz-3.1.0-7.fc16.i686.PAE root=/dev/sda1
       initrd /boot/initramfs-3.1.0-7.fc16.i686.PAE.img
}
menuentry "Fedora release 16 (Verne) (on /dev/sda1)" --class gnu-linux --class gnu --class os {
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fea960
       linux /boot/vmlinuz-3.1.6-1.fc16.i686.PAE root=/dev/sda1
       initrd /boot/initramfs-3.1.6-1.fc16.i686.PAE.img
}
### END /etc/grub.d/30_os-prober ###


You can boot the Fefora’s new kernel ( 3.1.6-1 ) via Mint’s grub.

way2 : add Fedora’s new kernel parameters in MBR

on Linux Mint 12

install os-prober to find installed other OSes
# apt-get install os-prober -y


Fedora 16 has been installed in /dev/sda1
# os-prober
/dev/sda1:Fedora release 16 (Verne):Fedora:linux


check the file system of /dev/sda1 (Fedora16)
# grub-probe -d /dev/sda1
btrfs


mount /dev/sda1 to tmp directory to check Fedora’s grub.cfg.
# mount -t btrfs /dev/sda1 tmp


check the Fedora’s grub.cfg
Red lines are the new Fedora’s kernel 3.1.6-1.
This kernel ver. does not exist in MBR (Mint’s grub ).
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Fedora (3.1.6-1.fc16.i686.PAE)' --class fedora --class gnu-linux --cl
ass gnu --class os {
       load_video
       set gfxpayload=keep
       insmod gzio
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fe
a960
       echo 'Loading Fedora (3.1.6-1.fc16.i686.PAE)'
       linux   /boot/vmlinuz-3.1.6-1.fc16.i686.PAE root=UUID=ba2b7a10-73a2-4986
-bcc5-964966fea960 ro rd.md=0 rd.lvm=0 rd.dm=0 quiet rhgb rd.luks=0 LANG=ja_JP.U
TF-8  KEYTABLE=jp106
       echo 'Loading initial ramdisk ...'
       initrd /boot/initramfs-3.1.6-1.fc16.i686.PAE.img
}
menuentry 'Fedora Linux, with Linux 3.1.0-7.fc16.i686.PAE' --class fedora --clas
s gnu-linux --class gnu --class os {
       load_video
       set gfxpayload=keep
       insmod gzio
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fea960
       echo    'Loading Linux 3.1.0-7.fc16.i686.PAE ...'
       linux   /boot/vmlinuz-3.1.0-7.fc16.i686.PAE root=UUID=ba2b7a10-73a2-4986-bcc5-964966fea960 ro rd.md=0 rd.lvm=0 rd.dm=0 quiet rhgb rd.luks=0 LANG=ja_JP.UTF-8  KEYTABLE=jp106
       echo    'Loading initial ramdisk ...'
       initrd  /boot/initramfs-3.1.0-7.fc16.i686.PAE.img
}


on Mint , make 15_Fedora file and add the above red lines
# cat /etc/grub.d/15_Fedora
#!/bin/sh
cat << \EOF
menuentry 'Fedora (3.1.6-1.fc16.i686.PAE)' --class fedora --class gnu-linux --cl
ass gnu --class os {
       load_video
       set gfxpayload=keep
       insmod gzio
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fe
a960
       echo 'Loading Fedora (3.1.6-1.fc16.i686.PAE)'
       linux   /boot/vmlinuz-3.1.6-1.fc16.i686.PAE root=UUID=ba2b7a10-73a2-4986
-bcc5-964966fea960 ro rd.md=0 rd.lvm=0 rd.dm=0 quiet rhgb rd.luks=0 LANG=ja_JP.U
TF-8  KEYTABLE=jp106
       echo 'Loading initial ramdisk ...'
       initrd /boot/initramfs-3.1.6-1.fc16.i686.PAE.img
}
EOF

# chmod u+x 15_Fedora


update grub.cfg
# update-grub2
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.0.0-14-generic
Found initrd image: /boot/initrd.img-3.0.0-14-generic
Found linux image: /boot/vmlinuz-3.0.0-13-generic
Found initrd image: /boot/initrd.img-3.0.0-13-generic
Found linux image: /boot/vmlinuz-3.0.0-12-generic
Found initrd image: /boot/initrd.img-3.0.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Fedora release 16 (Verne) on /dev/sda1
done


Fefora’s new kernel has been added in MBR’s grub.cfg ( Mint )
### BEGIN /etc/grub.d/15_Fedora ###
menuentry 'Fedora (3.1.6-1.fc16.i686.PAE)' --class fedora --class gnu-linux --cl
ass gnu --class os {
       load_video
       set gfxpayload=keep
       insmod gzio
       insmod part_msdos
       insmod btrfs
       set root='(hd0,msdos1)'
       search --no-floppy --fs-uuid --set=root ba2b7a10-73a2-4986-bcc5-964966fe
a960
       echo 'Loading Fedora (3.1.6-1.fc16.i686.PAE)'
       linux   /boot/vmlinuz-3.1.6-1.fc16.i686.PAE root=UUID=ba2b7a10-73a2-4986
-bcc5-964966fea960 ro rd.md=0 rd.lvm=0 rd.dm=0 quiet rhgb rd.luks=0 LANG=ja_JP.U
TF-8  KEYTABLE=jp106
       echo 'Loading initial ramdisk ...'
       initrd /boot/initramfs-3.1.6-1.fc16.i686.PAE.img
}
### END /etc/grub.d/15_Fedora ###


You can boot the Fedora’s new kernel (3.1.6-1) via Mint’s grub ( MBR )

You need to issue update-grub2 command in both the way1 and the way2 after upgrading Fedora’s kernel.
In case of way1 , all you have to do is just issuing update-grub2.
However , in case of way2 , you need to edit  /etc/grub.d/15_Fedora and issue update-grub2.
So I think the way1 would be a better operation than the way2.

1 comment:

  1. Would like your help, I have done "way 1" but all I get is "GRUB" and a flashing curser. I'm running Debian on sda2 and fedora on sda8 and trying to chainlink from debian to fedora. All this installed on a MacBook, booting using refit.
    Thanks in advance

    ReplyDelete

Note: Only a member of this blog may post a comment.