1

I want to add a custom menu to grub2 like this (as /etc/grub.d/40_custom):

#!/bin/sh
exec tail -n +3 $0
# 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 "Arch Linux" {
....some data here.....
}

and what I need is the "....some data here....."

Some difficulties:

  1. When booting the drive order changes from BIOS e.g. sometimes the disk with the partition is /dev/sda and sometimes it is /dev/sdg. so I use the UUIDs for the partition. UPDATE: last time is was /dev/sdc !

  2. The Linux system uses a separate boot partition i.e. partition 1 is the /boot partition, partition 2 is the /root partition and extended partition 4 is the /home partition

Here blkid output from when Linux thought the disk was /dev/sdg...

/dev/sdg1: LABEL="arch_boot" UUID="34a39f15-f1a8-46a3-88e7-00c370c3c6a2" TYPE="ext2" 
/dev/sdg2: LABEL="arch_root" UUID="c670b0cf-a644-48d6-903d-dc3e49395a04" TYPE="ext2" 
/dev/sdg3: UUID="b36c4dc0-f5d7-488e-80fb-4c2e14313de5" TYPE="swap" 
/dev/sdg5: LABEL="arch_home" UUID="327900a5-e8f7-4dc4-be52-2f0dd97e3164" TYPE="ext4" 
/dev/sdg6: LABEL="arch_adjunct" UUID="f65f0ae6-9af2-4767-b223-a199ce96c71a" TYPE="reiserfs" 

Here's contents of the Linux System (which had grub legacy until boot-repair overrode the MBR):

⋯@64bitWS:/media$ ls arch_boot
grub  initramfs-linux-fallback.img  initramfs-linux.img  lost+found  vmlinuz-linux
⋯@64bitWS:/media$ ls arch_boot/grub
e2fs_stage1_5  iso9660_stage1_5  minix_stage1_5     stage2           vstafs_stage1_5
fat_stage1_5   jfs_stage1_5      reiserfs_stage1_5  stage2_eltorito  xfs_stage1_5
ffs_stage1_5   menu.lst          stage1             ufs2_stage1_5
⋯@64bitWS:/media$ ls arch_root
aur  boot  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
bin  dev   home  lib64  media       opt  root  sbin  sys  usr

boot-info at http://paste.ubuntu.com/1099113/ and at http://paste.ubuntu.com/1100049/ for each of the cases of different boot orders.

I know it can work because it has worked before...


UPDATE:

I ran os-prober from 10.04 (1.38/lucid) and it worked, it found all linux systems unlike 12.04 os-prober (1.51). So I ran boot-repair (http://paste.ubuntu.com/1101977/) again and it produced the Arch Linux grub2 menu entry. It loooked like this (from /boot/grub/grub.conf):

menuentry 'Arch Linux' {
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd6,msdos1)'
    search --no-floppy --fs-uuid --set=root 34a39f15-f1a8-46a3-88e7-00c370c3c6a2
    linux   /boot/vmlinuz-linux root=UUID=670b0cf-a644-48d6-903d-dc3e49395a04
    initrd  /boot/initramfs-linux.img
}

Identical to Cumulus007 proposed answer.

Unfortunately this "new" grub.cfg wouldn't boot Arch Linux so no answer yet...


Last UPDATE: It seems that 10.04's grub3 (1.98) cannot use UUIDs for booting, and since my hardware's BIOS mixes up hard-drive order from boot to boot, actually achieving a boot is a craps shoot... <¬(

3 Answers3

0

Let me know if this works:

menuentry 'Arch Linux' {
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd6,msdos1)'
    search --no-floppy --fs-uuid --set=root 34a39f15-f1a8-46a3-88e7-00c370c3c6a2
    linux   /boot/vmlinuz-linux root=UUID=670b0cf-a644-48d6-903d-dc3e49395a04
    initrd  /boot/initramfs-linux.img
}
0

Well, this worked for me, probably not an option for others.

I have three Linux systems installed, Ubuntu 10.04 LTS, Xubuntu 12.04 and Arch Linux (rolling release).

12.04 failed because it's os-prober cannot find the Arch Linux

10.04 failed because it cannot use UUIDs and my hardware BIOS mixes up the hard-drive order.

So I turned to Arch Linux, installed grub2 and configured it. It's os-prober finds all installed systems and it can use UUIDs.

Installation per https://wiki.archlinux.org/index.php/Grub

0

Line 184 of /etc/grub.d/30_os-prober reads:

prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"

This could make the script parser to confuse. Edit it to:

prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e 's/^/\t/')"

should make it look better. This is the only defect I found in the os-prober of grub2 in 12.04. Try it and see if it can find the OS.

wijit
  • 19