[TIPS] Android-x86 bootloader: GRUB2, NeoGRUB, EasyBCD and Integration in Linux and Windows

18,195 views
Skip to first unread message

RetroAndMore

unread,
Mar 27, 2014, 2:53:01 PM3/27/14
to andro...@googlegroups.com
At least the images till 4.3 from Android-x86 I tested still used the GRUB legacy bootloader, I don't know why. I already posted this, but I have some new functions and so it's not neccessary to lick around to old posts. Google Code is unclearly enough. Of course, the settings are used from my Thinkpad x61t and it's older, so replace the entries with your system and image infos.


1. Integration into GRUB2 bootloader

This will be a guide to install Android to HD, and how to integrate it into another Linux GRUB2 bootloader. So an operating system using GRUB2 is neccessary. If you want to install Android to a hard drive, you'll need a EXT3 formatted partition, no matter if it's primary or logical. DON'T INSTALL GRUB from the Android installer, otherwise you can't boot only Android. Booting Android from hard drive from is much faster, but it has one disadvantage: It doesn't allow booting from another installation from an USB stick, because it always searches for the first Android folder, and this is always the one on the harddisk. But it is possible to install more than one Android installation on one partition, you just have to use other names for the Android root directory.

Actually after a fresh installation without Android GRUB can't boot Android at all, you'll need an operating system which uses GRUB2. These are the most operating systems, I'm using AROS, but all Ubuntu versions have it and other Linux distros, too. These are the entries for grub.cfg to make Android bootable:

submenu "Android x86 4.0 RC2" {

menuentry "Android x86 4.0 RC2" --class android --class linux --class os {
set root=
"(hd0,7)"
linux /android-4.0-RC2/kernel root=/dev/ram0 androidboot.hardware=thinkpad quiet
video=1400x1050 dpi=145 i915downclock=1 i915.powersave=1 usbcore.autosuspend=2 SRC=/android-4.0-RC2/
initrd
/android-4.0-RC2/initrd.img
}

menuentry "Android x86 4.0 RC2 text output" --class android --class linux --class os {
set root="(hd0,7)"
linux
/android-4.0-RC2/kernel root=/dev/ram0 androidboot.hardware=thinkpad video=1400x1050 dpi=145 i915downclock=1 i915.powersave=1 usbcore.autosuspend=2 SRC=/android-4.0-RC2/
initrd
/android-4.0-RC2/initrd.img
}
menuentry "Android x86 4.0 RC2 debug mode" --class android --class linux --class os {
set root=
"(hd0,7)"
linux
/android-4.0-RC2/kernel root=/dev/ram0 androidboot.hardware=thinkpad video=1400x1050 dpi=145 i915downclock=1 i915.powersave=1 usbcore.autosuspend=2 SRC=/android-4.0-RC2/ DEBUG=1
initrd
/android-4.0-RC2/initrd.img
}
}

This entry creates a submenu with the three entries to boot Android normal, with text output, or in debug mode. You have to change these settings if you are not using a Thinkpad:

"Android x86 4.0 RC2" - This is the name of the submenu displayed in GRUB.
"Android x86 4.0 RC2" - This is the name of the boot entries.
(hd0,7)-This is your drive/partition in which Android is installed. hd0,1 - hd0,3 are primary partitions, the first logical partition begins with hd0,5
/android-4.0-RC2/ - This is the path where Android is installed.
androidboot.hardware=thinkpad - This is your hardware model. You have to replace 'thinkpad' with your model, you could get the name from the file /isolinux/isolinux.cfg from your Android installation CD.
video=1400x1050 - I'm not sure if this option has effect, change the value to your displays native resolution.
dpi=145 - I'm also not sure if that option has effect, check if you find something about your displays density value. You also can skip this option. The standard 1024x768 displays of the Thinkpads have 106 dpi.

To modify your grub bootlist in Ubuntu, open a Terminal or press Alt-F2. Then enter gksu nautilus and your password, to get full read/write access. A new desktop window will pop up, and navigate to the /boot/grub/grub.cfg. Best make a copy of grub.cfg first, then open it and add the entries above. Fix the shown vales to your system, save the file. After a reboot one Android entry should appear. If you open it, a submenu with three entries will open, these are the boot entries. Press Escape to return to the main menu. If your bootloader is messed up or won't work at all, boot from the Live DVD, make the system read/writeable and check <ubuntu partition>/boot/grub/grub.cfg, or restore it from the backup.


2. Integrating Android into Linux

