September 11, 2013

ChromeOS in VMWare Player

Background

Recently my kids have all gotten Chromebooks at school. The high school students bring their Chromebooks home which means I get to play a little with them. Since the Chromebook is the property of the school system I can't actually do much to them, and even the little I can do scares my wife.
So instead I did what all sane people do, I looked around to find out how I can run ChromeOS in a virtual machine.

Available Options

It turns out there isn't really much in the way of a straight up ChromeOS virtual machine. Google doesn't seem to be interested in that market. There are some ChromiumOS virtual machines but they don't integrate as well.
I ran across Jay Lee's post which contains some instructions on converting his supplied VMWare image into a real ChromeOS virtual machine. Pretty much the instructions show you how to run his script which downloads a recovery image from Google onto the virtual machine. The problem is the recent recovery images are bigger than the partition space in his virtual machine. I could likely move and resize partitions to get it to work, but that seemed too likely to fail.
Hexxeh, has made some very good ChromiumOS builds that can install on a real machine, and he has made VMWare and VirtualBox images as well. But these are ChromiumOS which aren't was tightly integrated into the Google ecosystem, plus they don't have flash and a few other things that are only distributed with the ChromeOS.

Creating a ChromeOS Virtual Machine

These instructions are for VMWare Player, but other than the initial changes to the virtual machine, the rest of the instructions are specific to the "guest" machine and have no dependency on the "host" virtualization software. In other words, the VirtualBox image will probably work just as well.

Downloading the Virtual Machine

Head on over to Hexxeh's Chromium OS Builds page. And download the VMWare image of the latest Vanilla build.

Extract the ZIP File

Extract the ZIP file to the location where you want your virtual machine to reside.
The extracted files will be the virtual machine definition (.vmx) and the virtual machine disk (.vmdk). Pay attention to the name of the virtual machine disk file, you will need it in the next step.

Fix the Virtual Machine

Using your favorite text editor, open the .vmx file. One line has to be changed and one line has to be added.

Edit the disk image name.


Find the ide0:0.fileName line, and change the "ChromeOS-Vanilla-VMWare.vmdk" to the name of the .vmdk file extracted from Hexxeh's ZIP file.

Add an Ethernet definition.


Add the following line anywhere in the .vmx file.
ethernet0.virtualDev = "e1000"
Save and close the .vmx file.

Mac Notes

In the following steps you will need to press the Control+Option+F2 and Control+Option+F1 keys. On most Mac keyboards this will require you to use the Fn key as well. It may be helpful to go into System Preferences -> Keyboard and enable the "Use all F1, F2, etc. keys as standard functions keys" option.

Boot the Virtual Machine

You can boot the virtual machine by double clicking on the .vmx file. This will boot into the ChromiumOS, not our final ChromeOS. Make sure that Ethernet is selected in the "Select a network" drop down box, then click "Continue"

Sign Into Chromium

You will have to sign into Chromium using a valid Google account. The guest account cannot make the changes we want to make.
Just sign in as though you were on a web page. Two step verification is also supported, use it.

Logged Into Chromium

Now you should see the pretty Chromium desktop.

Enable Developer Mode

Enabling developer mode is pretty easy, but there are a number of ways found in web searches that do not work.

Go into settings:


Click on the Help menu


Click on the "More info..." link


Under the Channel drop down, select the "Dev - Unstable" option

Prepare to Get the Recovery Image

From the virtual machine press Ctrl+Alt+F2 (or Control+Option+F2 on Mac) to switch to the text console. (You can use Ctrl+Alt+F1/Control+Option+F1 to switch back.)
The username is "chronos", the password is currently "facepunch". Alternate passwords could be "chronos", "password" or nothing.
Once you have successfully logged in, run "sudo bash" to become root. The password will be the same password used to login above.
As root run:
touch /mnt/stateful_partition/.developer_mode # may not be needed
cd /tmp # to get to a read/write partition
wget http://goo.gl/4suhf # to download the script
bash 4suhf # to run the script

An alternate script can be found at:
http://cr-48-ubuntu.googlecode.com/files/overwrite-chromiumos-with-chromeos.sh
This should fix the problem for people experiencing the unexpected token 'newline' error.

Select the Recovery Image 


Most of the images should work. I have only tested the Samsung Chromebook Series 5 550 image.

Once an image is selected it will be downloaded.

When the download is complete it will be unpacked and the image will be written to the virtual disks.

Finally the script will finish. The error on line 939 is not critical. Running any commands now will result in a segmentation fault. When the script is finished the system will be pretty much unresponsive, this is normal.

Restart the Guest Machine

Since the ChromiumOS has been overwritten it will be unresponsive and you will have to "hit the reset button" on the virtual machine. On VMware Player, click on the obvious pause button and choose "Restart Guest".

Ignore the Error Behind the Curtain

When the virtual machine starts you will get a warning that a factory error has been detected. Since you are the factory it is up to you to solve the warning. Just "Skip for now".

 Repeat the Sign-In Steps Above

This is a new ChromeOS, nothing on the previous virtual hard drive has been preserved. You will have to go through the login procedure from above again.

Chrome-Sweet-ChromeOS

Finally you have a complete ChromeOS system.

Caveats

I don't know if this is illegal, immoral or fattening. I can't guarantee that this will work, or that it will not trash every electronic memory you have ever made. I know it worked for me.
Automatic updates may or may not work, and may or may not continue to work. See the gotchas from Jay Lee's post.