header image
 

How to install Android x86 4.4 RC2 on Hyper-V – Part 1: Install

[UPdate]

This Post has been updated on 2015 for the Android x86 R2 which now natively supports Hyper-V, see here:

http://luisrato.azurewebsites.net/2015/01/02/how-to-install-android-x86-4-4-r2-on-hyper-v-part-1-install-jan-2015/

This post is maintained for future reference.

[/update]

Hi there folks,

Cloud adoption is moving surprisingly fast, with the so called strategy “mobile first, cloud first” I am frequently challenged to demo different business scenarios with Office 365 and Microsoft Azure services being consumed across multiple devices.

As enterprise customers are getting immersed into CYOD/BYOD policies I need to do showcases with different OS’s, so I have a dilemma, I need an additional non-Windows OS/Device but I don’t want to buy one.

With iOS I would need Apple devices – not an option, with Android I have Bluestacks for Android emulation which is a bit intrusive for my Laptop OS/Hyper-V Host or I can run a x86 ported version of Android on a VM, I prefer the latest.

I have already done this exercise before with Android 4.3 Jelly Bean, it has limitations and is a bit unstable and with Android 4.4 (KitKat) RC2 there are a lot of issues being addressed.

If you want to run Android 4.4 x86 RC2 on Hyper-V you will probably struggle a lot because of the Virtualization modules are not being loaded by default, to make the installation possible we need to accomplish some advanced tasks, even though if you follow the steps as described here there’s no room for failure.
Android x86 4.4 RC1 release note
Android x86 4.4 RC2 release note

 

Part 1: How to install Android x86 4.4 RC2 on Hyper-V: Install

– Phase 1: Download Android x86 4.4 and prepare a VM to run it
– Phase 2: Install Android x86 4.4 on a VM
– Phase 3: Loading Hyper-V modules permanently

 

Part 2: How to Install Android x86 4.4 RC2 on Hyper-V: Configuration, Screen resolution and Network

– Phase 4: Run and Configure Android x86 for the first time
– Phase 5: Advanced settings – Screen resolution
– Phase 6: Advanced settings – Network configuration

 

Phase 1: Download Android x86 4.4 RC2 and prepare a VM to run it

1. Download Android ISO: http://www.android-x86.org/releases/releasenote-4-4-rc2

 

Android Live and Installation ISO
Version: 4.4 RC2 (KitKat-MR1 4.4.2 release)
File name: android-x86-4.4-RC2.iso
Size: 348.1MB
SHA1: 3b7acd23d3feb87ed13a2c5f489ea1a3f254f809

2. Open the Hyper-V Manager to Create a Virtual Switch for your Virtual environment Network

On the right pane Click “Virtual Switch Manager

Create an “Internal” or “External” Virtual Switch depending on your network needs

3. On the Hyper-V Manager create a new Virtual Machine and Virtual Hard Disk:

On the right-pane Actions menu Click “New” –>Virtual Machine

On the New Virtual Machine Wizard –> Next

Define the Machine Machine Name “Android44” and the desired location of the Virtual Machine configuration files

If your are running a Windows 8.1 or Windows Server 2012 R2 host Select the Virtual Machine “Generation 1

Set the Memory size “1024” MB (add more if needed) and enable “Use Dynamic memory for this Virtual Machine” by ticking the Checkbox

Select the Virtual Switch Network (I will use my “External” vSwitch)

Create a Virtual Hard Disk (default: differential) with no more than “8GB” (should be enough…)

Select “Install Operating System from a Boot CD/DVD” and Select the Android “image file (ISO)”

Review the VM configuration and click “Finish” to complete the VM creation

 

Phase 2: Install Android x86 4.4 RC2 on a VM

1. Start the VM and on the Boot menu select “Installation – Install Android-x86 to harddisk

install

2. After boot Press [ENTER] on the default option “Create Modify partition

install1

3. As mentioned before the Hyper-V Storage driver (module “hv_storvsc”) is not loaded by default on the build Android 4.4 RC2, so when you click “OK” to create the partition the cfdisk (Linux partition editor) will fail to access the HDD and you’ll see the following error message:

FATAL ERROR: Cannot open disk drive
Press any Key to exit cfdisk

