Android / Linux: Dualboot entries in /boot/grub/menu.lst

7

Something old came back to me recently…
In relation to the discussion under
https://groups.google.com/forum/?fromgroups#!topic/android-x86/xs9_mShRyFQ

Situation:

A netbook with Ubuntu (or any other Linux) and Android each on a separate partition.

sda1 250M ext2 boot partition
sda2 3GB ext4 Ubuntu
sda3 600m ext2 Android installation under /android-4.0-RC1 folder

GRUB 1 (0.97)

Now how to modify grub 1 to boot from sda3 android to avoid getting “file not found”.

Boot and login to the Linu running on sda2 (or sda1)

1. Get your uuid

# sudo blkid
/dev/sda1: UUID="0b2328bf-707a-4b5e-98b4-b4b75ebb0480" TYPE="ext2"
/dev/sda2: UUID="530f0371-2172-4711-8f03-fcd59087bb2b" TYPE="ext4"
/dev/sda3: UUID="4d324fc8-3af7-49cf-a48d-796a7c939307" TYPE="ext2"

This gives you the uuid’s for each partition. You will need the one for your android partition (sda3)

2. Then we modify the Grub 1 menu under /boot/grub/menu.lst*
* If this file doesn’t exist then there is a chance that you have a system not older than max 2 years which has Grub 2 (Version 1.89) Then please follow below the steps for Grub 2

# vi /boot/grub/menu.lst
# make the android entry look a bit like this:
title Android
uuid 4d324fc8-3af7-49cf-a48d-796a7c939307 <--- your one from sudo blkid sda3
root (hd0,2)
kernel /android-4.0-RC1/kernel root=/dev/ram0 androidboot.hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-4.0-RC1
initrd /android-4.0-RC1/initrd.img

# search also for this entry to make the timeout value large enough for your boot
## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 15

3. Close the editor and reboot. It should work

GRUB 2 (0.98)

Grub 2 is a different story and a bit more work involving.

1. Get your uuid

# sudo blkid
/dev/sda1: UUID="0b2328bf-707a-4b5e-98b4-b4b75ebb0480" TYPE="ext2"
/dev/sda2: UUID="530f0371-2172-4711-8f03-fcd59087bb2b" TYPE="ext4"
/dev/sda3: UUID="4d324fc8-3af7-49cf-a48d-796a7c939307" TYPE="ext2"

This gives you the uuid’s for each partition. You will need the one for your android partition (sda3)

2. Then we modify the Grub 2 menu.
Unlikely to Grub 1 it’s using /etc/default/grub to create every time a new /boot/grub/grub.cfg file. So we edit /etc/default/grub

Edit the /etc/default/grub and make it a bit look like the following

# sudo vi /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

menuentry "Android" {
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos3)'search --no-floppy --fs-uuid --set=root 4d324fc8-3af7-49cf-a48d-796a7c939307
linux /android-4.0-RC1/kernel root=UUID=530f0371-2172-4711-8f03-fcd59087bb2b ro quiet splash
initrd /android-4.0-RC1/initrd.img
}

3. Save and run a grub-update

# sudo update-grub

I must admit the Grub 2 values are theoretical since I don’t have Grub 2 on the android device but i’m certain it should work like this. If not please leave a comment and I fix this workaround.

7 thoughts on “Android / Linux: Dualboot entries in /boot/grub/menu.lst

    1. I still don’t have grub2 on the android box and the hardware is EOL so might go away soon anyway.
      But the settings above for grub2 are from a current Ubuntu system just modified to match the android values. I’ll rate them as 99% reliable. If you try it and let me know how it worked I would appreciate it. If you have trouble let me know and I can help you through.

      1. Hi, I edited
        /etc/grub.d/40_custom
        adding the following lines
        menuentry “Android-x86” {
        set root='(hd0,*6*)’
        linux /android-4.0-RC*2*/kernel quiet root=/dev/ram0 androidboot.hardware=*eeepc
        *acpi_sleep=s3_bios,s3_mode SRC=/android-4.0-RC*2* SDCARD=/data/sdcard.img
        initrd /android-4.0-RC*2*/initrd.img}

        I found a lot of other different configurations, but they where too complicated and misleading. In grub2

        Then I issued
        sudo chmod +x /etc/grub.d/40_custom
        sudo update-grub

        Then I landed into android … and started wondering “Hey, but what’s the point :))?”

        2012/9/13 Disqus

  1. Hi, I edited

    /etc/grub.d/40_custom

    adding the following lines

    menuentry “Android-x86” {set root='(hd0,6)’linux /android-4.0-RC2/kernel quiet root=/dev/ram0 androidboot.hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-4.0-RC2 SDCARD=/data/sdcard.imginitrd /android-4.0-RC2/initrd.img}
    I found a lot of other different configurations, but they where too complicated and misleading. In grub2
    Then I issued
    sudo chmod +x /etc/grub.d/40_customsudo update-grub
    Then I landed into android … and started wondering “Hey, but what’s the point :))?”

    1. Thanks for letting me know.
      I believe to recall the when I used 40_custom it got overwritten by some container updates. I will check that and update the post accordingly

      1. Actually I had a Lubuntu 12.04 partition on sda (+swap), I purged grub-pc package via synaptic – then reinstalled it to make sure grub2 was in place correctly in mbr of boot disk.
        Then I gparted.
        Then I booted android from key, asking to install and pointing to empty partition I had created, but not letting android to edit grub (which is know to cause ..problems)

Leave a Reply