I prefer this method because you don't need another partition and you can share a larger Linux partition with Android. However, you can't access files on the Linux partitions, but you can modify Android from Linux. That makes editing much easier. I have ZorinOS 7 installed, it is based on Ubuntu 13. I have used the ext3 filesytem because there was no ext4 listed in the Android installer, maybe it wouldn't be compatible. I don't know about much about Linux. So install Android-x86 into your Linux partition, but don't format or install GRUB. Boot into Linux. Gain root access for your filesystem and copy (not move!) the Android folder to another place, I used my home folder. Now rename the uninstalled Android-x86 folder, f.e. using _bak. So you don't need another installation if your system isn't working, just copy the files back again. It's useful to rename it, so you can install a new Android-x86 without overwriting the older version. Now modify your GRUB2 entry of your Linux partition that the Android-x86 boot entries are available.


3. Integrate Android-x86 in the EasyBCD bootloader

EasyBCD is the one Windows 7 uses. I like it because it's very fast and it has a config program - although it has a few quirks. You need to have a Windows and the 100 MB Windows system partition. It is also possibly to use this partition better, I'll post it later. Install EasyBCD on your Windows and write the bootloader. This will overwrite the graphical Windows 8 bootloader, but that's better because EasyBCD is much faster. You'll find your Windows partitions, or use 'Add new entry'. Select 'NeoGrub' and click 'Configure. You'll get an editor window with the configuration entries for NeoGrub. It's wonderful because Lecgacy GRUB, GRUB2 and NeoGrub are all incompatible.

These are my entries:

# NeoSmart NeoGrub Bootloader Configuration File
#
# This is the NeoGrub configuration file, and should be located at D:\NST\menu.lst
# Please see the EasyBCD Documentation for information on how to create/modify entries:
# http://neosmart.net/wiki/display/EBCD/

default=2
timeout=6

title    Android-x86 4.3
root     (hd0,4)
kernel   /home/kernel quiet root=/home androidboot.hardware=android_x86 pcie_aspm=force usbcore.autosuspend=2 video=-16 SRC=/home quiet
initrd   /home/initrd.img

title    Android-x86 4.3 ramroot
root     (hd0,4)
kernel   /home/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 pcie_aspm=force usbcore.autosuspend=2 video=-16 SRC=/home quiet
initrd   /home/initrd.img


My partition is hd0,4, this it's the second logical partition in the extended partition of my MBR harddisk. I have used root=/home and root=/dev/ram0, both works. Save your entries in the editor, change the name and position in the EasyBCD editor and save the settings. Now try to reboot, if it works you are lucky, otherwise check all entries or take a look at the NeoGrub site for more information.


4. Integrate Linux in the EasyBCD bootloader

You also can integrate Linux in EasyBCD by 'AutoNeoGrub'. It maybe not work the first time, check out the extended options or take a look at the EasyBCD site. It is working, on my system I have a working multiboot system with Windows XP 64bit, Windows 7 Ultimate 64 bit, Windows 8.1 Professional 64 bit, ZorinOS 7.1 Ultimate 64 bit and Android-x86.


5. Make better use of the Windows 'System' partition

If you're installing a new Windows, it creates a 100 MB system partition for the bootloader. This wastes a full primary partition on a MBR harddisk. So use it simply for a second Windows! Go in the advanced hard drives settings of the Windows installation and create a partition for your Windows 7 or 8. It will automatically create the 100 MB system partition and the main Windows partition. Now delete the main Windows partition and resize the system partition. You can use a Windows XP for compatibility reasons, 35 GB will be enough. After this create your Windows partition again. Now don't install Windows 7 or 8, make a reset! Get your Windows XP CD and install, without formatting the partition again. Windows XP can't be installed on harddisks with 4K sectors from itself, newer Windows installers have to align the partition to 4K sector borders. Make sure that you have AHCI drivers for your system. Some mainboards can force-mount an USB stick as floppy for installing the drivers before the installation (press F6) or use WinSetupFromUSB, it can integrate boot drivers to an Windows XP installation. It's also possible to create USB boot sicks to install Windows Vista/7/8 on GPT partitions, and it's much faster than from DVD. After installing and quick configuring XP, install your newer Windows. It will integrate Windows XP as 'older version of Windows' and you can select the one you want to boot from. YOu can modify the boot entries with EasyBCD.

