My first experience running Android-x86 7.1-rc1 on QEMU

4,327 views
Skip to first unread message

Alain Kalker

unread,
Jun 25, 2017, 2:10:06 PM6/25/17
to Android-x86
Hi all,

It's been a long time since I've tried running Android-x86 in an emulator, here's my experience with running Android-x86 7.1-rc1 on QEMU so far.

TL;DR:
- Perhaps remove '-sdl' option from `qemu-android` script, not all builds of QEMU support it.
- Live system runs very quickly and smoothly.
- Couldn't get shared 'data' directory to work, problem with 9p modules perhaps?
- Filesystem on data.img must be ext4, not ext2, for app updates to work.
- Had to use 'video=...' kernel commandline option to set custom resolution.

For this test, I used Void Linux x86_64 running on a box with a Core i7-4790 CPU @ 3.60GHz, with 8 GB RAM, QEMU version 2.9.0.
I downloaded android-x86-7.1-rc1.iso and android-x86-7.1-rc1.x86_64.rpm
from [1].
I managed to adapt the advice on running Android-x86 in QEMU from [2] somewhat (I think it applies to older versions) after I studied the `qemu-android` script in the RPM package.

= Live system

To boot it, I started out from the `qemu-android` script on [2], which I had to adapt somewhat with help from the `qemu-android` script in the RPM package.
In particular, I needed to remove the '-sdl' option from the QEMU command, because my build of QEMU doesn't support it (it has only the GTK+ GUI).
In the end, I used the following command:

qemu-system-x86_64 -enable-kvm -vga std \
-m 2048 -smp 2 -cpu host \
-soundhw ac97 \
-net nic,model=e1000 -net user \
android-x86_64-7.1-rc1.iso

After QEMU started, I chose the menu option "Live CD - Run Android-x86 without installation".
The live system booted very quickly, and I could install and run apps quickly and smoothly.

= Shared 'data' directory

Next, as an experiment, instead of installing to a disk image, I looked for a way to setup Android-x86 using a shared 'data' directory.
For this, I used the `qemu-android` script from the RPM package (which I extracted using `rpmextract` because Void Linux doesn't use RPM and doesn't come with an 'rpm' or 'alien' package to install it).
I used the following commands:

$ rpmextract android-x86-7.1-rc1.x86_64.rpm
$ mv android-7.1-rc1 ~/.local/opt/
$ OUT=$HOME/.local/opt/android-7.1-rc1
$ mv usr/bin/qemu-android $HOME/.local/bin/
$ mkdir $OUT/data

Again, I had to remove '-sdl' from the QEMU command line to allow it to start.
Finally, I ran:

$ sudo OUT=$OUT $HOME/.local/bin/qemu-android

QEMU started up, but did not boot Android-x86. In the debug shell, I used `mount`, command to check if the shared 'data' directory was mounted, but it wasn't. Also, `lsmod` didn't show any 9p modules loaded. Any help on why this didn't work is much appreciated.

= data.img disk image

Next, I tried using a disk image. To create one, I used the following commands, which I adapted from [2]:

$ rmdir $OUT/data
$ qemu-img create -f qcow2 $OUT/data.img 16G
$ OUT=$OUT qemu-android

I expected Android-x86 to not boot, because the disk image did not have any filesystem on it yet.
In the debug shell, I first had to figure out which block device matched the disk image, then I ran the command:

x86:/ # mkfs.ext2 -j -L DATA /dev/block/vdc

After quitting and restarting QEMU, Android-x86 booted, yay!
However, I could not install or update packages, I kept getting "error 963" from Google Play.
After some searching, I found out that I should format the disk image as ext4, not ext2, to make app install and update work without errors.
To do this, I had to run:

$ rm $OUT/data.img # just to be sure
$ qemu-img create -f qcow2 $OUT/data.img 16G
$ OUT=$OUT qemu-android

Back in the debug shell, I found out that this installation doesn't have a `mkfs.ext4` command, so I had to use the generic `mke2fs` and specify the filesystem type:

