Friday, May 30, 2014

How I Converted My Chromebook into a Linux Laptop

Introduction

In previous posts I described my experiences with getting Bodhi Linux installed and working on Chromebooks, first a Samsung (ARM based) Chromebook and then a Lenovo Thinkpad X131e (Intel based) Chromebook.  In both cases I was forced to re-use the Chrome OS Linux kernel. Basically I would use the vbutil_kernel utility to repack the kernel used by Chrome OS in one partition, and I would install the Linux distribution (Bodhi in my case) in the next one.  By using the cgpt tool to select which partition was booted, I was able to select Chrome OS or Bodhi for the subsequent boots.

While the approach I described above was usable, it had some limitations:
  • In order to boot a different OS I had to be in developer mode. Thus, on every boot, I got the scary boot screen about OS verification being off (see below). Of course, I only had to type Ctrl-D to get past that screen and boot. However, if I accidentally hit the space bar it would start the process of reinstalling Chrome OS, which would cause me to lose most or all of my data. Although I have never done this, I have read of others who have. I could certainly see the possibility of powering on the machine in the morning, seeing the error message and (not thinking), hitting the space bar.
  • In order to leave space for two Chrome OS versions (when Chrome OS updates it updates the older version in case there is a failure), I lose about half of the SSD space that I could be using for my Linux distribution.
  • Because I was only able to use the Chrome OS kernel on my machine with my Linux distribution, there were issues:
    1. I wasn't able to use the latest Linux kernel available. Also, when I would update my Linux distribution, it would try to update the kernel to no avail.
    2. There were limitations in the kernel provided with Chrome OS. I learned this when I tried to install and use docker.  It was not possible to get docker working because of the way the kernel was compiled.
I should point out a couple of other things about the kernel. For the Samsung Chromebook there aren't a lot of options for kernels to use, because of the ARM architecture. For the Lenovo Thinkpad X131e Chromebook, it is theoretically possible to use vbutil_kernel to sign a different kernel to use. At least that is what I was told. I tried numerous times to do this. Using the verbose verification options of vbutil_kernel, I compared my signed kernel with the Chrome OS one. I could not discern a difference. Yet, I was unable to ever get a non-Chrome OS kernel to boot.  I should point out that, to my knowledge, those who said that a different kernel could be used had not done so with the Lenovo Thinkpad X131e Chromebook, but with other Chromebooks. My particular model is targeted only at the education market. I was only able to get one by getting a refurbished model in the secondary market.  So in terms of getting different Linux distributions running on it, I have (unfortunately) been somewhat of a trailblazer. My searches have failed to uncover much useful information about installing and using Linux distributions on that particular model.

You might be reading this and simply saying, Well you shouldn't have bought a Chromebook then.  I discussed why I bought Chromebooks in previous posts. I am not alone in this thinking. Jeff Hoogland, who heads the Bodhi Linux project (of which I am a part), discussed his thinking on using Chromebooks for Linux desktops here.

Given the limitations I was encountering with Linux on my Thinkpad Chromebook, I had two options to improve the situation:
  1. I could compile my own Chrome OS kernel, including the options I needed. I actually have some experience compiling a Chrome OS kernel in the past.
  2. I could flash a different ROM which allows installing and using any Linux kernel and distribution.
Although option #1 would theoretically be easier, I really don't care any more about being able to boot back into Chrome OS (which option #2 would prevent). I still have a Samsung Chromebook for that if I need it.  Option #2 provides a way to turn my Thinkpad Chromebook into a full-blown Linux desktop.  So, option #2 is the option I took.  As I will describe below, this is not a direction to be taken lightly.

Here by the way is the scary boot screen I was encountering at every boot:

Flashing a New Coreboot ROM

The Lenovo Thinkpad X131e Chromebook uses Coreboot and U-Boot to boot the system. You can find a brief description of it here.  The part that can be overwritten (replaced) is the Coreboot part.  There is a Google+ community which discusses (and in some cases provides ROMs for) Coreboot on Chromebooks here, owned by John Lewis.  John provides ROMs for various Chromebooks. You can find a discussion at his website FAQ page. After I discussed some of the issues I was having trying to utilize other Linux kernels on my Chromebook, he graciously volunteered to try building a Coreboot ROM for my model of Chromebook.

The payload used in the Coreboot ROMs John builds are SeaBIOS, which you can find described here.  These SeaBIOS payloads (that John provides) are great for booting Linux, which is what I am interested in. They may not be useful for Windows.

The tools available for flashing a new ROM are pretty easy to use. However, when considering doing this for a Chromebook there is one possibly significant issue. The Chromebook comes configured with ROM flashing disabled. That is, there is some type of write-protect for the writable ROM, and it is enabled by default. Thus, to flash a new ROM, you must disable this write protection for the ROM writing process.  Each Chromebook model is different. For many, you have to use a jumper across pins to disable the write-protect feature. For the Thinkpad X131e Chromebook, there is a switch.  That is the good news.  The bad news is you have to open up the Thinkpad and remove lots of parts to access that switch.

