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.

45 comments:

  1. Interesting. Only if I had a Windows machine at home to try it out. All I have is ChromeOS devices.... :)

    Does the ChromeOS update work in VMware Player?

    ReplyDelete
    Replies
    1. I haven't tried it, but the site I got started from (http://chromeos-cr48.blogspot.com/2012/10/how-to-run-chrome-os-not-chromium-os-on.html) indicated that the updates would not work. However re-running the script should do it.

      Delete
  2. there is some problem, after donwloading 4suhl, at bash 4suhl it gives the error syntax error near unexpected token 'newline' . Any Idea?

    ReplyDelete
    Replies
    1. That's new to me, I haven't had any trouble with it (and I ran through the process several times to get it captured for this tutorial). You can try using sh instead of bash.

      Delete
    2. I'm getting the same error, syntax error neare unexpected token 'newline'

      Delete
    3. Eric Hart found a possible solution:
      Type this instead:
      wget http://cr-48-ubuntu.googlecode.com/files/overwrite-chromiumos-with-chromeos.sh; sudo bash overwrite-chromiumos-with-chromeos.sh

      Delete
  3. It works great in a VM, well done this tutorial. The only thing is: Chromium boots also from USB after converting the vmdk, but unfortunately Chrome OS doesn't. Any idea how we can get this done???

    ReplyDelete
    Replies
    1. It's probably related to the restore image you chose. One thing you can try is to boot Chromium on the USB after converting the vmdk, then running this script on the machine you're wanting to use. That should make it use the USB drive correctly.

      Delete
    2. Both Chromium OS aswell as Chrome Os conversions give the next error on USB-boot:

      kernel panic unable to mount root fs on unknown-block(8,3)

      P.S.: I remember in the past conversion of the Chromium OS vmdk to img succeeded. I must mistaken myself.

      Delete
    3. The USB Chromium OS version of Hexxeh seems to be to small. Isn't there away to merge vmdk and usb version with a partition manager.
      On which partition is the crucial info to boot from usb?? Anyone knows??
      Mayby I can copy that partition.

      Delete
    4. tried out arnoldthebat image but also to little space in user/tmp. How do I change dir and where to?

      Delete
    5. Sorry for the late reply William, I don't get much free time in the fall, lots of hardware development then.

      If you can boot into a regular Linux you might be able to resize the partition on the USB. Otherwise you might create a new partition in memory that would be big enough.

      Delete
  4. Works really well. For me the process diverged after executing the script where it outputs

    Unpacking the zipfile
    RootFS Start:.....

    My console was then blanked and it was quite some time until I got the

    localhost tmp #

    prompt. The first time I tried it I didn't wait for this prompt before restarting and it never would boot. The second time I let that propmpt sit and it attempted to restart itself after yet another quite a while. I got some messages about the restart and it finally hung with a message about booting the kernel. I let that sit another quite a while, making sure that VMware Player's disk indicator had stopped blinking, and then manually restarted and all went as described after that.

    It plays YouTube but I can't yet get sound out of it.

    I've been wanting this for a long time to assess Chrome OS before plunking down any money and this allows a full check of the OS as well as being useful unto itself. Many thanks.

    I wish you could get this working with a USB image and Broadcom drivers so I could put it on my old ASUS 1015 netbook. I did get a USB working on that with Arnoldthebat's image but without a functioning trackpad. I may just try this on it and see what happens. Probably blow it out of the water.

    Thanks again.

    ReplyDelete
    Replies
    1. I'll bet you could run this script from Arnoldthebat's image on your netbook which would get you the possibility of a functioning image. Given the number of times I had to start over with this process to get it right, I'll bet you'll be restoring the original image to the USB drive a couple times.

      Delete
    2. Yeah, I'm going to boot my modified Arnoldthebat's image up on the ASUS and see what the script does but not immediately. I'll report back for sure when I get to it. Since the download has to be pretty hardware agnostic it might even make the machine's built in Broadcom wireless adapter and its touchpad work. (a USB wireless adapter and USB mouse works ok but I'd really like to have it work with the native hardware.)

      Michael, on the Google+ Chrome OS community, http://goo.gl/RQqwX, I described what has to be done with images having Ethernet drivers that are incompatible with a machine in order to make them work with the (really cheap) Edimax EW-7811UN wireless USB adapter but it's all pretty fragmented. If you want to apply your didactic talents to create a more coherent procedure from that it would be a very good thing. :-) My input starts with Kjetil Solheim Aarsand's post on May 31.

      I'm now looking for a way to disable the inactivity sleep built into it. There appears to be no setting for that. On VMware that turns into a full power off. There is some info at http://goo.gl/aoXjX5 but I haven't played with it yet. If you know you're going inactive for a while Ctrl-Alt-F2 into the developer console seems to inhibit sleep shutdown with Ctrl-Alt-F1 taking you back.

      Delete
    3. Don, I've gotten to the point where it sits waiting for "booting the kernel" was there any trick to making it move forward? I tried rebooting and no change.

      Thanks,
      Aaron

      Delete
    4. Same error here! How to get through this

      Delete
  5. Worked great on a HP proobook (4320s) running chromium os installation from Arnoldthebat's image. No errors running the script, though it seemed a bit unresponsive and didn't display anything after "Unpacking the zipfile", but after a few minutes it restarted and everything worked (sound, touchpad, flash, hangouts etc).

    ReplyDelete
    Replies
    1. Forgot to write that i selected the "1 - HP Pavillion chromebook" option when I installed...

      Delete
  6. When I run the 4suhf script I get the following error -

    4suhf: line 1: syntax error near unexpected token 'newline'
    4suhf: line 1 ''

    Any ideas?

    ReplyDelete
    Replies
    1. Eric Hart found a possible solution:
      Type this instead:
      wget http://cr-48-ubuntu.googlecode.com/files/overwrite-chromiumos-with-chromeos.sh; sudo bash overwrite-chromiumos-with-chromeos.sh

      Delete
  7. This helped me with the error:
    4suhf: line 1: syntax error near unexpected token 'newline'
    4suhf: line 1

    Type this instead:
    wget http://cr-48-ubuntu.googlecode.com/files/overwrite-chromiumos-with-chromeos.sh; sudo bash overwrite-chromiumos-with-chromeos.sh

    ReplyDelete
    Replies
    1. Thanks Eric, I put that as an alternate script in the instructions.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Man, I really appreciate your good instructions. Your instructions were clear. They worked. You told me that I could ignore the various errors. As a further plug I shall writeup this positive experience on our majzel.blogspot.com (small plug). I currently running a Samsung Chromebook, but it's a little slow. So as a Chrome OS advocate, until a more powerful machine is available, a stopgap solution is to run Chrome OS in a VM guest on a regular windows or OSX laptop. Again, really great instructions. Thanks and regards marcus b.

    ReplyDelete
  10. These are excellent instructions! They worked just as expected. I am using VMWare Fusion on the Mac, so I have a couple of minor modifications for Mac users:

    - Before starting, go into "System Preferences->Keyboard" and select the "Use all F1, F2, etc. keys as standard function keys" option. That will allow you to escape to the developer mode in the first step of "Prepare to Get the Recovery Image."

    - In the "Prepare to Get the Recovery Image" step, you need to use Control+Option+F2 to switch and Control+Option+F1 to switch back.

    - Once complete, youYou can then revert the system preferences for the keyboard to its original setting (if you wish).

    I selected the Acer C720 image, since that was what I was looking at for my son. As another commenter noted above, I too do not have sound in the VM (yet) and the mouse at full speed is painfully slow. But, it does work and gives me a good idea what the environment is like and how it works.

    ReplyDelete
    Replies
    1. I added in your Mac OS notes. I haven't tried it on any of my Macs, but I've used Oracle's VirtualBox on Mac for other Linux builds. My Mac is painfully slow and my wife's is not often available.

      Delete
  11. I receive an error during the relocation phase...

    Kernel panic - not syncing: No init found. Try passing init= option to kernel.

    I'm attempting this on VMW WS 9 connected with IDE controller. I've tried multiple different images and each get this same error.

    Please advise, thank you.

    ReplyDelete
    Replies
    1. Discovered the issue. Previously, I had checked the box to 'update' the VD when attaching it to my VM. Attaching it as-is allowed the process to complete.

      Delete
    2. Although sound is not functioning and the mouse is slowwww for me as well, the rest of the environment seems to works nicely. Thanks for the guide!

      Delete
    3. Scott, could you please clarify what you mean about updating the VD? I'm having the same problem, but I can't figure out what you did. I assume VD = virtual disk, but I don't see a box to update or run as-is...

      Delete
    4. Just to clarify, below the Kernel panic error, my error is PID: 1, comm: swapper/0 Not tainted 3.8.11 #1.

      Delete
    5. This comment has been removed by the author.

      Delete
  12. Firstly awesome post! It's what I've been looking for to test and see if I want to purchase a Chromebook. (I know they're cheap, but I'm still skint) So many thanks!

    I know this is an old post, but hopefully someone will reply and help.

    I can get a VMWare version running perfectly but was trying like William Droog to get a USB version.

    Problem is I have an Nvidia based PC so no gfx will show up on an initial usb boot. I saw the updates had an Acer C720 version which in theory should hold nvidia drivers, so I boot via plop USB in VMware in the hopes to build the update via VM first.

    Anyway, I install vanilla Hexxeh version to usb, GPart to ensure there enough space in the partitions as Will had problems with space (as above). All goes swimmingly until the "unpacking" stage, then it crashes and reboots but too quick to see what the fault was.

    Is there anyway to pause before the crash in order to trouble shoot. Or, is it possible to convert my updated VMWare version to an .IMG file to try on a USB stick instead?

    ReplyDelete
    Replies
    1. Ahh, scratch all this. Seems I read the specs for the Acer wrong. Doesn't look like there's any nVidia based Chromebooks like I thought, they're all Intel HD. Oh well, stick with the VMware version and decide from there.

      Delete
  13. I'm not able to get this to work. Am using VMWare Workstation 10.0.1. I did succesfully complete all the steps down to the final where I got the bus error (Core dumped) message. I then did a restart of the guest OS from the menu. At that point, the screen went blank, started up, then went blank again. About 30 seconds later it rebooted (saw the VM restart) and then it went blank and just sits there. No graphics at all. Nothing. I chose the Samsung Chromebook Series 5 550 as the image. I had tried the Google Pixel but that proved too large to unpack. Any ideas?

    ReplyDelete
    Replies
    1. I'm getting the same issue. I tried Samsung Chromebook Series 5 550 & Cr-48 and got the same result.

      Delete
    2. I'm also getting the same blank screen after restart issue. Help please?

      Delete
  14. Same here - though the blank screen is not really nothing. you can press CTRL ALT F2 and get to a console prompt ... you just dont get a GUI for some reason.

    Any help would be appreciated.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Same here, no GUI, but can get to console. Anyone get through this?

    ReplyDelete
  17. When I restart in the final step I get a dialog box saying that the CPU has been disabled. The main screen shows the following

    early console in decompress_kernal
    KASLR using RDTSC...

    Decompressing Linux...

    uncompression error

    - - System halted_

    ReplyDelete
  18. I added the line for the Ethernet Virtual Adapter but I still can not get the wireless card to be recognized..any help greatly appreciated...JV

    ReplyDelete