x86:/ # mke2fs -t ext4 -j -L DATA /dev/block/vdc

After quitting and restarting QEMU again, I could install and update apps without problems. Yay again!

= Custom screen resolution

Next, I tried changing the resolution of the Android display. I had no luck when trying any of the tips in [3], but after some searching, I found [4] and [5], which motivated to try and use 'video=1920x1080' kernel command line option.
After adding this option to the '-append ...' QEMU option, I was able to run Android-x86 in QEMU fullscreen, without ugly stretching and crisp fonts and graphics.

I hope that some of this long rant can be used to improve what are mostly documentation issues. Thanks to all for making this great project, keep up the good work!

Kind regards,

-Alain

[1]: http://www.android-x86.org/download
[2]: http://www.android-x86.org/documents/qemuhowto
[3]: http://www.android-x86.org/documents/uvesafbhowto
[4]: https://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg05306.html
[5]: https://fedoraproject.org/wiki/Display_resolution_of_Fedora_18_virtual_machines

Chih-Wei Huang

unread,
Jun 25, 2017, 10:19:07 PM6/25/17
to Android-x86
2017-06-26 1:07 GMT+08:00 Alain Kalker <a.c.k...@gmail.com>:
> Hi all,
>
> It's been a long time since I've tried running Android-x86 in an emulator, here's my experience with running Android-x86 7.1-rc1 on QEMU so far.
>
> TL;DR:
> - Perhaps remove '-sdl' option from `qemu-android` script, not all builds of QEMU support it.
> - Live system runs very quickly and smoothly.
> - Couldn't get shared 'data' directory to work, problem with 9p modules perhaps?
> - Filesystem on data.img must be ext4, not ext2, for app updates to work.
> - Had to use 'video=...' kernel commandline option to set custom resolution.
>
> For this test, I used Void Linux x86_64 running on a box with a Core i7-4790 CPU @ 3.60GHz, with 8 GB RAM, QEMU version 2.9.0.
> I downloaded android-x86-7.1-rc1.iso and android-x86-7.1-rc1.x86_64.rpm
> from [1].
> I managed to adapt the advice on running Android-x86 in QEMU from [2] somewhat (I think it applies to older versions) after I studied the `qemu-android` script in the RPM package.
>
> = Live system
>
> To boot it, I started out from the `qemu-android` script on [2], which I had to adapt somewhat with help from the `qemu-android` script in the RPM package.
> In particular, I needed to remove the '-sdl' option from the QEMU command, because my build of QEMU doesn't support it (it has only the GTK+ GUI).

Good. Thank you for pointing it out.

> In the end, I used the following command:
>
> qemu-system-x86_64 -enable-kvm -vga std \
> -m 2048 -smp 2 -cpu host \
> -soundhw ac97 \
> -net nic,model=e1000 -net user \
> android-x86_64-7.1-rc1.iso
>
> After QEMU started, I chose the menu option "Live CD - Run Android-x86 without installation".
> The live system booted very quickly, and I could install and run apps quickly and smoothly.
>
> = Shared 'data' directory
>
> Next, as an experiment, instead of installing to a disk image, I looked for a way to setup Android-x86 using a shared 'data' directory.
> For this, I used the `qemu-android` script from the RPM package (which I extracted using `rpmextract` because Void Linux doesn't use RPM and doesn't come with an 'rpm' or 'alien' package to install it).
> I used the following commands:
>
> $ rpmextract android-x86-7.1-rc1.x86_64.rpm
> $ mv android-7.1-rc1 ~/.local/opt/
> $ OUT=$HOME/.local/opt/android-7.1-rc1
> $ mv usr/bin/qemu-android $HOME/.local/bin/
> $ mkdir $OUT/data
>
> Again, I had to remove '-sdl' from the QEMU command line to allow it to start.
> Finally, I ran:
>
> $ sudo OUT=$OUT $HOME/.local/bin/qemu-android
>
> QEMU started up, but did not boot Android-x86. In the debug shell, I used `mount`, command to check if the shared 'data' directory was mounted, but it wasn't. Also, `lsmod` didn't show any 9p modules loaded. Any help on why this didn't work is much appreciated.