There is no documentation on the Google Chromebook pages about how to do this. Fortunately, I found the instructions in the hardware guide for the Lenovo Thinkpad X131e Chromebook.  The steps listed in the manual are:
  1. Disconnect the power and remove the battery. Removing the battery is very easy to do on Thinkpads.
  2. Remove the bottom slot cover.
  3. Remove the hard disk or solid-state drive if installed, or the empty hard disk bracket if not. My unit had an empty hard disk bracket.
  4. Remove the keyboard.
  5. Remove the keyboard bezel assembly.
  6. Locate and turn off the write-protect switch.
Steps 1 and 2 are trivial. Step 3 was simple, but I later determined was also unnecessary.  Step 4, removing the keyboard, is a little scary, especially since you have to disconnect a couple of ribbon connectors. These connectors are not like the old ones which plug in. Instead the ribbon is locked into a slot, and it is locked in by a little cover.  Step 5, removing the keyboard bezel assembly was a pain as well.  There was one ribbon connector like the ones I just described, plus one which was a plug-in socket. The plug-in socket was very small and took 15 minutes to unplug. Then to remove the bezel itself was complicated. The manual says to use a plastic pry tool. Once I got things started, I was able to use a plastic knife.

I am sure for people who work on these at a repair facility, these steps are simple. For someone who has not done it, it is not so simple. Although I had removed a Thinkpad keyboard before (different model), the ribbon connectors on this model were smaller and harder to deal with. The keyboard bezel was difficult as well.

Once I had everything removed, flipping the switch (location well described in the manual) was trivial.  Then I had to put things back together. Once I had things back together I tried restarting the system.  It started fine, but I quickly saw the keyboard was not working. So now I had to repeat steps 1 through 4 to remove the keyboard and play with the connectors. This time I skipped step #3. Needless to say after redoing the keyboard connectors and putting the keyboard back on, I did not screw in the keyboard nor put on the bottom plate until I knew the keyboard worked. It took a couple of tries but I got it working. Then I completely put everything back together.

Since I already had Bodhi Linux installed (using the Chrome OS kernel), I booted into Linux. I had previously downloaded the flashrom program provided by John Lewis and fixed the links to the needed libraries as described in his FAQ. 

I first used flashrom to save the existing ROM in case there was something wrong with the new one:

./flashrom -r x131e_chromeos_original.rom

The filename "x131e_chromeos_original.rom" was the name I used for the saved ROM. Next I wrote the ROM John had made available to the flash:

./flashrom -w coreboot-stout-seabios-270514.rom

First, it wrote out some information about the flashrom version. Eventually it said:

Erasing and writing flash chip...

It took several minutes. Then it said it was verifying the flashing and soon after it said verification was successful. So, I rebooted. I should note here that John did not have this model of Chromebook, so to my knowledge, I ws the first to try it.

It booted up without the scary boot screen. Instead, it booted up with a single line describing the SeaBIOS version and that is was created by John Lewis. Then it said to use F12 to select what to boot. I had actually discussed this with John before trying the ROM. Chromebooks do not have F11 and F12 (F12 is the norm for getting to a BIOS screen). He wasn't sure if he had changed it to ESC or F10 or not. He said if not, I could use an external keyboard. Fortunately, I had a USB keyboard.  So I powered off, plugged in the external keyboard. I had already inserted a bootable USB live CD of Bodhi 3.0.0 beta.  I selected the USB drive and tried to boot up the Live CD. It started but hung at the splash screen. As I have seen this type of thing before, I tried again, selecting the USB drive again, but this time I was able to edit the boot line and turn off the splash and specify vga=771. This time the Live CD came up properly.

At this point I decided to install Bodhi. I was able to repartition the main SD card, with some swap space and the rest of the 16GB for my Linux distribution. By doing this, I was erasing the various Chrome OS partitions and my previous Linux install. Upon reboot, I got the SeaBIOS screen and after a second or so of waiting for a possible F12 press, it started my Bodhi distribution. In about 10 seconds I was up and running.

I mentioned the F12 problem to John and he was nice enough to send me a new ROM which used ESC instead of F12. I used flashrom again to write the ROM. With that updated version, I can now use ESC to select the boot device within SeaBIOS.  I made a donation to John because of his efforts.

Running Bodhi on My Thinkpad

I had been running Bodhi beta 3 before (using the Chrome OS kernel), so there were few surprises.  One issue I encountered was that when the screen blanked I could not recover.  However, I then got the latest updates and I noticed a couple of interesting things:
  1. The blanking issue went away. I was able to move the cursor or hit a key and the screen came back as expected.
  2. The look was fantastic! Unlike the previous fairly simple desktop background, there was now an impressive looking desktop background which looks 3 dimensional and has various color gradients.  And the quality of text and icons within various applications looks really sharp.  I don't know if this was due to a theme change or improvements to Enlightenment, but I can say that those who move up from Bodhi 2.4 to Bodhi 3.0 will see a dramatic improvement.