Press any key to exit the black error screen.

install2

4. On the next screen we are informed that the Installation failed.

To fix this we need to load the Hyper Storage module manually from the command Shell, to get there press [CONTROL] + [ALT] + [F2].

install3

5. On the Command Shell type the following to load the Hyper-V Storage Module “hv_storvsc

# modprobe storvsc

install4

Now press [CONTROL] + [ALT] + [F1] to exit command shell and return to the installation prompt

6. Back to the Installation failure message make sure you select “Retry” and press [ENTER] key

install3

7. You will be presented with “Choose Partition” screen, now you can select “Create/Modify partitions” and press “OK

install1

8. On Cfdisk partition configuration select “New” and next select “Primary

install5

install6

9. Confirm the Volume size (e.g 8587.20MB) and mark the Partition as “Bootable” through the menu options

install7

install8

10. Select “Write” and confirm “yes” to write the partition table to disk and select “Quit” to complete

install9

install10

11. Select the new partition installation partition “sda1” and the File system format “ext3

install11

install12

12. Confirm the partition format “Yes” and confirm the GRUB boot loader install with “Yes

install13

install14

13. Confirm the read-write directory with “Yes” and wait a few seconds for the installation to complete.

install15

14. Following the last step you will see a screen confirming that the installation was successful.

If you  select the option “Run Android-x86” it will fail because the Hyper-V modules are not preloaded by default. We need to make some permanent changes so that Hyper-V modules are loaded every time you boot your VM.

install16

Shut down the VM through the Hyper-V Manager console.

Phase 3: Loading Hyper-V modules permanently

 

If we attempt to boot the VM after the installation it will fail because the Hyper-V modules are not preloaded by default.

For reference, here is the list and location of each Hyper-V module/driver:

hv_vmbus: Hyper-v virtualization driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_vmbus.ko

hv_balloon: Hyper-v Dynamic memory driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_balloon.ko

hv_utils: Hyper-v integration services
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_utils.ko

hv_storvsc: Hyper-v Storage Syntethic driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/scsi/hv_storvsc.ko

hv_netvsc: Hyper-v Network Syntethic driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/net/hyperv/hv_netvsc.ko

hid_hyperv: Microsoft Vmbus HID-compliant Mouse
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hid/hid-hyperv.ko

 

On the following steps we will make changes on the ‘init’ file so that Hyper-V modules/drivers are loaded in Kernel.

 

1. Boot the VM with the iso image loaded and select the option “Live CD – Debug mode” so that we get a command shell to execute the whole process.

permanent

2. On the Live CD Debug mode command shell we will load the Hyper-V Storage module “hv_storvsc” so that we can access our VM HDD and make permanent changes. For that execute the following command:

modprobe hv_storvsc

permanent1

3. Navigate to a writable folder and mount the Virtual Hard disk partition:

# cd data/
# mkdir mnt
# mknod sda1 b 8 1
# mount sda1 mnt

4. We will make a backup of initrd.img just in case we mess up with it and decompress all the content to a temporary directory:

# cp mnt/android-4.4-RC2/initrd.img initrd.img.bak
# mkdir initrd
# cd initrd/
# gunzip -c ../mnt/android-4.4-RC2/initrd.img | cpio -i

5. Copy all the required Hyper-V modules/drivers from the Live CD to the temporary initrd directory:

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_vmbus.ko .
# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_balloon.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_utils.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hid/hid-hyperv.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/net/hyperv/hv_netvsc.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/scsi/hv_storvsc.ko .

 

6. We need to install the Hyper-V loadable modules in the running Kernel by using insmod for each Hyper-v driver. We can do this by editing the ‘init’ file.

You have two options to do this, we can use the ‘sed’ tool to append the information on the ‘init’ file or we can use the ‘vi’ editor to edit the ‘init’ file directly.

 

Option 1: Using ‘sed’ to append each Hyper-v loadable module:

# sed -i -e ‘118i\insmod hv_vmbus.ko’ -e ‘118i\insmod hv_storvsc.ko’ -e ‘118i\insmod hv_netvsc.ko’ -e ‘118i\insmod hv_utils.ko’ -e ‘118i\insmod hv_balloon.ko’ -e ‘118i\insmod hid-hyperv.ko’ init