Easier uses for the resized system partition are are simple data partition, or as 'Swap Partition'. Windows usually puts the pagefile.sys on C:/, this wastes a lot of space, makes problems while defragmenting and if you want to make a block-based backup (f.e. via TrueImage) you have to turn it off all the way. So I'm using always swap partitions. They always have to be 1,5x the size of the real memory, so if you have 16 GB RAM, it must be about 24 GB. It's Windows standard with the 1.5x size. In Windows use the drive letters S: (Swap) or T: (Temp) for it. Set the pagefile in the virtual memory settings to this partition and disable it on partition C:/. Use as start and end size the full size, no automatic resizing. With tools like TuneUp Utilities you can use an option that specific drive letters aren't shown on the desktop. Also disable the 'no free drive space left' notification.

6. Use real Administrator as your account

If you're creating your Windows account, it is an administrator account, but not the full administrator account. But it is possible to use it as own account. On Windows XP you have to log off and press Ctrl-Alt-Del twice. You'll get the old text-based login window. Log in with name 'Administrator' and no password. Windows will begin with this account as it is just created, so it will display the Windows tour and so on. Create yourself a password, and delete the account you've create during the installation. Check out the net how you can do this. In Windows 7 and 8 this works a bit different: Go to 'Computer', right-click and use 'Manage...'. Select there users and groups. There is your account, 'Guest', and 'Administrator'. Click on it, and you'll see that it is not active/hidden. Make it active, log out and log in as Administrator. You can delete your account from this. In Windows 8 it works the same, but - it's incredible - you can't start apps in Administrator mode, not even Internet Explorer. It also installs much less Apps by default. YOu can use these registry entries to allow starting Apps as administrator:

Allow starting Apps as Administrator:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"FilterAdministratorToken"=dword:00000001


Deny starting Apps as Administrator:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"FilterAdministratorToken"=dword:00000000


you can save them directly as .reg files to integrate them into the registry. I've tested this successful on Windows 8.1 Professional 64 bit.


So, that's a lot of stuff. Check out what you need.

Greets, RAM.

Vaidotas

unread,
Mar 27, 2014, 4:07:27 PM3/27/14
to andro...@googlegroups.com
Any hints for booting Android on 32-bit UEFI systems? It would be great to boot Android without messing with Windows partitions and primary hard drive. Would it be possible to set up booting Android from external USB hard drive?

RetroAndMore

unread,
Mar 27, 2014, 6:04:17 PM3/27/14
to andro...@googlegroups.com
I'm not sure if it's possible at all. At least you can't combine a 32bit UEFI Windows with a 64bit UEFI Windows, because the 64bit UEFI Windows needs a GPT formatted hard disk. A 32bit UEFI Windows doesn't support GPT. MBR is still the most compatible mode. The partition system is not the best, and Windows isn't even able to create logical partitions in the extended partition, you have to use a tool like GParted for this. But it is possible. My multiboot uses this configuration on an 1 TB hard disk:

 1 - Primary - Windows XP Professional x64 Edition
 2 - Primary - Windows 7 Ultimate 64bit
 3 - Primary - Windows 8.1 Pofessional 64bit
 4 - Extended Partition
 5 - Logical - Empty partition
 6 - Free Space, used by AROS operating system with own RDB partition block and two partitions
 7 - Logical - ZorinOS 7.1 Ultimate 64bit & Android-x86
 8 - Primary - ZorinOS Swap Patition
 9 - Logical - Data partition
10 - Logical - Windows Swap Partition 1
11 - Logical - Windows Swap Partition 2
12 - Logical - Windows Swap Partition 3


It looks weird, check it out: http://www.bilder-hochladen.net/files/big/c4q7-g4-1728.png

Notice: The AROS partition and the ZorinOS Swap partition (16 GB) are listed as Primary, although they are in the Extended partition and they should be logical.

My experiences with MBR bootblocks aren't bad, although I'm used much better ones. The best one is the RDB (Rigid Disk Block) which is used by the Amiga, AROS and MorphOS. It was already available in 1988 and is probably more advanced than GUID, except that it was originally only designed for harddisks up to 4 GB. These are the possibilites:

- Max size 4 GB, more with a patch. I'm using 40 GB without problems.
- uses track/sector/cylinder format of harddisks, autodetection possible.
- unlimited number of partitions, everyone is bootable, with different boot priority
- different filesystems could be loaded into the RDB and used in every partition
- specific flags for bootable, automount and more
- specific settings for transfer and masking data
- fixed partition names (not volume names!) with up to 30 characters!

