NEmu

Network Emulator for Mobile Universes

Tutorial - Setup an Android VFs

In order to build a virtual network with several Android virtual nodes, you may be interested in creating a customized root virtual file system what will be cloned after.

Configuration

First of all, you have to get an ISO image of Android. In this tutorial, we choose to use an Android x86 image which allows to activate the hardware acceleration, Ethernet connection and which is fully compatible with all standard and custom APK applications. Then, the NEmu script for your setup is this one:

InitNemu()

VHost('android', 
 hds=[EmptyFs('android4.img', size='1G', type='raw', format='ext3')], 
 nics=[VNic(model='pcnet')], cdrom='/tmp/android4.iso', display="sdl", 
 enable_kvm=None, vga="std", localtime=None, k='fr', m=512, cpu='core2duo')

VSlirp('slirp', net='192.168.0.0/24')

Link('android', 'slirp')

StartNemu()

WaitNemu('android')

StopNemu()

ExportFs('android4.img')

DelNemu()

The first line is the initialization of the NEmu session.

The VHost line is the configuration of our virtual machine, called android, in which we are going to perform our Debian installation. This virtual machine contains an empty virtual raw hard drive, called android4.img, of 1GB formatted in EXT 3. Our virtual node contains a single PCNET virtual network interface card, with a French keyboard, 512MB of RAM and an Intel Core 2 Duo processor. We choose to activate the KVM hardware acceleration in order to improve the performances of our virtual machine. The SDL library is used to display the window of the virtual machine. The localtime option enables a synchronization between the real and the virtual clock.

Then, we setup a VSlirp in order to enable an Internet connection on the sub-net 192.168.0.0/24.

Finally, we link the virtual node to the slirp.

That's all for the configuration !

The next lines are for:

At the end of the process, the new fresh installed virtual hard drive with our Android 4 will be located in the current directory.

And action !

First of all, we download an Ethernet compatible version of Android 4:

$ wget http://android-x86.googlecode.com/files/android-x86-4.0-RC2-eeepc.iso 
       -O /tmp/android4.iso

Then, we start NEmu:

$ nemu --file script.py

Now you can install your Android as a normal real machine setup; do not forget to install a boot-loader. When you will turn off the virtual machine, its virtual hard drive will be copied in your current directory. Then, the session will be deleted.