Monday, August 11, 2014

How to install Dual Boot Android x86 on PC KitKat 4.4 RC2 without USB or CD

Not that long ago after screwing up my android while fooling around with ZTE merit codes on my ZTE Z990g that was rooted with the ZTE avail, I screwed up my touchscreen calibration firmware and cannot figure out how to reinstall it, oops.  After figuring out how to get my rooted devices to work with android screencast on my computer so that it could be accessed, I than proceeded to try different techniques to unroot my android to see if there was any way to get into FTM mode.  Just for kicks, my SD card reader decided to take a dive, great, now I have an android, that is unrooted and can't do a thing until my new phone and new touchscreen comes in.

Anyways, while doing many searches on how to fix my issue while waiting, I discovered the world of installing the Android Operating system on the computer.  My oh my, this is so cool, had to try it out.  Well since Android is still in beta testing, it was unable to detect my my keyboard after getting past the "install to harddisk screen", grrr.  Tried it in Virtual Machine, way to slow, sheesh, if one wanted to go back in time and get that nostalgic feeling of installing windows 98 on a 486, why not do just that.  Okay so there had to be a way, and let me just say, it was easier than I thought.  There are a few ways I discovered, that one would not find in a search but had to know what they where searching for, search for all those little pieces and put them together, so I did just that, got Android KitKat running on my Desktop computer.  Now let me make it easier for you, in one Blog Post, just how to the same thing I did, without doing all those searches one how to do one thing only to have to put them all together.

There are a few ways this can be done, my preferable way is using a Linux operating system, since Android is a linux operating system, this technique is a little easier than if you are running Windows.  If using windows, it is probably a better idea to just use the steps to create an ext4 format on a USB stick, setup your bios settings to boot to USB stick as first or second boot option.  

For Ubuntu, things you will or may need:
  1. Ubuntu or Xubuntu live CD, 14.04 is the latest stable release
  2. Android x86 KitKat RC2 Iso
  3. Some type of unzip tool to extract your android x86 ISO to your harddisk, winzip - extraction tool already available if Ubuntu is already installed.
  4. Gparted - if you are already running Ubuntu and have a second hard disk or a area already partitioned off, then you can run the following commands:
sudo apt-get install gparted