Not bad for a partition block that was already available in 1988. The two most interesting functions that every partition can be bootable with different boot priority, it reaches from +127 to -128. Boot priority +5 is the first floppy, 0 is the hard drive, the second floppy is -10. So if no floppy disk was inserted, the next lower boot prioity was booted. Since AmigaOS 2.0 you can enter the Early Startup Menu and can choose the bootable device you want. It's also possible to boot without startup-sequence, so you simply get a AmigaDOS shell after booting. That's ideal for error checking.

The other great function that every partition can have a different, fixed partition name. Today this is rather simple made by the OS, Unix/Linux/Mac uses partition entries like dev/sda0,0 or similar, the original MS-DOS used only letters, like C:/ D:/ etc. Since Windows NT it was possible to use fixed drive letters, but in MS-DOS (which was standard in Amiga times) this was absolutely weird: Imagine you have a partition table like this:

IDE Primary Master (PM)

PM1 - Primary C:/
PM2 - Primary D:/
PMX - Extended Primary
PM3 - Logical E:/


Now you'll add a partition with this partition to Secondary Master (SM):

SM1 - Primary C:/
SMX - Extended Secondary
SM2 - Logical D:/
SM3 - Logical E:/


This will result in the following configuration:

PM1 - Primary C:/
SM1 - Primary D:/
PM2 - Primary E:/
PMX - Extended Primary
PM3 - Logical F:/

SMX - Extended Secondary
SM2 - Logical G:/
SM3 - Logical H:/


That seems weird, but can also happen on modern systems if you change hard disks to another SATA port, a drive would change from /dev/sda0,0 to /dev/sda1,0. On all Amiga-based operating systems a partition always uses the fixed name defined in the RDB. Typically, the first hard disk is DH0: (Device Hard 0) and the volume name is Workbench:. So it is possible to access a file by DH0:c/dir or Workbench:c/dir.  Because the Amiga has fixed partition names, it could be problematic if you add another harddisk with a partition DH0: But AmigaOS has a solution for this: It will be renamed temporary to DH0.1: ! The number is used depending on the position the device is connected. Typically was SCSI used, which allows 7 devices, unit numbers 0-6, unit 7 is the controller. If you have your normal hard drive connected on scsi unit 0, it is DH0: If you are connecting a second drive to scsi unit 1, it will be renamed to DH0.1: If you add another drive, it will be renamed to DH0.2: But AmigaOS has more features: The first SCSI controller (external on A1000, A500, A2000, CDTV and CD32, internal on all other Amigas) is called scsi.device. If you add another card which has a contoller with the name scsi.device, it'll be renamed to 2nd.scsi.device, 3rd.scsi.device, 4th.scsi.device and so on. Amazing for an more than 25 year old operating system which would be called '2 MB shared memory' today...

Greets, RAM.

fuzzy7k

unread,
Mar 28, 2014, 11:37:40 AM3/28/14
to andro...@googlegroups.com
A few tips & scripts to add:

1. Integration into GRUB2 bootloader
...
To modify your grub bootlist in Ubuntu, open a Terminal or press Alt-F2. Then enter gksu nautilus and your password, to get full read/write access. A new desktop window will pop up, and navigate to the /boot/grub/grub.cfg. Best make a copy of grub.cfg first, then open it and add the entries above. Fix the shown vales to your system, save the file. After a reboot one Android entry should appear. If you open it, a submenu with three entries will open, these are the boot entries. Press Escape to return to the main menu. If your bootloader is messed up or won't work at all, boot from the Live DVD, make the system read/writeable and check <ubuntu partition>/boot/grub/grub.cfg, or restore it from the backup.


It's best to modify grub menus in /etc/grub.d/##_xxxx. Modifying grub.cfg directly will probably lead to your changes being wiped out the next system update. They provide 40_custom & 41_custom, but I prefer to make my own so that the package manager has no chance of overwriting my menu's. 40_custom is for embedding menu's into grub.cfg. 41_custom sources custom.cfg. The files must be executable to be picked up when grub updates, i.e. chmod +x ##_xxxx. To disable a file, simply chmod -x that file. I do this for most of mine, expecially 20_linux_xen. This speeds up the update process. These are what mine look like:

33_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.

set timeout=4

if [ -n "${boot_once}" ] ; then set timeout=0 ; fi
---------------------------------------------

/etc/grub.d/44_custom:------------
#!/bin/sh
cat <<EOF
source \$prefix/android.cfg;
source \$prefix/gentoo.cfg;
source \$prefix/pxe.cfg;
source \$prefix/other.cfg;
EOF
---------------------------------------------