We need to load each module just before the line ‘echo –n Detecting Android-x86…’, on this build Android x86 4.4 RC2 the line just before that is the number 118, on future or prior builds that could be different, make sure you verify that and change accordingly if you are not running this build.

After running the above command with ‘sed’ if you edit the init file (vi init) you will notice that starting on the line 118 we have appended each Hyper-v module driver, here is the output:

permanent3

Option 2: Using ‘vi’ editor to add each Hyper-v loadable module:

Vi editor is old school stuff from the early days of Unix. I will just provide the required steps to use it for this purpose.

Start editing the ‘init’ file with the following command:

vi init

With the cursor keys move down to line 118 which should be just before the line ‘echo –n Detecting Android-x86…’. See the print screen:

permanent2

Now that you are on the line 118 do the following:

Press the [ESC] key to make sure you are on vi command mode.

Press the [o] key to add an additional line (like pressing the Return key on a normal text editor) and add the following text:

insmod hv_vmbus.ko
insmod hv_storvsc.ko
insmod hv_netvsc.ko
insmod hv_utils.ko
insmod hv_balloon.ko
insmod hid-hyperv.ko

Press the [ESC] key to exit from edit mode and go to command mode.

Type the following [:wq]     -> Just what’s between brackets []

 

Other useful Vi modes (should be enough to edit files):

[ESC] Vi command mode (also stops editing the file)
[i] Insert before cursor
[dd] delete current line
[:q] quit as long as there are not changes
[:q!] Force quit and discard changes
[:wq] or [:x] Write changes and quit

 

Vi full Cheat Sheet: http://www.lagmonster.org/docs/vi.html

7. Now we need to recreate the initrd image with all Hyper-v drivers included.

# find .| cpio -H newc -o -v | gzip -9 -c > ../mnt/android-4.4-RC2/initrd.img

 

8. Unmount the Virtual Hard disk partition

# umount ../mnt

 

9. Shutdown the VM through Hyper-V Manager

 

This completes the Part 1 of “How to install Android x86 4.4 RC2 on Hyper-V”. You can access the “Part 2: How to Install Android x86 4.4 RC2 on Hyper-V – Part 2: Configuration, Screen resolution and Network”.

R-Tape Loading error,
Luís Rato

 

~ by lrato on June 30, 2014.

Hyper-V, Linux

10 Responses to “How to install Android x86 4.4 RC2 on Hyper-V – Part 1: Install”

  1. Congratulation ! You have succeeded to bypass HDD fatal error 😀

  2. hi
    mount sda1 mnt gives Error can’t find souch directory
    have any idea to fix it ??

  3. hi I’m using a Surface Pro 3, when I hold ctrl+alt+f2 it dosen’t do anything it won’t open the command shell and don’t know why. What can I do??…

  4. Helpful, thanks. I do somehow seem to have got Android running, but not sure all is well. (NOTE: I am using the android-x86-4.4-r1 release from August)

    1.At the instruction “modprobe hv_storvsc” I get “modprobe: module hv_storvsc not found in modules.dep”. What am I doing wrong?

    2. At the instructions “# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_vmbus.ko .” I get “can’t stat ‘/system/lib/modules/3.10.40-android-x86+/kernel/drivers/hv/hv_vmbus.ko’ : No such file or directory” Should the 3.10.40 or something change if I am using a later release? Or is it simply because the error I get at #1 is affecting everything after it?

    It’s making my brain work and using some rusty old skills I used to have, so thanks for that 🙂

    • To clarify: I can start Android, sign in, load apps, etc. But I have no way of waking the VM up if it goes to sleep and none of the User data is persistent (I have to sign in each time I start the VM). Obviously I can get to the Dev Tools but not sure how I get to a command prompt from those.

  5. There is known issue with Suspend and resume on Android x86.

    Known issues
    •Suspend and resume may have problems on some systems.
    •The installer can’t format ext3 filesystem.
    •Bluetooth isn’t stable.

    http://www.android-x86.org/releases/releasenote-4-4-r2

  6. This was a huge, huge help. Thanks!

Leave a Reply




 
%d bloggers like this: