Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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... <¬(

share|improve this question

3 Answers 3

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
}
share|improve this answer
    
I was very happy to see your answer 8¬) Here's what happened… "Arch linux" showed up in the boot menu!!!! When selected, grub2 responded "file not found...&" –  keepitsimpleengineer Jul 20 '12 at 3:30
    
So I booted in 10.04 (where everything still works) and ran sudo blkid ⋯cue drum roll⋯ arch linux noW reported as: /dev/sdc1: LABEL="arch_boot" UUID="34a39f15-f1a8-46a3-88e7-00c370c3c6a2" TYPE="ext2" /dev/sdc2: LABEL="arch_root" UUID="c670b0cf-a644-48d6-903d-dc3e49395a04" TYPE="ext2" /dev/sdc3: UUID="b36c4dc0-f5d7-488e-80fb-4c2e14313de5" TYPE="swap" /dev/sdc5: LABEL="arch_home" UUID="327900a5-e8f7-4dc4-be52-2f0dd97e3164" TYPE="ext4" /dev/sdc6: LABEL="arch_adjunct" c670b0cf-a644-48d6-903d-dc3e49395a04"UUID="f65f0ae6-9af2-4767-b223-a199ce96c71a" TYPE="reiserfs" –  keepitsimpleengineer Jul 20 '12 at 3:40
    
… so perhaps "--set=root 34a39f15-f1a8-46a3-88e7-00c370c3c6a2" should be "--set=root c670b0cf-a644-48d6-903d-dc3e49395a04" let me know, I'm dying of curiosity :¬) –  keepitsimpleengineer Jul 20 '12 at 3:40
up vote 0 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.