OOPS!
I just noticed 9p module is not enabled
in the kernel of 7.1-rc1.
It was enabled before. But apparently
I forgot it in the new kernel.
Thank you for the report.

> = data.img disk image
>
> Next, I tried using a disk image. To create one, I used the following commands, which I adapted from [2]:
>
> $ rmdir $OUT/data
> $ qemu-img create -f qcow2 $OUT/data.img 16G
> $ OUT=$OUT qemu-android
>
> I expected Android-x86 to not boot, because the disk image did not have any filesystem on it yet.
> In the debug shell, I first had to figure out which block device matched the disk image, then I ran the command:
>
> x86:/ # mkfs.ext2 -j -L DATA /dev/block/vdc
>
> After quitting and restarting QEMU, Android-x86 booted, yay!
> However, I could not install or update packages, I kept getting "error 963" from Google Play.
> After some searching, I found out that I should format the disk image as ext4, not ext2, to make app install and update work without errors.
> To do this, I had to run:
>
> $ rm $OUT/data.img # just to be sure
> $ qemu-img create -f qcow2 $OUT/data.img 16G
> $ OUT=$OUT qemu-android
>
> Back in the debug shell, I found out that this installation doesn't have a `mkfs.ext4` command, so I had to use the generic `mke2fs` and specify the filesystem type:
>
> x86:/ # mke2fs -t ext4 -j -L DATA /dev/block/vdc
>
> After quitting and restarting QEMU again, I could install and update apps without problems. Yay again!
>
> = Custom screen resolution
>
> Next, I tried changing the resolution of the Android display. I had no luck when trying any of the tips in [3], but after some searching, I found [4] and [5], which motivated to try and use 'video=1920x1080' kernel command line option.
> After adding this option to the '-append ...' QEMU option, I was able to run Android-x86 in QEMU fullscreen, without ugly stretching and crisp fonts and graphics.

Refer:
https://groups.google.com/d/msg/android-x86/xh65fvLqvtQ/MQn9y6JGAwAJ

> I hope that some of this long rant can be used to improve what are mostly documentation issues. Thanks to all for making this great project, keep up the good work!
>



--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Alain Kalker

unread,
Jun 26, 2017, 7:58:34 PM6/26/17
to Android-x86


On Monday, June 26, 2017 at 4:19:07 AM UTC+2, Chih-Wei Huang wrote:
2017-06-26 1:07 GMT+08:00 Alain Kalker <a.c.k...@gmail.com>:
> = Live system
>
> To boot it, I started out from the `qemu-android` script on [2], which I had to adapt somewhat with help from the `qemu-android` script in the RPM package.
> In particular, I needed to remove the '-sdl' option from the QEMU command, because my build of QEMU doesn't support it (it has only the GTK+ GUI).

Good. Thank you for pointing it out.
 
Glad to be of help :-)

> $ sudo OUT=$OUT $HOME/.local/bin/qemu-android
>
> QEMU started up, but did not boot Android-x86. In the debug shell, I used `mount`, command to check if the shared 'data' directory was mounted, but it wasn't. Also, `lsmod` didn't show any 9p modules loaded. Any help on why this didn't work is much appreciated.

OOPS!
I just noticed 9p module is not enabled
in the kernel of 7.1-rc1.
It was enabled before. But apparently
I forgot it in the new kernel.
Thank you for the report.
 
Thanks for the quick fix! I synced the repos, built and booted Android-x86, and shared 'data' gets mounted now. Android doesn't boot in this configuration, but I think that this is more of a general Android issue unrelated to Android-x86, perhaps due to the new security requirements or such.

I was wondering if for the kernel configuration you could perhaps do a `make kvmconfig` after doing the initial `make *_defconfig`? As far as I understand, this will take the existing '.config' file and merge it with the contents of 'kernel/kvm_guest.config'.
This way you can focus on updating the *_defconfig files for real hardware, and not have to worry about re-adding the 9p configuration after every kernel update.
I haven't tested this myself yet, first build of Android-x86 took quite some time, so any suggestions are very welcome.

