Installing Android-x86 on a USB (not creating a Live USB)

androidfilesystemspartitionvirtual machinevirtualbox

I want to carry around an Android OS install on a USB so I can have a Google Authenticator with me everywhere I go since I don't own any mobile devices. The idea being that I can run Android through VirtualBox on the computers I use.

So I first partitioned my 8 GB USB drive using gparted into a fat32 file system for portability.

Then I created a VirtualBox disk associated with the fat32 partition on the USB drive at /dev/sdd1:

$ sudo su -
root@ckleinlx:~/.VirtualBox/HardDisks# VBoxManage internalcommands createrawvmdk -filename /root/.VirtualBox/HardDisks/usbdisk.vmdk -rawdisk /dev/sdd1
RAW host disk access VMDK file /root/.VirtualBox/HardDisks/usbdisk.vmdk created successfully.

Then I downloaded the android-x86 iso, and attached the iso and newly created usbdisk.vmdk as storage on a new VM in VirtualBox.

enter image description here

Then I boot up the VM and start the installer.

enter image description here

I formatted the partition again as fat32 and marked it Bootable, then started the install. When asked if I want to install GRUB I confirm, installation completes, and I select "Reboot", then shut down the VM.

At this point I remove the Android install disk from the VM, leaving only usbdisk.vmdk, which has Android installed on it now. However, when I boot, I just get this:

enter image description here

Android and grub are both clearly installed on the usb:

root@ckleinlx:~/.VirtualBox/HardDisks# mount /dev/sdd1 /media/usb
root@ckleinlx:~/.VirtualBox/HardDisks# ls /media/usb
android-4.3-test  grub

And here's what the USB stick looks like in gparted

enter image description here

Why can't Android be booted from this USB? Everything seems to be installed correctly, but virtualbox complains that it can't read the boot medium.

Best Answer

Here are a few things that I changed to make it work:

  1. Do not use the Android installer to format the drive.
  2. Create your VirtualBox vmdk disk from the device (/dev/sdd), not the partition (/dev/sdd1)
  3. Disable the USB devices on the VM: Settings -> USB -> USB Device Filters -> Uncheck all