Here is a picture of the desktop:


I think the desktop background is impressive. At the top you can see the shelf. The shelf contains icons for applications as well as widgets for things like the battery, etc..  Similar to Ubuntu Unity, the application icons are used both to start applications and to indicate those that are running. You may be able to see the browser (blue globe) icon with a little orange dot under it to the right side. This indicates an instance is running. If you move the cursor below the icon, it will show you the running instance(s) that you can select.  If you click on the icon itself, it opens a new instance. This is a little different from how the Ubuntu Unity taskbar works. Also, unlike what Ubuntu Unity allows, this shelf can be placed on either side, or top or bottom. You can add additional shelves as well.  Similar to Ubuntu Unity and Mac, you can automatically hide the shelves as well.
 
You also see I have an external drive. The blue dot indicates it is mounted.
 
I initially chose Bodhi because of the Enlightenment desktop environment. With this new version of Bodhi, I am seeing even more enhancements to the Enlightenment desktop environment which makes it unique and more fun and useful.
 
One issue I have encountered is inability to suspend. To be clear, it appears to suspend, but instead of waking up properly, it reboots instead.  I even tried a couple of tpm_tis settings that I used previously to get suspend to work previously. They did not seem to make a difference. Interestingly, I saw that it appeared that the tpm_tis module was being started according to the system log. I tried installing tcsd and trousers which are for trusted computing, and although I was able to get them installed, I still have not gotten suspend to work.  John indicated he thought it was a limitation in the ROM.  I don't know. Having suspend is not a big deal to me anyway since I can boot in about 10 seconds. I normally shut down my machine (rather than suspend) anyway.

Summary

In this post I have described how I turned by Lenovo Thinkpad X131e Chromebook into a full-blown Linux laptop.  I chose the laptop for the hardware (SSD instead of hard drive, enough memory, long battery life) and price. I always intended to run Linux on it.  Although it has been a long and sometimes scary (taking parts of the unit apart to flip a switch) process, I now have the laptop I want booting the Linux distribution I prefer.

7 comments:

  1. I recently got one of these x131e chromebooks myself. I'm not feeling a lot of love for chromeos at the moment. I think I'd like to install archlinux on it. Does the replacement seabios allow for booting directly from the hard drive? I would like to drop in a full SSD and just leave the chromeos one alone if possible.

    ReplyDelete
  2. Yes, the replacement seabios does allow for booting directly from the hard drive (actually an SSD I believe). However, if you remove the old SSD and replace with a new one, I don't know if you would be able to re-use the old SSD to run chromeos in the future on that machine. I don't know whether the Seabios would boot the ChromeOS type of Linux.

    I basically overwrote my old chromeos SSD with Bodhi (Ubuntu). Of course, if you just want a bigger SSD or something, yes that should work fine with this BIOS.

    ReplyDelete
  3. Great work Chris!
    I have an X131e too, and while bodhi was the first dual-boot I got to work, I realized it was a 32-bit (so my new 16GB RAM modules were going to waste). Do you have the link for John's BIOS, or has the site link been updated?

    Thanks for being the first to test out the X131e for the rest of us!

    ReplyDelete
  4. +Zhong Liang Ong, the ROM (the second one) I flashed was at http://johnlewis.ie/coreboot-stout-seabios-290514.rom. I found out about it on the "coreboot on Chromebooks" Google+ group: https://plus.google.com/communities/112479827373921524726. It is a pain to access the switch to be able to flash a new ROM, but once I did it it was worth it. I have no regrets booting straight into Linux. Good luck.

    ReplyDelete
  5. Thanks for this description. Seems like I got it too late. I have a x131e with intel processor, thought this might be a better option compared to the AMD processor because it was my plan to get Linux Mint running. I extra added a 128GB SSD and additional RAM.
    But I I understood correctly, I have to flash the ROM anyway in order to install a native Linux, right? My problem is, that I am not able to unscrew all screws for the keyboard bezel, basically one was impossible to to loosen. Thus, I have no chance to access the read/write switch. Am I right that I have now no chance to install a native Linux system on the x131e?

    ReplyDelete
  6. To the Anonymous poster who could not access the read/write switch:

    Yes, I believe you cannot flash a new ROM without removing the keyboard to access the read/write switch. In that case, if you want to use Linux, you can still run Linux, but with a ChromeOS kernel. See my earlier post: http://allhailtothepenguin.blogspot.com/2014/03/how-to-install-bodhi-linux-on-lenovo_3.html. You can put any type of Linux you wish, as long as it will operate with that ChromeOS kernel. Certainly not ideal though.

    ReplyDelete
  7. with the second ROM, as you mention above - can you cold boot and press ESC using the built-in keyboard and select the drive to boot, or do you still need an external USB keyboard? the reason i ask some people have problem with the non-working internal keyboard on cold boot, as described here:

    http://comments.gmane.org/gmane.comp.bios.coreboot.seabios/8196

    cheers!

    ReplyDelete