The first one sets the timeout to 4 seconds, but short circuits the timeout if I use grub2-reboot. The second lets me keep static menu files in /boot/grub/. That way, I can edit the menu without having to run grub-update, or lose my menu's when my package manager runs grub-update. Most users can just use /boot/grub/custom.cfg, which should be sourced by 41_custom.

You may also want to edit /etc/default/grub and change the default to "saved", which lets you use grub2-reboot. This allows you to reboot into Android without waiting for the grub menu to appear.

GRUB_DEFAULT="saved"

Now, run grub-update, or if it doesn't exist,
grub2-mkconfig -o /boot/grub/grub.cfg
grub2-install /dev/sd?

Here is an example script I use to reboot into Android, needs updated for systemd.
---------------------------------------------
#!/bin/sh
sudo grub2-reboot "Android"
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart || sudo reboot
---------------------------------------------

And to help that, the following sudo file.
/etc/sudoers.d/10_power----------
Cmnd_Alias      POWER = /sbin/shutdown,/sbin/reboot,/sbin/restart,/usr/sbin/pm-suspend
Cmnd_Alias      GRUB = /sbin/grub2-reboot,/sbin/grub2-set-default

%users          ALL = (root) NOPASSWD: POWER, GRUB
---------------------------------------------



Easier uses for the resized system partition are are simple data partition, or as 'Swap Partition'. Windows usually puts the pagefile.sys on C:/, this wastes a lot of space, makes problems while defragmenting and if you want to make a block-based backup (f.e. via TrueImage) you have to turn it off all the way. So I'm using always swap partitions.
 
They always have to be 1,5x the size of the real memory, so if you have 16 GB RAM, it must be about 24 GB. It's Windows standard with the 1.5x size. In Windows use the drive letters S: (Swap) or T: (Temp) for it. Set the pagefile in the virtual memory settings to this partition and disable it on partition C:/. Use as start and end size the full size, no automatic resizing. With tools like TuneUp Utilities you can use an option that specific drive letters aren't shown on the desktop. Also disable the 'no free drive space left' notification.

Not true, This was a guidline when RAM was expensive. Honestly, why would a computer that had 512MB of RAM need more swap space than one that had 64MB of RAM. Only if you are talking apples & oranges. Nowadays, swap mostly just slows your computer down, just like I'd slow down if I used a walker. I turn it off completely on any computer that has 2GB of RAM or more. The one exception I have to this is video editing or other tasks that need a lot of RAM. In the computer that I build Android on I have 6GB of RAM, but a 30GB swap partition. Swap's only purpose is stability, and I like stability, but not if it's going to slow me down for no reason.

RetroAndMore

unread,
Mar 28, 2014, 12:47:49 PM3/28/14
to andro...@googlegroups.com
I only said that it's standard, not if it's useful or neccessary. The topic is the possible use of a swap partition, not disabling the swapfile.

A swapfile is not completely unneccessary, especcially on 32 bit systems. Not all users have switched to a 64bit Windows with maxed-out RAM. A 32bit Windows does need virtual memory, because it can only access 3 GB RAM, systems with onboard graphics need graphics memory, too. 32bit Windows programs still have a limit of 2 GB RAM, even in a 64bit system. And there are much more 32bit programs available than 64bit ones. The virtual memory has changed, Windows 7 64bit sets 12 GB virtual memory as default on a system with 8 GB RAM, Windows 8.0 64bit uses by default about 4.8 GB virtual RAM. Don't know why, either because it is not neccessary, or the use of Apps should be preferred before the use of real programs.

No matter how it is, I'm setting a virtual memory partition with 1,5x of the real RAM in every case. Simply because it was all the time so. The harddisks are so cheap and big, that doesn't matter. Users with a SSD boot partition and a real hard drive can use this method with the swap partition: Create the swap partition on the real hard disk, that saves drive space and write accesses on the SSD. It doesn't matter if this may be slower, a better use of the SSD would be more important.

I'd be interested how OS X realizes it's virtual memory: On my system with 4 GB RAM it uses actually 56,75 GB VM... And I already hard higher values!

グエントゥアンラン

unread,
Jan 10, 2022, 10:02:16 AM1/10/22
to Android-x86
I think problem is chang hd0 , msdos x (with x is 1 ; 2 ; 3  is the partition android installed ) to hd0, gpt x

Vào lúc 23:47:49 UTC+7 ngày Thứ Sáu, 28 tháng 3, 2014, RetroAndMore đã viết:
Reply all
Reply to author
Forward
0 new messages