sudo gparted
    If Ubuntu is already installed and you do not want to redo everything, but just want to create a new partition, there are a few work arounds.

    • Follow the steps using a USB Stick from gparted. 

    • Want mega space to run all kinds of Google Play APPS in AndroidX86 Kitkat but do not have any available partition, than a fresh install of Ubuntu is the best method. 

    • You could partition off the hard disk that Ubuntu is installed from using the method below through the live CD, but this may give you messy run around, causing issues with your boot.  

    • If you do decide to try to partition off your primary Windows or Ubuntu drive, from the Ubuntu Live CD:
                   a.  run Ubuntu Live CD

                   b.  unmount the linux-swap if Ubuntu
                   c.  right click on the primary partition and resize
                           d.  create a new primary partition from the unallocated space

                           e.  format the partition, ext4 is usually the safest way to go for
                                any  Linux based operating system.

                           f.  this could potentially cause problems with the Ubuntu boot
                               afterwards, if so, follow these instructions to repair the boot.

    As for using Gparted to partition off your Windows drive, not really sure, again, if in doubt use a USB stick.

    Burn your Ubuntu ISO to a CD, DVD or USB per instructions on the Ubuntu download link above.

    If you already have done the following Steps for installing Ubuntu/Xubuntu, skip down to the link below for instructions on how to manually install Android X86 below.

    Part One - getting ready for Android X86 KitKat!

    Make sure BIOS is setup to recognize the device you plan on using to Install Ubuntu from under boot options (USB or CD storage).  Each computer is different so you will have to reference your motherboard manual to find your settings.

    Insert your Xubuntu/Ubuntu CD/USB stick and turn on the PC, when finished loading, select Try Xubuntu/Ubuntu:
      When Ubuntu shell loads, click on the menu and open up your terminal:

      sudo gparted

      Gparted will now open, this is where you can partition your harddisk to suit your needs.  Lets say you have a 1.5 tb hard disk like me, this is how I setup my partitions.  For a fresh new install, you will need to right click on any partitions that are used and delete them, right click and delete until all the partitions are combined into one large unallocated space.
      Right click and delete unwanted partitions, you want to work with unallocated space.  If resizing, right click the partition you want to resize, create an extended partition then create a new ext4 partition.  This method is useful if dual-booting with windows.

      • Right Click on free space and create your an ext3 or ext4 partition, in the box that says "Free space following MiB" select how much you want to leave for whatever operating system or storage you are going to need following
      Optional: I'll show you later how to create an emulated SDCARD for Kitkat
      • Right click and again in the "Free space following MiB" set a number, if using for storage label storage, if using for your other OS skip this step.
      • Right Click, select new and create an extended partition than just select OK do not change any numbers.
      If your going to install windows just select OK no need to enter any values.
      • Right Click and create new in the new unallocated space, it will match the extended space above it, in "Free Space following MiB" enter a number for Linux Swap to match the amount of ram you have.  If you have 4gb of ram, then in the space "Free Space following MiB" enter 4000 for 4gb.  Under file system select ext 4 for Ubuntu or ntfs/fat32 for windows
      • Skip this step if going to install windows. Right click one last time and make your file system Linux Swap.

      This is how your final result should look
      Part Two: Setting up Android X86 4.4 without having to use the install method.

      • Right click on the Android-x86 and select "Extract Here"
      • Now you should see a folder with the same name as the Android-x86 ISO you just extracted.
      • In that folder all you need are the following four files:
        • initrd.img
        • ramdisk.img
        • kernel
        • system.sfs
      • Select just those four and copy them to the drive where android-x86 is going to run from and paste them into a folder called Android.  In the newly created folder Android create another folder called data.  The data structure should now be:
          • Android-x86
            • data
              • initrd.img
              • system.sfs
              • kernel
              • ramdisk.img
      There is a system folder in the picture above, this is because on the first boot of Android-x86, a system folder will be created automatically.
      • Open up terminal and enter the code:
      sudo nano /etc/grub.d/40_custom

      This is the following you will see:

      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.

      At the bottom, enter the following:
      <code>menuentry "Android-x86" {
      set root='(hd0,X)'
      Linux /Android/kernel quiet root=/dev/ram0 androidboot.hardware=generic_x86 acpi_sleep=s3_bios,s3_mode SDCARD=sda3 SRC=/Android
      initrd /Android/initrd.img}

      If you skipped the step for creating an emulated SDCARD, then just remove the line, SDCARD=sdaX.  If you did create a partition to use an emulated SDCARD, then below in the following command, <code>sudo fdisk -l</code> identify that partition and replace X with the number, mine is sda3.  As for the <code>set root='(hdX,X)'</code> this is determined as to which drive android is running from.  In terminal shell enter:

      sudo fdisk -l
      and the output will be, this is mine:

         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1   *        2048   204802047   102400000   83  Linux
      /dev/sda2       204802048   307202047    51200000    7  HPFS/NTFS/exFAT
      /dev/sda3       307202048  1906276351   799537152   83  Linux
      /dev/sda4      1906278398  2930276351   511998977    5  Extended
      /dev/sda5      1906278400  2912458087   503089844   83  Linux
      /dev/sda6      2912460800  2930276351     8907776   82  Linux swap / Solaris

      sda1 is where android is running from, so my format is - set root='(hd0,1).


      Hard Drive
      sda = (hd0,0)
      sda1 = (hd0,1)
      sda2 = (hd0,2)

      USB Stick
      sdb = (hd1,0)
      sdb1 = (hd1,1)
      sdb2 = (hd1,2)

      Now that you have created your menuentry for android, press 
      ctrl x
      press enter
      type the letter y for yes
      press enter

      Now in terminal type:
      sudo update-grub

      sudo reboot

      In the Ubuntu boot menu you will see Android-X86 at the bottom, scroll down, hit enter, sit back and enjoy Android on your PC! 


      1. I don't understand the part 2:
        system.cfg missed, i have system.sfs.
        what do we do with ramdisk.img?

        Thanks a lot.

        1. Sorry for the late reply, you are right, it was a misspelling on my part, it has been corrected. Should be system.sfs.

          Lets say you partition off 20gb of your hard disk just for Android-x86. Then in ubuntu you open up that partition in your file manager. Just create a folder called android-x86 and inside that folder make another folder named data, leave it empty. Outside that folder put the four files, system.sfs, kernel, initrd.img and ramdisk.img.

          In the post also update a picture how it should look.

      2. everything is working but in android it says system is read only. is there a way to make it read-write.

      3. /etc/grub.d/ 1: /etc/grub.d/ Û!/bin/sh: not found

        1. Same here. Did you fix it ?

      4.'s work for my pc..

      5. Does this work for UEFI systems?

      6. Hi. Very good write up. Please restore images. Many thanks.

      7. My BIOS is corrupted, I can't save any settings, so I can't boot from USB or CD, and everytime I need to login to my Ubuntu-MATE 14.04 I need to reset the CMOS with the jumper and all that.
        Anyway, I want to install Android on another HDD (/dev/sde) and I put the Android folder with the data and the .img .sfs and kernel files in a USB (/dev/sdd) so I could load it and then install it. I followed your instructions, my /etc/grub.d/40_custom looks like this:
        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.
        code menuentry "Android-x86" {
        set root='(hd3,1)'
        Linux /Android/kernel quiet root=/dev/ram0 androidboot.hardware=generic_x86 acpi_sleep=s3_bios,s3_mode SRC=/Android
        initrd /Android/initrd.img}
        (I had to delete the " symbols for this post)
        But when I get to GRUB menu, if I select Android it will take me to a blank screen with a message: "Press any key"
        I press any key and takes me back to GRUB's menu. What did I did wrong, can you please help me?

      8. Silly me, "code" is a HTML tag or something :D
        I deleted those tags and got this;
        error: can't find command 'Linux'.
        alloc magic is broken at 0xcfef8a60: 0
        Aborted. Press any key to exit._
        Any Ideas on how to solve this?

      9. I'm thinking it's in the hd3,1, HDD address? Not knowing your configuration I can't pinpoint. In terminal shell do

        sudo fdisk -l

        Paste the results.

        1. Disk /dev/sda: 160.0 GB, 160041885696 bytes
          255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
          Units = sectors of 1 * 512 = 512 bytes
          Sector size (logical/physical): 512 bytes / 512 bytes
          I/O size (minimum/optimal): 512 bytes / 512 bytes
          Disk identifier: 0x0007e202

          Device Boot Start End Blocks Id System
          /dev/sda1 * 2048 310503423 155250688 83 Linux
          /dev/sda2 310505470 312580095 1037313 5 Extended
          /dev/sda5 310505472 312580095 1037312 82 Linux swap / Solaris

          Disk /dev/sdb: 160.0 GB, 160041885696 bytes
          255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
          Units = sectors of 1 * 512 = 512 bytes
          Sector size (logical/physical): 512 bytes / 512 bytes
          I/O size (minimum/optimal): 512 bytes / 512 bytes
          Disk identifier: 0x0004eadc

          Device Boot Start End Blocks Id System
          /dev/sdb1 2048 295806975 147902464 83 Linux
          /dev/sdb2 295809022 312580095 8385537 5 Extended
          /dev/sdb5 295809024 312580095 8385536 82 Linux swap / Solaris

          Disk /dev/sdc: 80.0 GB, 80026361856 bytes
          255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
          Units = sectors of 1 * 512 = 512 bytes
          Sector size (logical/physical): 512 bytes / 512 bytes
          I/O size (minimum/optimal): 512 bytes / 512 bytes
          Disk identifier: 0x00034998

          Device Boot Start End Blocks Id System
          /dev/sdc1 * 2048 156301311 78149632 83 Linux

          Disk /dev/sdd: 8011 MB, 8011120640 bytes
          246 heads, 40 sectors/track, 1590 cylinders, total 15646720 sectors
          Units = sectors of 1 * 512 = 512 bytes
          Sector size (logical/physical): 512 bytes / 512 bytes
          I/O size (minimum/optimal): 512 bytes / 512 bytes
          Disk identifier: 0x0006e4bd

          Device Boot Start End Blocks Id System
          /dev/sdd1 * 2048 15646719 7822336 b W95 FAT32

          Disk /dev/sde: 20.0 GB, 20003880960 bytes
          255 heads, 63 sectors/track, 2432 cylinders, total 39070080 sectors
          Units = sectors of 1 * 512 = 512 bytes
          Sector size (logical/physical): 512 bytes / 512 bytes
          I/O size (minimum/optimal): 512 bytes / 512 bytes
          Disk identifier: 0x00087109

          Device Boot Start End Blocks Id System
          /dev/sde1 63 39070079 19535008+ 7 HPFS/NTFS/exFAT

        2. Currently, my USB is in /dev/sdd
          I want to install it in /dev/sde

      10. This comment has been removed by the author.

      11. I am getting the same error as EI-Asad. Linux command not found. Does this has anything to do with my partition not bieng in /etc/fstab

      12. A week ago decided to do the dual boot again. Was having problems with the dual boot myself.. Had installed Android to a USB stick. When I restarted the PC with the USB inserted, Android booted from my partition.

        Another words, if Android is installed on a partition of 80gb and a without grub, and a USB stick with grub, android will boot from the USB stick and load off the partition.

      13. How do I get Android to show up first in the GRUB menu?

      14. what are commands for android 6.0 cm version. i am getting errors

        Generating grub configuration file ...
        Found linux image: /boot/vmlinuz-4.4.0-47-generic
        Found initrd image: /boot/initrd.img-4.4.0-47-generic
        Found linux image: /boot/vmlinuz-4.4.0-45-generic
        Found initrd image: /boot/initrd.img-4.4.0-45-generic
        Found linux image: /boot/vmlinuz-4.4.0-21-generic
        Found initrd image: /boot/initrd.img-4.4.0-21-generic
        Found memtest86+ image: /boot/memtest86+.elf
        Found memtest86+ image: /boot/memtest86+.bin
        Found Kali GNU/Linux 2.0 (2.0) on /dev/sda1
        /etc/grub.d/ 1: /etc/grub.d/ in/sh: not found
        error: out of memory.
        error: syntax error.
        error: Incorrect command.
        error: syntax error.
        Syntax error at line 440
        Syntax errors are detected in generated GRUB config file.
        Ensure that there are no errors in /etc/default/grub
        and /etc/grub.d/* files or please file a bug report with
        /boot/grub/ file attached.


      My Blog List