[Galaxy S II General] Akez42:
Hello all.

I've been messing a fair amount with android recently and have been able to get Windows ME running on my Galaxy S2.

Now before you start getting excited, it is not perfect. It is frustratingly slow and buggy, although I have not had much trouble actually running the OS itself.

I would just like to point out that I am still a novice and there are most likely various easier/faster ways of doing this process, but this guide does require a moderate to large amount of experience of using Linux's Terminal.

This guide is written for Windows ME because it was more usuable than XP and was the only other version I had, but I was successful in XP booting up. Will try to add videos!

I know the image looks like a monitor, so I will take another picture when I get chance.

Note: I take no responsibility for any damage caused by my walkthrough as you are doing it at your own free will.

Now for the walkthrough. These are the steps I took in order to get this working:

Follow this guide to installing Backtrack 5 on your Galaxy S2 (Thanks to DooMLoRD & anantshri for the work they put into porting Backtrack from the X10 version)

You will need to re-size the Backtrack image by going into linux on your Desktop or Laptop, creating a new image and copying the Backtrack files over to the new image.

Navigate to the directory of bt.img (Backtrack image) in linux using the Terminal then use the commands below (anantshri provided them in another post):

Note: This requires 4GB of space (cannot create a larger image as the FAT file system only allows a maximum filesize of 4GB)

Note 2: I used a Backtrack 4 to do the below, so if you use Ubuntu or similar, you may need to add "sudo" to the start of each line just to make sure it works.

dd if=/dev/zero of=bt1.img bs=1M count=4000
losetup /dev/loop2 bt1.img
mkfs -t ext2 /dev/loop2
mkdir BT
mount -o loop bt.img BT
mkdir BT1
mount -o loop bt1.img BT1
cp -f -R BT/* BT1/
umount BT1

From there, you will need to copy that new image file over to your phone/sdcard, making sure you rename bt1.img to bt.img.

Now load up Backtrack on your phone and from within it, download Glib-2.0 (or 2.24.2 here) and extract the files.

Open Terminal and navigate to the new Glib then type the following commands:

./configure
make
make install

Now download Qemu 0.15.0 and extract it.

In Terminal, navigate to the Qemu directory and, like above, type the following commands (This can take a while and your phone can get quite warm so you could continue to the next step):

./configure
make
make install

Assuming there were no errors, Qemu should now be set up on your system (or you are waiting for it to finish installing). Either way, now would be a good time to create the Windows ME image for use with Qemu.

In a Linux OS of some sort on your Desktop or Laptop (I used Ubuntu), run the command "sudo apt-get install qemu". This will download and install Qemu onto your linux system.

With Qemu installed, run the following commands (ref. here) to create an image:

qemu-img create -f qcow2 winme.img 3G

if you have a cd image on your system:
qemu -m 256 -hda winme.img -cdrom winme.iso -boot d

or if you have the cd in the drive:
qemu -m 256 -hda winme.img -cdrom /dev/cdrom -boot d

The above commands will create the winme.img file to store Windows ME, and will then boot up that image so that you can install the OS. Go ahead with installing the OS and once finished, copy that to the same directory as the bt.img on your system.

Like earlier, we will be creating an image to store the files. Do the following commands in linux terminal and to copy the files over:

Note: You will need another 2GB of space free to create the below image (this goes for the phone you are copying it to as well)

dd if=/dev/zero of=btextras.img bs=1M count=2000
losetup /dev/loop3 btextras.img
mkfs -t ext2 /dev/loop3
mkdir BTExtras
mount -o loop btextras.img BTExtras
cp btextras.img BTExtras/
umount BTExtras

Now copy btextras.img over to the same directory as the bt.img on your phone.

You will now need to edit the startbt and stopbt scripts in that same folder.

Add the following lines to startbt:

Directly after line 15: "$bboxpath mknod /dev/block/loop253 b 7 253"
Directly after line 18: "$bboxpath losetup /dev/block/loop253 $kit/btextras.img"
Directly after line 21: "$bboxpath mkdir $mnt/extras"
Directly after line 22: "$bboxpath chmod a+rwx $mnt/extras -R"
Directly after line 23: "$bboxpath mount -t ext2 /dev/block/loop253 $mnt/extras"

And add the following lines to stopbt:

Directly after line 18: "$bboxpath umount -l $mnt/extras"
Directly after line 19: "$bboxpath rm -r $mnt/extras"
Directly after line 23: "$bboxpath losetup -d /dev/block/loop253"

With the above changes done, and with Qemu finally installed on Backtrack, it would now be worth restarting your phone after exiting Backtrack.

Once the phone has restarted, you can now reload Backtrack.

Within Backtrack, open Terminal and cd to /extras. Once here, run the following command:

/usr/local/bin/qemu -m 256 -hda winme.img -vnc :2

To explain the above command, the "-m 256" specifies the amount of memory to provide the emulator, "-hda winme.img" specifies the image to use as the hard drive, and "-vnc :2" specifies the port to use (2 + 5900 = actual port to use) for vnc which also allows for connecting to the vnc over the network.

The command will appear to "hang" the system, but if you open up a vnc client on your phone, you can connect to Windows ME with the address of 127.0.0.1 and port 5902.

Hopefully everything runs smoothly, but if you have any problems setting this up then let me know.

Known Problems

- When VNC'ing into Windows (or any other OS emulated with Qemu), the host and local mouse are out of sync.

- Emulation is very slow.

- Currently no network connection (Working on this)

- Also looking at running Qemu from within Android, removing the need for Backtrack.