> = Custom screen resolution
>
> Next, I tried changing the resolution of the Android display. I had no luck when trying any of the tips in [3], but after some searching, I found [4] and [5], which motivated to try and use 'video=1920x1080' kernel command line option.
> After adding this option to the '-append ...' QEMU option, I was able to run Android-x86 in QEMU fullscreen, without ugly stretching and crisp fonts and graphics.

Refer:
https://groups.google.com/d/msg/android-x86/xh65fvLqvtQ/MQn9y6JGAwAJ

Thanks for the link. I think it would be nice to document this in the Wiki.

Kind regards,

-Alain

Chih-Wei Huang

unread,
Jun 27, 2017, 2:31:57 AM6/27/17
to Android-x86
2017-06-27 7:58 GMT+08:00 Alain Kalker <a.c.k...@gmail.com>:
> On Monday, June 26, 2017 at 4:19:07 AM UTC+2, Chih-Wei Huang wrote:
>
>> OOPS!
>> I just noticed 9p module is not enabled
>> in the kernel of 7.1-rc1.
>> It was enabled before. But apparently
>> I forgot it in the new kernel.
>> Thank you for the report.
>
> Thanks for the quick fix! I synced the repos, built and booted Android-x86,
> and shared 'data' gets mounted now. Android doesn't boot in this
> configuration, but I think that this is more of a general Android issue
> unrelated to Android-x86, perhaps due to the new security requirements or
> such.

Ah, yes. Indeed.
SELinux and getxattr seem doesn't work on 9p.
I've pushed a workaround for it.

> I was wondering if for the kernel configuration you could perhaps do a `make
> kvmconfig` after doing the initial `make *_defconfig`? As far as I
> understand, this will take the existing '.config' file and merge it with the
> contents of 'kernel/kvm_guest.config'.
> This way you can focus on updating the *_defconfig files for real hardware,
> and not have to worry about re-adding the 9p configuration after every
> kernel update.
> I haven't tested this myself yet, first build of Android-x86 took quite some
> time, so any suggestions are very welcome.
>
>> > = Custom screen resolution
>> >
>> > Next, I tried changing the resolution of the Android display. I had no
>> > luck when trying any of the tips in [3], but after some searching, I found
>> > [4] and [5], which motivated to try and use 'video=1920x1080' kernel command
>> > line option.
>> > After adding this option to the '-append ...' QEMU option, I was able to
>> > run Android-x86 in QEMU fullscreen, without ugly stretching and crisp fonts
>> > and graphics.
>>
>> Refer:
>> https://groups.google.com/d/msg/android-x86/xh65fvLqvtQ/MQn9y6JGAwAJ
>
>
> Thanks for the link. I think it would be nice to document this in the Wiki.
>
> Kind regards,


Alain Kalker

unread,
Jun 28, 2017, 6:21:52 PM6/28/17
to Android-x86


On Tuesday, June 27, 2017 at 8:31:57 AM UTC+2, Chih-Wei Huang wrote:
2017-06-27 7:58 GMT+08:00 Alain Kalker <a.c.k...@gmail.com>:
> On Monday, June 26, 2017 at 4:19:07 AM UTC+2, Chih-Wei Huang wrote:
>
>> OOPS!
>> I just noticed 9p module is not enabled
>> in the kernel of 7.1-rc1.
>> It was enabled before. But apparently
>> I forgot it in the new kernel.
>> Thank you for the report.
>
> Thanks for the quick fix! I synced the repos, built and booted Android-x86,
> and shared 'data' gets mounted now. Android doesn't boot in this
> configuration, but I think that this is more of a general Android issue
> unrelated to Android-x86, perhaps due to the new security requirements or
> such.

Ah, yes. Indeed.
SELinux and getxattr seem doesn't work on 9p.
I've pushed a workaround for it.

Works like a charm. Thanks!

-Alain
Reply all
Reply to author
Forward
0 new messages